Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#307)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.9.1](astral-sh/ruff-pre-commit@v0.8.6...v0.9.1)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Format black

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update snap.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: pyiron-runner <[email protected]>
Co-authored-by: Jan Janssen <[email protected]>
  • Loading branch information
3 people authored Jan 14, 2025
1 parent 0cc06ab commit 9ddcbbf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.1
hooks:
- id: ruff
name: ruff lint
Expand Down
15 changes: 6 additions & 9 deletions structuretoolkit/analyse/snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,8 @@ def _extract_computes_snap(
np.ndarray: Output of the LAMMPS compute command
"""
lmp_atom_ids = lmp.numpy.extract_atom_iarray("id", num_atoms).flatten()
assert np.all(
lmp_atom_ids == 1 + np.arange(num_atoms)
), "LAMMPS seems to have lost atoms"
cond = np.all(lmp_atom_ids == 1 + np.arange(num_atoms))
assert cond, "LAMMPS seems to have lost atoms"

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

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

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

dbatom_shape = db_atom.shape
Expand Down
3 changes: 1 addition & 2 deletions structuretoolkit/build/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def create_mesh(
n_mesh = np.rint(np.linalg.norm(cell, axis=-1) / density).astype(int)
elif density is not None:
raise MeshInputError(
"You cannot set n_mesh at density at the same time. Set one of"
" them to None"
"You cannot set n_mesh at density at the same time. Set one of them to None"
)
n_mesh = np.atleast_1d(n_mesh).astype(int)
if len(n_mesh) == 1:
Expand Down
2 changes: 1 addition & 1 deletion structuretoolkit/build/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ def generate(group):
structures.append({"atoms": s, "symmetry": g, "repeat": i})
if len(failed_groups) > 0:
warnings.warn(
f'Groups [{", ".join(map(str,failed_groups))}] could not be generated with stoichiometry {stoich}!'
f"Groups [{', '.join(map(str, failed_groups))}] could not be generated with stoichiometry {stoich}!"
)
return structures

0 comments on commit 9ddcbbf

Please sign in to comment.