diff --git a/src/equisolve/utils/convert.py b/src/equisolve/utils/convert.py index fcd09c6..c441db5 100644 --- a/src/equisolve/utils/convert.py +++ b/src/equisolve/utils/convert.py @@ -43,11 +43,13 @@ def ase_to_tensormap( positions_gradients = None if stress is not None: - cell_gradients = [-f.arrays[stress] for f in frames] + cell_gradients = [-f.info[stress] for f in frames] else: cell_gradients = None - return properties_to_tensormap(values, positions_gradients, cell_gradients) + return properties_to_tensormap( + values, positions_gradients, cell_gradients, property_name=energy + ) def properties_to_tensormap( @@ -55,6 +57,7 @@ def properties_to_tensormap( positions_gradients: List[np.ndarray] = None, cell_gradients: List[np.ndarray] = None, is_structure_property: bool = True, + property_name: str = "property", ) -> TensorMap: """Create a :class:`equistore.TensorMap` from array like properties. @@ -94,7 +97,7 @@ def properties_to_tensormap( values=np.asarray(values).reshape(-1, 1), samples=Labels(["structure"], np.arange(n_structures).reshape(-1, 1)), components=[], - properties=Labels(["property"], np.array([(0,)])), + properties=Labels([property_name], np.array([(0,)])), ) if positions_gradients is not None: diff --git a/tests/equisolve_tests/utils/convert.py b/tests/equisolve_tests/utils/convert.py index f0552dd..e426c4a 100644 --- a/tests/equisolve_tests/utils/convert.py +++ b/tests/equisolve_tests/utils/convert.py @@ -43,7 +43,7 @@ def test_ase_to_tensormap(self, energies, forces, stress): frame = ase.Atoms(self.n_atoms * "H") frame.info["energy"] = energies[i] frame.arrays["forces"] = forces[i] - frame.arrays["stress"] = stress[i] + frame.info["stress"] = stress[i] frames.append(frame) property_tm = ase_to_tensormap(frames, "energy", "forces", "stress")