From d6b283b8b15adfec2ca5e4f1fa963cf8f1e75790 Mon Sep 17 00:00:00 2001 From: Michele Ceriotti Date: Mon, 28 Aug 2023 09:48:42 -0700 Subject: [PATCH 1/3] Update python/chemiscope/structures/_shapes.py Co-authored-by: Guillaume Fraux --- python/chemiscope/structures/_shapes.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/python/chemiscope/structures/_shapes.py b/python/chemiscope/structures/_shapes.py index 5c84c9d5b..8bcebcec0 100644 --- a/python/chemiscope/structures/_shapes.py +++ b/python/chemiscope/structures/_shapes.py @@ -129,13 +129,11 @@ def ellipsoid_from_tensor(tensor, scale=1.0, force_positive=False): ax = np.sqrt(eigenvalues[0]) ay = np.sqrt(eigenvalues[1]) az = np.sqrt(eigenvalues[2]) - except FloatingPointError: - print( - "Non-positive definite tensor found with eigenvalues ", - eigenvalues, - ".\nIf this is acceptable, set `force_positive=True` to take the absolute values.", - ) - raise + except FloatingPointError as e: + raise ValueError( + f"Non-positive definite tensor found with eigenvalues {eigenvalues}.\n" + "If this is acceptable, set `force_positive=True` to take the absolute values.", + ) from e np.seterr(**old_settings) # makes sure the rotation is proper From ad4ab3d18aa2db8d24d71866159f5a11561fe658 Mon Sep 17 00:00:00 2001 From: Michele Ceriotti Date: Mon, 28 Aug 2023 09:48:56 -0700 Subject: [PATCH 2/3] Update python/chemiscope/structures/_ase.py Co-authored-by: Guillaume Fraux --- python/chemiscope/structures/_ase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/chemiscope/structures/_ase.py b/python/chemiscope/structures/_ase.py index 2f9ab5be8..caeaa4dcf 100644 --- a/python/chemiscope/structures/_ase.py +++ b/python/chemiscope/structures/_ase.py @@ -352,7 +352,7 @@ def extract_tensors_from_ase(frames, key="tensor", **kwargs): for f in frames: if key not in f.arrays: - raise IndexError(f"Key {key} not found in Atoms frame") + raise IndexError(f"Key {key} not found in `Atoms.arrays`") values = f.arrays[key] if len(values.shape) != 2 or (values.shape[1] != 6 and values.shape[1] != 9): raise ValueError( From 1a416aa9c04d90f8818985a29ebd1d3aabb31bb6 Mon Sep 17 00:00:00 2001 From: Michele Ceriotti Date: Mon, 28 Aug 2023 09:50:45 -0700 Subject: [PATCH 3/3] Update python/chemiscope/structures/_ase.py Co-authored-by: Guillaume Fraux --- python/chemiscope/structures/_ase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/chemiscope/structures/_ase.py b/python/chemiscope/structures/_ase.py index caeaa4dcf..4e00152e7 100644 --- a/python/chemiscope/structures/_ase.py +++ b/python/chemiscope/structures/_ase.py @@ -322,7 +322,7 @@ def extract_vectors_from_ase(frames, key="forces", **kwargs): for f in frames: if key not in f.arrays: - raise IndexError(f"Key {key} not found in Atoms frame") + raise IndexError(f"Key {key} not found in `Atoms.arrays`") values = f.arrays[key] if len(values.shape) != 2 or values.shape[1] != 3: raise ValueError(