Skip to content

Commit

Permalink
Merge branch 'feat/shapes_jupyter' of github.com:lab-cosmo/chemiscope…
Browse files Browse the repository at this point in the history
… into feat/shapes_jupyter
  • Loading branch information
ceriottm committed Aug 28, 2023
2 parents 8c87fcc + 1a416aa commit 51fa08c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions python/chemiscope/structures/_ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
12 changes: 5 additions & 7 deletions python/chemiscope/structures/_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 51fa08c

Please sign in to comment.