Skip to content

Commit

Permalink
Suppress pymatgen element data warnings when imputing (#934)
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed Apr 22, 2024
1 parent 19798db commit e58dff5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion matminer/utils/data.py
Expand Up @@ -357,7 +357,12 @@ def get_elemental_property(self, elem, property_name):
block_key = {"s": 1.0, "p": 2.0, "d": 3.0, "f": 3.0}
return block_key[getattr(elem, property_name)]
else:
value = getattr(elem, property_name)
# Suppress pymatgen warnings for missing properties if we are going to impute anyway
with warnings.catch_warnings():
if self.impute_nan:
warnings.simplefilter("ignore", category=UserWarning)
value = getattr(elem, property_name)

if self.impute_nan:
if value and not pd.isnull(value):
return value
Expand Down

0 comments on commit e58dff5

Please sign in to comment.