Skip to content

Commit 581f6ce

Browse files
lukaspieLukas Pielsticker
andauthored
fix atom_types parsing (#723)
Co-authored-by: Lukas Pielsticker <you@example.com>
1 parent 17e4a2a commit 581f6ce

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/pynxtools/nomad/parser.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ def _get_chemical_formulas(self) -> tuple[set[str], set[str]]:
461461
chemical_formulas: set[str] = set()
462462

463463
for sample in self._sample_class_refs["NXsample"]:
464-
if (atom_types := sample.get("atom_types__field")) is not None:
464+
if sample.get("atom_types__field") is not None:
465+
atom_types = sample.atom_types__field
465466
if isinstance(atom_types, list):
466467
for symbol in atom_types:
467468
if symbol in chemical_symbols[1:]:
@@ -477,6 +478,10 @@ def _get_chemical_formulas(self) -> tuple[set[str], set[str]]:
477478
for symbol in atom_types.replace(" ", "").split(","):
478479
if symbol in chemical_symbols[1:]:
479480
element_set.add(symbol)
481+
else:
482+
self._logger.warn(
483+
f"Ignoring {symbol} as it is not for an element from the periodic table"
484+
)
480485
# given that the element list will be overwritten
481486
# in case a single chemical formula is found we do not add
482487
# a chemical formula here as this anyway be correct only

0 commit comments

Comments
 (0)