diff --git a/python/chemiscope/structures/_ase.py b/python/chemiscope/structures/_ase.py index 2f9ab5be8..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( @@ -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( diff --git a/python/chemiscope/structures/_shapes.py b/python/chemiscope/structures/_shapes.py index ae06c1957..c79c005e2 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