Skip to content

Commit 83f06f3

Browse files
authored
replace assert (#4527)
1 parent c621d44 commit 83f06f3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/pymatgen/core/periodic_table.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,9 +1640,9 @@ def get_el_sp(obj: int | SpeciesLike) -> Element | Species | DummySpecies:
16401640
# If obj is an integer, return the Element with atomic number obj
16411641
try:
16421642
flt = float(obj)
1643-
assert flt == int(flt) # noqa: S101
1644-
return Element.from_Z(int(flt))
1645-
except (AssertionError, ValueError, TypeError, KeyError):
1643+
if flt.is_integer():
1644+
return Element.from_Z(int(flt))
1645+
except (ValueError, TypeError, KeyError):
16461646
pass
16471647

16481648
# If obj is a string, attempt to parse it as a Species

0 commit comments

Comments
 (0)