Skip to content

Conversation

@DanielYang59
Copy link
Contributor

@DanielYang59 DanielYang59 commented Oct 22, 2025

Currently get_el_sp uses assert to check if obj is integar, this could be bypassed by the optimization flag (-O) and results in surprising behaviour, for example:

python3 -c "from pymatgen.core.periodic_table import get_el_sp; print(get_el_sp(4.5))"
>>> ValueError: Can't parse Element or Species from 4.5

However with -O it bypasses assert and gives Be because of int(flt):

python3 -O -c "from pymatgen.core.periodic_table import get_el_sp; print(get_el_sp(4.5))"
>>> Be

@DanielYang59 DanielYang59 marked this pull request as ready for review October 22, 2025 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant