diff --git a/openmc/material.py b/openmc/material.py index 7ffa899a19..cd19225364 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -464,16 +464,16 @@ class Material(object): Nuclide to remove """ + cv.check_type('nuclide', nuclide, string_types + (openmc.Nuclide,)) - if not isinstance(nuclide, openmc.Nuclide): - msg = 'Unable to remove a Nuclide "{}" in Material ID="{}" ' \ - 'since it is not a Nuclide'.format(self._id, nuclide) - raise ValueError(msg) + if isinstance(nuclide, string_types): + nuclide = openmc.Nuclide(nuclide) # If the Material contains the Nuclide, delete it for nuc in self._nuclides: - if nuclide == nuc: + if nuclide == nuc[0]: self._nuclides.remove(nuc) + break def add_macroscopic(self, macroscopic): """Add a macroscopic to the material. This will also set the @@ -625,15 +625,14 @@ class Material(object): Element to remove """ + cv.check_type('element', element, string_types + (openmc.Element,)) - if not isinstance(element, openmc.Element): - msg = 'Unable to remove "{}" in Material ID="{}" ' \ - 'since it is not an Element'.format(self.id, element) - raise ValueError(msg) + if isinstance(element, string_types): + element = openmc.Element(element) # If the Material contains the Element, delete it for elm in self._elements: - if element == elm: + if element == elm[0]: self._elements.remove(elm) def add_s_alpha_beta(self, name):