Skip to content

Commit

Permalink
test unknown calc keys
Browse files Browse the repository at this point in the history
  • Loading branch information
PythonFZ committed Jun 26, 2024
1 parent fca4216 commit cf1eb34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"s22_all_properties",
"s22_info_arrays_calc",
"s22_mixed_pbc_cell",
# "s22_illegal_calc_results",
"s22_illegal_calc_results",
"water",
],
)
Expand Down
4 changes: 4 additions & 0 deletions znh5md/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def extract_atoms_data(atoms: ase.Atoms) -> ASEData:

if atoms.calc is not None:
for key, result in atoms.calc.results.items():
if key not in all_properties:
uses_calc.append(key)
value = np.array(result) if isinstance(result, (int, float)) else result
if value.ndim > 1 and value.shape[0] == len(atomic_numbers):
particles[key if key != "forces" else "force"] = value
Expand All @@ -124,6 +126,7 @@ def extract_atoms_data(atoms: ase.Atoms) -> ASEData:
pbc=pbc,
observables=info_data,
particles=particles,
metadata={key: {"unit": None, "calc": True} for key in uses_calc},
)


Expand All @@ -143,6 +146,7 @@ def combine_asedata(data: List[ASEData]) -> ASEData:
pbc=pbc,
observables=observables,
particles=particles,
metadata=data[0].metadata, # we assume they are all equal
)


Expand Down

0 comments on commit cf1eb34

Please sign in to comment.