From 7d0c4aa1d6504cd82204f86221b9b07e5b37464d Mon Sep 17 00:00:00 2001 From: Fabian Zills <46721498+PythonFZ@users.noreply.github.com> Date: Wed, 24 Jul 2024 18:08:46 +0200 Subject: [PATCH] convert lists to `np.array` (#101) * convert lists to np.array * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- znh5md/format.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/znh5md/format.py b/znh5md/format.py index bc3f3bc..a5b463f 100644 --- a/znh5md/format.py +++ b/znh5md/format.py @@ -160,7 +160,9 @@ def extract_atoms_data(atoms: ase.Atoms) -> ASEData: 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 + value = ( + np.array(result) if isinstance(result, (int, float, list)) else result + ) if value.ndim > 1 and value.shape[0] == len(atomic_numbers): particles[key if key != "forces" else "force"] = value else: