Skip to content

[pre-commit.ci] pre-commit autoupdate #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading