From 3c9b207dec02bf8c342009bc4ea6e357167399dc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 21:11:54 +0000 Subject: [PATCH 1/5] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.9.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.6...v0.9.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 648c3acc2..c6b69de9d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 From bcd19e6a873ecd64dc1fa938bf1f37684eeca366 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 21:12:15 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- structuretoolkit/analyse/snap.py | 18 +++++++++--------- structuretoolkit/build/mesh.py | 3 +-- structuretoolkit/build/random.py | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/structuretoolkit/analyse/snap.py b/structuretoolkit/analyse/snap.py index 0259346f3..69479ac2b 100644 --- a/structuretoolkit/analyse/snap.py +++ b/structuretoolkit/analyse/snap.py @@ -545,9 +545,9 @@ 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" + assert np.all(lmp_atom_ids == 1 + np.arange(num_atoms)), ( + "LAMMPS seems to have lost atoms" + ) # Extract types lmp_types = lmp.numpy.extract_atom_iarray(name="type", nelem=num_atoms).flatten() @@ -569,16 +569,16 @@ 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" + assert np.allclose(lmp_dbsum, lmp_dbarr.sum(axis=0), rtol=1e-12, atol=1e-12), ( + "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" + assert np.allclose(lmp_vbsum, lmp_vbarr.sum(axis=0), rtol=1e-12, atol=1e-12), ( + "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 diff --git a/structuretoolkit/build/mesh.py b/structuretoolkit/build/mesh.py index 0a6d72269..387ee5f0f 100644 --- a/structuretoolkit/build/mesh.py +++ b/structuretoolkit/build/mesh.py @@ -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: diff --git a/structuretoolkit/build/random.py b/structuretoolkit/build/random.py index 8ac0a2d88..71e474801 100644 --- a/structuretoolkit/build/random.py +++ b/structuretoolkit/build/random.py @@ -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 From 2a610ad960f638ae7273c9f706d38dcb423d4788 Mon Sep 17 00:00:00 2001 From: pyiron-runner Date: Tue, 14 Jan 2025 05:51:07 +0000 Subject: [PATCH 3/5] Format black --- structuretoolkit/analyse/snap.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/structuretoolkit/analyse/snap.py b/structuretoolkit/analyse/snap.py index 69479ac2b..0259346f3 100644 --- a/structuretoolkit/analyse/snap.py +++ b/structuretoolkit/analyse/snap.py @@ -545,9 +545,9 @@ 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" - ) + assert np.all( + lmp_atom_ids == 1 + np.arange(num_atoms) + ), "LAMMPS seems to have lost atoms" # Extract types lmp_types = lmp.numpy.extract_atom_iarray(name="type", nelem=num_atoms).flatten() @@ -569,16 +569,16 @@ 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" - ) + assert np.allclose( + lmp_dbsum, lmp_dbarr.sum(axis=0), rtol=1e-12, atol=1e-12 + ), "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" - ) + assert np.allclose( + lmp_vbsum, lmp_vbarr.sum(axis=0), rtol=1e-12, atol=1e-12 + ), "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 From f1f9c0af45a4c0269738ab11cdd0003ea2d373ba Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 05:52:15 +0000 Subject: [PATCH 4/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- structuretoolkit/analyse/snap.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/structuretoolkit/analyse/snap.py b/structuretoolkit/analyse/snap.py index 0259346f3..69479ac2b 100644 --- a/structuretoolkit/analyse/snap.py +++ b/structuretoolkit/analyse/snap.py @@ -545,9 +545,9 @@ 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" + assert np.all(lmp_atom_ids == 1 + np.arange(num_atoms)), ( + "LAMMPS seems to have lost atoms" + ) # Extract types lmp_types = lmp.numpy.extract_atom_iarray(name="type", nelem=num_atoms).flatten() @@ -569,16 +569,16 @@ 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" + assert np.allclose(lmp_dbsum, lmp_dbarr.sum(axis=0), rtol=1e-12, atol=1e-12), ( + "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" + assert np.allclose(lmp_vbsum, lmp_vbarr.sum(axis=0), rtol=1e-12, atol=1e-12), ( + "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 From 1af6aef9820b48f91e9c6bfafc8ffb795da34aa8 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Tue, 14 Jan 2025 07:02:09 +0100 Subject: [PATCH 5/5] Update snap.py --- structuretoolkit/analyse/snap.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/structuretoolkit/analyse/snap.py b/structuretoolkit/analyse/snap.py index 69479ac2b..9c8e984fa 100644 --- a/structuretoolkit/analyse/snap.py +++ b/structuretoolkit/analyse/snap.py @@ -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() @@ -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