Skip to content

Commit 1af6aef

Browse files
authored
Update snap.py
1 parent f1f9c0a commit 1af6aef

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

structuretoolkit/analyse/snap.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,8 @@ def _extract_computes_snap(
545545
np.ndarray: Output of the LAMMPS compute command
546546
"""
547547
lmp_atom_ids = lmp.numpy.extract_atom_iarray("id", num_atoms).flatten()
548-
assert np.all(lmp_atom_ids == 1 + np.arange(num_atoms)), (
549-
"LAMMPS seems to have lost atoms"
550-
)
548+
cond = np.all(lmp_atom_ids == 1 + np.arange(num_atoms))
549+
assert cond, "LAMMPS seems to have lost atoms"
551550

552551
# Extract types
553552
lmp_types = lmp.numpy.extract_atom_iarray(name="type", nelem=num_atoms).flatten()
@@ -569,16 +568,14 @@ def _extract_computes_snap(
569568

570569
lmp_dbarr = _extract_compute_np(lmp, "db", 1, 2, (num_atoms, num_types, 3, n_coeff))
571570
lmp_dbsum = _extract_compute_np(lmp, "db_sum", 0, 1, (num_types, 3, n_coeff))
572-
assert np.allclose(lmp_dbsum, lmp_dbarr.sum(axis=0), rtol=1e-12, atol=1e-12), (
573-
"db_sum doesn't match sum of db"
574-
)
571+
cond = np.allclose(lmp_dbsum, lmp_dbarr.sum(axis=0), rtol=1e-12, atol=1e-12)
572+
assert cond, "db_sum doesn't match sum of db"
575573
db_atom = np.transpose(lmp_dbarr, (0, 2, 1, 3))
576574

577575
lmp_vbarr = _extract_compute_np(lmp, "vb", 1, 2, (num_atoms, num_types, 6, n_coeff))
578576
lmp_vbsum = _extract_compute_np(lmp, "vb_sum", 0, 1, (num_types, 6, n_coeff))
579-
assert np.allclose(lmp_vbsum, lmp_vbarr.sum(axis=0), rtol=1e-12, atol=1e-12), (
580-
"vb_sum doesn't match sum of vb"
581-
)
577+
cond = np.allclose(lmp_vbsum, lmp_vbarr.sum(axis=0), rtol=1e-12, atol=1e-12)
578+
assert cond, "vb_sum doesn't match sum of vb"
582579
vb_sum = np.transpose(lmp_vbsum, (1, 0, 2)) / lmp_volume * eV_div_A3_to_bar
583580

584581
dbatom_shape = db_atom.shape

0 commit comments

Comments
 (0)