diff --git a/tests/test_api.py b/tests/test_api.py index aead563a..a480e08f 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python3 # noqa: INP001, EXE001 - """Tests for the application programming interface (API).""" +from __future__ import annotations + import numpy as np import pytest @@ -10,7 +10,8 @@ from overreact import coords -def test_get_enthalpies(): # noqa: D103 +def test_get_enthalpies() -> None: + """Ensure we can retrieve enthalpies.""" model = rx.parse_model("data/hickel1992/UM06-2X/6-311++G(d,p)/model.k") assert rx.get_delta( model.scheme.B, @@ -21,7 +22,7 @@ def test_get_enthalpies(): # noqa: D103 ) -def test_get_entropies(): +def test_get_entropies() -> None: """Ensure get_entropies match some logfiles. It is worth mentioning that, currently, ORCA uses QRRHO in entropy @@ -58,7 +59,8 @@ def test_get_entropies(): ) -def test_get_freeenergies(): # noqa: D103 +def test_get_freeenergies() -> None: + """Ensure we can retrieve free energies.""" model = rx.parse_model("data/hickel1992/UM06-2X/6-311++G(d,p)/model.k") sym_correction = 298.15 * rx.change_reference_state(3, 1) @@ -74,7 +76,7 @@ def test_get_freeenergies(): # noqa: D103 ) -def test_compare_calc_star_with_get_star(): +def test_compare_calc_star_with_get_star() -> None: """Ensure the calc_* functions match the get_* functions.""" model = rx.parse_model("data/hickel1992/UM06-2X/6-311++G(d,p)/model.k") sym_correction = 298.15 * rx.change_reference_state(3, 1) @@ -99,7 +101,7 @@ def test_compare_calc_star_with_get_star(): for bias in np.array([-1, 0, 1]) * constants.kcal: for environment in ["gas", "solvent"]: for qrrho in [True, False, (False, True)]: - qrrho_enthalpy, qrrho_entropy = rx.api._check_qrrho( # noqa: SLF001 + qrrho_enthalpy, qrrho_entropy = rx.api._check_qrrho( qrrho, ) for temperature in [200, 298.15, 400]: @@ -166,7 +168,7 @@ def test_compare_calc_star_with_get_star(): bias == 0 and environment == "gas" and qrrho == (False, True) - and temperature == 298.15 # noqa: PLR2004 + and temperature == 298.15 and pressure == constants.atm # TODO(schneiderfelipe): do a test for H+(w) and compound != "H+(w)" diff --git a/tests/test_cli.py b/tests/test_cli.py index 2ed4449a..5c3ef64c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,32 +1,32 @@ -#!/usr/bin/env python3 # noqa: INP001, EXE001 - """Tests for the command-line interface.""" +from __future__ import annotations + from overreact import _cli as cli -def test_cli_compiles_source_file(monkeypatch): +def test_cli_compiles_source_file(monkeypatch) -> None: """Ensure the command-line interface can compile a source file (`.k`).""" params = ["overreact", "--compile", "data/ethane/B97-3c/model.k"] monkeypatch.setattr("sys.argv", params) cli.main() -def test_cli_describes_source_file(monkeypatch): +def test_cli_describes_source_file(monkeypatch) -> None: """Ensure the command-line interface can describe a source file (`.k`).""" params = ["overreact", "data/ethane/B97-3c/model.k"] monkeypatch.setattr("sys.argv", params) cli.main() -def test_cli_describes_model_file(monkeypatch): +def test_cli_describes_model_file(monkeypatch) -> None: """Ensure the command-line interface can describe a model file (`.jk`).""" params = ["overreact", "data/ethane/B97-3c/model.jk"] monkeypatch.setattr("sys.argv", params) cli.main() -def test_cli_accepts_gaussian_logfiles(monkeypatch): +def test_cli_accepts_gaussian_logfiles(monkeypatch) -> None: """Ensure the command-line interface is OK with Gaussian logfiles.""" params = ["overreact", "data/acetate/Gaussian09/wB97XD/6-311++G**/model.k"] monkeypatch.setattr("sys.argv", params) diff --git a/tests/test_constants.py b/tests/test_constants.py index 5662a895..b6442b6b 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -1,14 +1,14 @@ -#!/usr/bin/env python3 # noqa: INP001, EXE001 - """Tests for constants module.""" +from __future__ import annotations + import pytest import overreact as rx from overreact import _constants as constants -def test_reference_raw_constants(): +def test_reference_raw_constants() -> None: """Ensure raw constants are close to values commonly used by the community. Reference values were taken from the ones used by Gaussian 16 @@ -28,7 +28,7 @@ def test_reference_raw_constants(): ) == pytest.approx(0.022710953) -def test_reference_conversion_factors(): +def test_reference_conversion_factors() -> None: """Ensure conversion factors are close to values commonly used by the community. Reference values were taken from the ones used by Gaussian 16 diff --git a/tests/test_coords.py b/tests/test_coords.py index 652eab5a..934b93a1 100644 --- a/tests/test_coords.py +++ b/tests/test_coords.py @@ -1,7 +1,8 @@ -#!/usr/bin/env python3 # noqa: INP001, EXE001 - """Tests for module coords.""" + +from __future__ import annotations + import numpy as np import pytest @@ -10,26 +11,26 @@ # TODO(schneiderfelipe): add one extra atom -def test_can_understand_K_symmetry(): # noqa: N802 +def test_can_understand_k_symmetry() -> None: """Ensure values match regression logfiles for K symmetry.""" data = datasets.logfiles["tanaka1996"]["Cl·@UMP2/6-311G(2df,2pd)"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([0.0, 0.0, 0.0]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 1 assert len(groups[0]) == 1 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("spheric", "atomic") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 0 - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -37,7 +38,7 @@ def test_can_understand_K_symmetry(): # noqa: N802 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -45,36 +46,36 @@ def test_can_understand_K_symmetry(): # noqa: N802 proper_axes, ) assert len(mirror_axes) == 0 - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "K" assert coords.symmetry_number(point_group) == 1 -def test_can_understand_C1_symmetry(): # noqa: N802 +def test_can_understand_c1_symmetry() -> None: """Ensure values match regression logfiles for C1 symmetry.""" data = datasets.logfiles["symmetries"]["chlorobromofluoromethane"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([81.70347257, 264.62028172, 335.60557643]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 5 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 5 assert len(groups[0]) == 1 assert len(groups[1]) == 1 assert len(groups[2]) == 1 assert len(groups[3]) == 1 assert len(groups[4]) == 1 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 0 - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -82,7 +83,7 @@ def test_can_understand_C1_symmetry(): # noqa: N802 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -90,34 +91,34 @@ def test_can_understand_C1_symmetry(): # noqa: N802 proper_axes, ) assert len(mirror_axes) == 0 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C1" assert coords.symmetry_number(point_group) == 1 -def test_can_understand_Cs_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_cs_symmetry() -> None: """Ensure values match regression logfiles for Cs symmetry.""" data = datasets.logfiles["symmetries"]["NHF2"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([9.58233074, 49.04289888, 56.82386749]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 assert len(groups[1]) == 1 - assert len(groups[2]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[2]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 0 - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -125,7 +126,7 @@ def test_can_understand_Cs_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -133,9 +134,9 @@ def test_can_understand_Cs_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(mirror_axes) == 1 - assert mirror_axes[0][0] == "" # noqa: PLC1901 + assert mirror_axes[0][0] == "" assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "Cs" assert coords.symmetry_number(point_group) == 1 @@ -144,22 +145,22 @@ def test_can_understand_Cs_symmetry(): # noqa: N802, PLR0915 moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([17.61945078, 253.37069181, 267.61052366]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 4 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 4 assert len(groups[0]) == 1 assert len(groups[1]) == 1 assert len(groups[2]) == 1 - assert len(groups[3]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[3]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 0 - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -167,7 +168,7 @@ def test_can_understand_Cs_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -175,8 +176,8 @@ def test_can_understand_Cs_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(mirror_axes) == 1 - assert mirror_axes[0][0] == "" # noqa: PLC1901 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert mirror_axes[0][0] == "" + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "Cs" assert coords.symmetry_number(point_group) == 1 @@ -186,22 +187,22 @@ def test_can_understand_Cs_symmetry(): # noqa: N802, PLR0915 assert moments == pytest.approx([18.69862033, 334.44171615, 349.75324294]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 4 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 4 assert len(groups[0]) == 1 assert len(groups[1]) == 1 assert len(groups[2]) == 1 - assert len(groups[3]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[3]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 0 - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -209,7 +210,7 @@ def test_can_understand_Cs_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -217,36 +218,36 @@ def test_can_understand_Cs_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(mirror_axes) == 1 - assert mirror_axes[0][0] == "" # noqa: PLC1901 + assert mirror_axes[0][0] == "" assert mirror_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "Cs" assert coords.symmetry_number(point_group) == 1 -def test_can_understand_Ci_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_ci_symmetry() -> None: """Ensure values match regression logfiles for Ci symmetry.""" data = datasets.logfiles["symmetries"]["1,2-dichloro-1,2-difluoroethane"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([130.04075032, 358.98131538, 473.66138286]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 4 # noqa: PLR2004 - assert len(groups[0]) == 2 # noqa: PLR2004 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 2 # noqa: PLR2004 - assert len(groups[3]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 4 + assert len(groups[0]) == 2 + assert len(groups[1]) == 2 + assert len(groups[2]) == 2 + assert len(groups[3]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 0 - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -254,7 +255,7 @@ def test_can_understand_Ci_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -262,7 +263,7 @@ def test_can_understand_Ci_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(mirror_axes) == 0 - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "Ci" assert coords.symmetry_number(point_group) == 1 @@ -272,26 +273,26 @@ def test_can_understand_Ci_symmetry(): # noqa: N802, PLR0915 assert moments == pytest.approx([213.53202466, 543.08552098, 732.14870909]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 8 # noqa: PLR2004 - assert len(groups[0]) == 2 # noqa: PLR2004 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 2 # noqa: PLR2004 - assert len(groups[3]) == 2 # noqa: PLR2004 - assert len(groups[4]) == 2 # noqa: PLR2004 - assert len(groups[5]) == 2 # noqa: PLR2004 - assert len(groups[6]) == 2 # noqa: PLR2004 - assert len(groups[7]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 8 + assert len(groups[0]) == 2 + assert len(groups[1]) == 2 + assert len(groups[2]) == 2 + assert len(groups[3]) == 2 + assert len(groups[4]) == 2 + assert len(groups[5]) == 2 + assert len(groups[6]) == 2 + assert len(groups[7]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 0 - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -299,7 +300,7 @@ def test_can_understand_Ci_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -307,33 +308,33 @@ def test_can_understand_Ci_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(mirror_axes) == 0 - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "Ci" assert coords.symmetry_number(point_group) == 1 -def test_can_understand_Cinfv_symmetry(): # noqa: N802 +def test_can_understand_cinfv_symmetry() -> None: """Ensure values match regression logfiles for C∞v symmetry.""" data = datasets.logfiles["tanaka1996"]["HCl@UMP2/6-311G(2df,2pd)"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([0.0, 1.58676025, 1.58676025], 5e-3) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 assert len(groups[0]) == 1 assert len(groups[1]) == 1 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "linear") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 0 - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -341,7 +342,7 @@ def test_can_understand_Cinfv_symmetry(): # noqa: N802 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -349,7 +350,7 @@ def test_can_understand_Cinfv_symmetry(): # noqa: N802 proper_axes, ) assert len(mirror_axes) == 0 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C∞v" assert coords.symmetry_number(point_group) == 1 @@ -358,21 +359,21 @@ def test_can_understand_Cinfv_symmetry(): # noqa: N802 moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([1.17654558e-8, 8.53818341e1, 8.53818341e1]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 assert len(groups[1]) == 1 assert len(groups[2]) == 1 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "linear") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 0 - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -380,7 +381,7 @@ def test_can_understand_Cinfv_symmetry(): # noqa: N802 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -388,13 +389,13 @@ def test_can_understand_Cinfv_symmetry(): # noqa: N802 proper_axes, ) assert len(mirror_axes) == 0 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C∞v" assert coords.symmetry_number(point_group) == 1 -def test_can_understand_Dinfh_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_dinfh_symmetry() -> None: """Ensure values match regression logfiles for D∞h symmetry.""" data = datasets.logfiles["symmetries"]["dihydrogen"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -403,20 +404,20 @@ def test_can_understand_Dinfh_symmetry(): # noqa: N802, PLR0915 assert atomcoords == pytest.approx( np.array([[3.83307188e-1, 0.0, 0.0], [-3.83307188e-1, 0.0, 0.0]]), ) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 1 - assert len(groups[0]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[0]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "linear") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 - improper_axes = coords._get_improper_axes( # noqa: SLF001 + assert proper_axes[0][0] == 2 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -424,9 +425,9 @@ def test_can_understand_Dinfh_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 4 # noqa: PLR2004 + assert improper_axes[0][0] == 4 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -435,31 +436,31 @@ def test_can_understand_Dinfh_symmetry(): # noqa: N802, PLR0915 ) assert len(mirror_axes) == 1 assert mirror_axes[0][0] == "h" - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D∞h" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 data = datasets.logfiles["symmetries"]["carbon-dioxide"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([8.94742236e-8, 4.44644189e1, 4.44644190e1]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 assert len(groups[0]) == 1 - assert len(groups[1]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "linear") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 + assert proper_axes[0][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -467,9 +468,9 @@ def test_can_understand_Dinfh_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 4 # noqa: PLR2004 + assert improper_axes[0][0] == 4 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -479,33 +480,33 @@ def test_can_understand_Dinfh_symmetry(): # noqa: N802, PLR0915 assert len(mirror_axes) == 1 assert mirror_axes[0][0] == "h" assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D∞h" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 -def test_can_understand_C2_symmetry(): # noqa: N802 +def test_can_understand_c2_symmetry() -> None: """Ensure values match regression logfiles for C2 symmetry.""" data = datasets.logfiles["symmetries"]["hydrogen-peroxide"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([1.74210646, 19.61466369, 20.420849]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 - assert len(groups[0]) == 2 # noqa: PLR2004 - assert len(groups[1]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 + assert len(groups[0]) == 2 + assert len(groups[1]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 - improper_axes = coords._get_improper_axes( # noqa: SLF001 + assert proper_axes[0][0] == 2 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -513,7 +514,7 @@ def test_can_understand_C2_symmetry(): # noqa: N802 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -521,34 +522,34 @@ def test_can_understand_C2_symmetry(): # noqa: N802 proper_axes, ) assert len(mirror_axes) == 0 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C2" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 data = datasets.logfiles["symmetries"]["hydrazine"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([3.48031691, 20.67234093, 20.67777505]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 - assert len(groups[0]) == 2 # noqa: PLR2004 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 + assert len(groups[0]) == 2 + assert len(groups[1]) == 2 + assert len(groups[2]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 + assert proper_axes[0][0] == 2 assert proper_axes[0][1] == pytest.approx( [-6.265379700455943e-5, 0.0388451244158036, -0.9992452413615102], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -556,7 +557,7 @@ def test_can_understand_C2_symmetry(): # noqa: N802 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -564,36 +565,36 @@ def test_can_understand_C2_symmetry(): # noqa: N802 proper_axes, ) assert len(mirror_axes) == 0 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C2" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 -def test_can_understand_C3_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_c3_symmetry() -> None: """Ensure values match regression logfiles for C3 symmetry.""" data = datasets.logfiles["symmetries"]["H3PO4"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([117.15458225, 119.69622329, 119.71729381]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 4 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 4 assert len(groups[0]) == 1 assert len(groups[1]) == 1 - assert len(groups[2]) == 3 # noqa: PLR2004 - assert len(groups[3]) == 3 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[2]) == 3 + assert len(groups[3]) == 3 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 3 # noqa: PLR2004 + assert proper_axes[0][0] == 3 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -601,7 +602,7 @@ def test_can_understand_C3_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -609,10 +610,10 @@ def test_can_understand_C3_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(mirror_axes) == 0 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C3" - assert coords.symmetry_number(point_group) == 3 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 3 data = datasets.logfiles["symmetries"]["triphenylphosphine"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -627,32 +628,32 @@ def test_can_understand_C3_symmetry(): # noqa: N802, PLR0915 ], ), ) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 12 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 12 assert len(groups[0]) == 1 - assert len(groups[1]) == 3 # noqa: PLR2004 - assert len(groups[3]) == 3 # noqa: PLR2004 - assert len(groups[3]) == 3 # noqa: PLR2004 - assert len(groups[4]) == 3 # noqa: PLR2004 - assert len(groups[5]) == 3 # noqa: PLR2004 - assert len(groups[6]) == 3 # noqa: PLR2004 - assert len(groups[7]) == 3 # noqa: PLR2004 - assert len(groups[8]) == 3 # noqa: PLR2004 - assert len(groups[9]) == 3 # noqa: PLR2004 - assert len(groups[10]) == 3 # noqa: PLR2004 - assert len(groups[11]) == 3 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 3 + assert len(groups[3]) == 3 + assert len(groups[3]) == 3 + assert len(groups[4]) == 3 + assert len(groups[5]) == 3 + assert len(groups[6]) == 3 + assert len(groups[7]) == 3 + assert len(groups[8]) == 3 + assert len(groups[9]) == 3 + assert len(groups[10]) == 3 + assert len(groups[11]) == 3 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 3 # noqa: PLR2004 + assert proper_axes[0][0] == 3 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -660,7 +661,7 @@ def test_can_understand_C3_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -668,34 +669,34 @@ def test_can_understand_C3_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(mirror_axes) == 0 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C3" - assert coords.symmetry_number(point_group) == 3 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 3 -def test_can_understand_C2h_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_c2h_symmetry() -> None: """Ensure values match regression logfiles for C2h symmetry.""" data = datasets.logfiles["symmetries"]["trans-1,2-dichloroethylene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([9.8190931, 342.02181465, 351.84090775]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 - assert len(groups[0]) == 2 # noqa: PLR2004 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 + assert len(groups[0]) == 2 + assert len(groups[1]) == 2 + assert len(groups[2]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "irregular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 - improper_axes = coords._get_improper_axes( # noqa: SLF001 + assert proper_axes[0][0] == 2 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -703,9 +704,9 @@ def test_can_understand_C2h_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 2 # noqa: PLR2004 + assert improper_axes[0][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -714,10 +715,10 @@ def test_can_understand_C2h_symmetry(): # noqa: N802, PLR0915 ) assert len(mirror_axes) == 1 assert mirror_axes[0][0] == "h" - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C2h" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 data = datasets.logfiles["symmetries"]["transplatin"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -726,24 +727,24 @@ def test_can_understand_C2h_symmetry(): # noqa: N802, PLR0915 assert axes == pytest.approx( np.array([[1.0, 0.0, 0.0], [0.0, -1.0, 0.0], [0.0, 0.0, -1.0]]), ) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 4 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 4 assert len(groups[0]) == 1 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 2 # noqa: PLR2004 - assert len(groups[3]) == 6 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 2 + assert len(groups[2]) == 2 + assert len(groups[3]) == 6 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 + assert proper_axes[0][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, -1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -751,9 +752,9 @@ def test_can_understand_C2h_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 2 # noqa: PLR2004 + assert improper_axes[0][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -763,39 +764,39 @@ def test_can_understand_C2h_symmetry(): # noqa: N802, PLR0915 assert len(mirror_axes) == 1 assert mirror_axes[0][0] == "h" assert mirror_axes[0][1] == pytest.approx([0.0, 0.0, -1.0]) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) # TODO(schneiderfelipe): people say this should be D2h, but it is # impossible if we consider hydrogen atoms: add an option to # find_point_group that ignores hydrogen atoms. assert point_group == "C2h" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 -def test_can_understand_C3h_symmetry(): # noqa: N802 +def test_can_understand_c3h_symmetry() -> None: """Ensure values match regression logfiles for C3h symmetry.""" data = datasets.logfiles["symmetries"]["boric-acid"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([52.01309348, 52.01530317, 104.02839606]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3), abs=1e-6) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 - assert len(groups[1]) == 3 # noqa: PLR2004 - assert len(groups[2]) == 3 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 3 + assert len(groups[2]) == 3 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "regular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 3 # noqa: PLR2004 + assert proper_axes[0][0] == 3 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -803,9 +804,9 @@ def test_can_understand_C3h_symmetry(): # noqa: N802 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 3 # noqa: PLR2004 + assert improper_axes[0][0] == 3 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -815,35 +816,35 @@ def test_can_understand_C3h_symmetry(): # noqa: N802 assert len(mirror_axes) == 1 assert mirror_axes[0][0] == "h" assert mirror_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C3h" - assert coords.symmetry_number(point_group) == 3 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 3 -def test_can_understand_C2v_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_c2v_symmetry() -> None: """Ensure values match regression logfiles for C2v symmetry.""" data = datasets.logfiles["symmetries"]["water"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([0.6768072475, 1.1582103375, 1.835017585]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 assert len(groups[0]) == 1 - assert len(groups[1]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "irregular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 + assert proper_axes[0][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 1.0, 0.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -851,45 +852,45 @@ def test_can_understand_C2v_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 2 # noqa: PLR2004 + assert len(mirror_axes) == 2 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert mirror_axes[1][1] == pytest.approx([0.0, 0.0, 1.0]) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C2v" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 data = datasets.logfiles["symmetries"]["SF4"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([81.52806583, 133.34202281, 167.8488049]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 2 + assert len(groups[2]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 + assert proper_axes[0][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -897,49 +898,49 @@ def test_can_understand_C2v_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 2 # noqa: PLR2004 + assert len(mirror_axes) == 2 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert mirror_axes[1][1] == pytest.approx([0.0, 1.0, 0.0]) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C2v" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 data = datasets.logfiles["symmetries"]["cyclohexane-boat"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([119.38090371, 123.2008681, 206.20634797]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 5 # noqa: PLR2004 - assert len(groups[0]) == 2 # noqa: PLR2004 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 4 # noqa: PLR2004 - assert len(groups[3]) == 4 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 5 + assert len(groups[0]) == 2 + assert len(groups[1]) == 2 + assert len(groups[2]) == 4 + assert len(groups[3]) == 4 # TODO(schneiderfelipe): I believe the following group should be split into # two groups, one of 2 atoms and one of 4 atoms: - assert len(groups[4]) == 6 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[4]) == 6 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 + assert proper_axes[0][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -947,14 +948,14 @@ def test_can_understand_C2v_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 2 # noqa: PLR2004 + assert len(mirror_axes) == 2 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[0][1] == pytest.approx( @@ -963,35 +964,35 @@ def test_can_understand_C2v_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[1][1] == pytest.approx( [-0.999999999999952, 3.098747565480977e-7, 3.719778376187453e-9], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C2v" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 data = datasets.logfiles["symmetries"]["cisplatin"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([231.33596051, 300.06695463, 525.9371719]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 5 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 5 assert len(groups[0]) == 1 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 2 # noqa: PLR2004 - assert len(groups[3]) == 2 # noqa: PLR2004 - assert len(groups[4]) == 4 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 2 + assert len(groups[2]) == 2 + assert len(groups[3]) == 2 + assert len(groups[4]) == 4 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 + assert proper_axes[0][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 1.0, 0.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -999,48 +1000,48 @@ def test_can_understand_C2v_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 2 # noqa: PLR2004 + assert len(mirror_axes) == 2 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert mirror_axes[1][1] == pytest.approx([0.0, 0.0, 1.0]) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C2v" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 data = datasets.logfiles["symmetries"]["1,2-dichlorobenzene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([266.78313761, 355.80034163, 622.58347924]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 6 # noqa: PLR2004 - assert len(groups[0]) == 2 # noqa: PLR2004 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 2 # noqa: PLR2004 - assert len(groups[3]) == 2 # noqa: PLR2004 - assert len(groups[4]) == 2 # noqa: PLR2004 - assert len(groups[5]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 6 + assert len(groups[0]) == 2 + assert len(groups[1]) == 2 + assert len(groups[2]) == 2 + assert len(groups[3]) == 2 + assert len(groups[4]) == 2 + assert len(groups[5]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "irregular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 + assert proper_axes[0][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -1048,53 +1049,53 @@ def test_can_understand_C2v_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 2 # noqa: PLR2004 + assert len(mirror_axes) == 2 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[0][1] == pytest.approx([0.0, 1.0, 0.0]) assert mirror_axes[1][1] == pytest.approx([0.0, 0.0, 1.0]) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C2v" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 data = datasets.logfiles["symmetries"]["1,3-dichlorobenzene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([179.02244122, 596.70030705, 775.72274827]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 5 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 5 assert len(groups[0]) == 1 - assert len(groups[1]) == 2 # noqa: PLR2004 + assert len(groups[1]) == 2 # TODO(schneiderfelipe): I believe the following should be two groups, one # of two atoms, one of one atom each - assert len(groups[2]) == 3 # noqa: PLR2004 + assert len(groups[2]) == 3 # TODO(schneiderfelipe): I believe the following should be two groups, one # of two atoms, one of one atom each - assert len(groups[3]) == 3 # noqa: PLR2004 + assert len(groups[3]) == 3 # TODO(schneiderfelipe): I believe the following should be two groups, one # of two atoms, one of one atom each - assert len(groups[4]) == 3 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[4]) == 3 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "irregular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 + assert proper_axes[0][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 1.0, 0.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -1102,50 +1103,50 @@ def test_can_understand_C2v_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 2 # noqa: PLR2004 + assert len(mirror_axes) == 2 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert mirror_axes[1][1] == pytest.approx([0.0, 0.0, 1.0]) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C2v" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 data = datasets.logfiles["symmetries"]["tetracarbonyldicloro-OsII"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([785.21973892, 809.59902436, 817.20306192]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 6 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 6 assert len(groups[0]) == 1 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 2 # noqa: PLR2004 - assert len(groups[3]) == 2 # noqa: PLR2004 - assert len(groups[4]) == 2 # noqa: PLR2004 - assert len(groups[5]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 2 + assert len(groups[2]) == 2 + assert len(groups[3]) == 2 + assert len(groups[4]) == 2 + assert len(groups[5]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 + assert proper_axes[0][0] == 2 assert proper_axes[0][1] == pytest.approx( [0.001877205661635017, 0.011104681211935762, 0.9999365790659351], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -1153,48 +1154,48 @@ def test_can_understand_C2v_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 2 # noqa: PLR2004 + assert len(mirror_axes) == 2 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert mirror_axes[1][1] == pytest.approx( [-0.009273225981885458, 0.9999054852612625, -0.010150262278787719], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C2v" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 -def test_can_understand_C3v_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_c3v_symmetry() -> None: """Ensure values match regression logfiles for C3v symmetry.""" data = datasets.logfiles["symmetries"]["ammonia"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([1.70511527, 1.70683927, 2.6588982]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 assert len(groups[0]) == 1 - assert len(groups[1]) == 3 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 3 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 3 # noqa: PLR2004 + assert proper_axes[0][0] == 3 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -1202,14 +1203,14 @@ def test_can_understand_C3v_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 3 # noqa: PLR2004 + assert len(mirror_axes) == 3 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -1222,10 +1223,10 @@ def test_can_understand_C3v_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[2][1] == pytest.approx( [0.08831067425523016, 0.9960929548201968, -0.00022398695457168588], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C3v" - assert coords.symmetry_number(point_group) == 3 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 3 data = datasets.logfiles["symmetries"]["trichloromethane"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -1241,23 +1242,23 @@ def test_can_understand_C3v_symmetry(): # noqa: N802, PLR0915 ), abs=1e-6, ) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 assert len(groups[1]) == 1 - assert len(groups[2]) == 3 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[2]) == 3 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 3 # noqa: PLR2004 + assert proper_axes[0][0] == 3 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -1265,14 +1266,14 @@ def test_can_understand_C3v_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 3 # noqa: PLR2004 + assert len(mirror_axes) == 3 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -1285,31 +1286,31 @@ def test_can_understand_C3v_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[2][1] == pytest.approx( [-0.6664703153892539, 0.745531567878424, 1.298894105965732e-6], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C3v" - assert coords.symmetry_number(point_group) == 3 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 3 data = datasets.logfiles["symmetries"]["phosphorous-oxychloride"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([269.55650843, 269.5984722, 366.72364626]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 assert len(groups[1]) == 1 - assert len(groups[2]) == 3 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[2]) == 3 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 3 # noqa: PLR2004 - improper_axes = coords._get_improper_axes( # noqa: SLF001 + assert proper_axes[0][0] == 3 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -1317,14 +1318,14 @@ def test_can_understand_C3v_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 3 # noqa: PLR2004 + assert len(mirror_axes) == 3 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -1337,39 +1338,39 @@ def test_can_understand_C3v_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[2][1] == pytest.approx( [-0.4301018285979955, -0.902780371800905, 0.00013163464672069048], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C3v" - assert coords.symmetry_number(point_group) == 3 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 3 data = datasets.logfiles["symmetries"]["benzenetricarbonylchromium"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([532.79651409, 683.7802014, 684.19947951]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 5 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 5 assert len(groups[0]) == 1 - assert len(groups[1]) == 3 # noqa: PLR2004 - assert len(groups[2]) == 3 # noqa: PLR2004 + assert len(groups[1]) == 3 + assert len(groups[2]) == 3 # TODO(schneiderfelipe): I believe the following should be split into two # groups of three each - assert len(groups[3]) == 6 # noqa: PLR2004 + assert len(groups[3]) == 6 # TODO(schneiderfelipe): I believe the following should be split into two # groups of three each - assert len(groups[4]) == 6 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[4]) == 6 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 3 # noqa: PLR2004 + assert proper_axes[0][0] == 3 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -1377,14 +1378,14 @@ def test_can_understand_C3v_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 3 # noqa: PLR2004 + assert len(mirror_axes) == 3 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -1397,36 +1398,36 @@ def test_can_understand_C3v_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[2][1] == pytest.approx( [0.00035562884006787933, -0.9888277564519781, 0.14906220714277532], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C3v" - assert coords.symmetry_number(point_group) == 3 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 3 -def test_can_understand_C4v_symmetry(): # noqa: N802 +def test_can_understand_c4v_symmetry() -> None: """Ensure values match regression logfiles for C4v symmetry.""" data = datasets.logfiles["symmetries"]["OF4Xe"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([198.56886522, 198.66454795, 298.68512748]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 assert len(groups[1]) == 1 - assert len(groups[2]) == 4 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[2]) == 4 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 4 # noqa: PLR2004 + assert proper_axes[0][0] == 4 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -1434,49 +1435,49 @@ def test_can_understand_C4v_symmetry(): # noqa: N802 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 4 # noqa: PLR2004 + assert len(mirror_axes) == 4 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" assert mirror_axes[3][0] == "v" - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C4v" - assert coords.symmetry_number(point_group) == 4 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 4 -def test_can_understand_C5v_symmetry(): # noqa: N802 +def test_can_understand_c5v_symmetry() -> None: """Ensure values match regression logfiles for C5v symmetry.""" data = datasets.logfiles["symmetries"]["corannulene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([1010.15093506, 1010.21973269, 1945.45456697]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 4 # noqa: PLR2004 - assert len(groups[0]) == 5 # noqa: PLR2004 - assert len(groups[1]) == 5 # noqa: PLR2004 - assert len(groups[2]) == 10 # noqa: PLR2004 - assert len(groups[3]) == 10 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 4 + assert len(groups[0]) == 5 + assert len(groups[1]) == 5 + assert len(groups[2]) == 10 + assert len(groups[3]) == 10 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 5 # noqa: PLR2004 + assert proper_axes[0][0] == 5 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -1484,14 +1485,14 @@ def test_can_understand_C5v_symmetry(): # noqa: N802 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 5 # noqa: PLR2004 + assert len(mirror_axes) == 5 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -1512,44 +1513,44 @@ def test_can_understand_C5v_symmetry(): # noqa: N802 assert mirror_axes[4][1] == pytest.approx( [-0.058396984482266025, 0.9982934340845996, 0.000108013679569529], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "C5v" - assert coords.symmetry_number(point_group) == 5 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 5 -def test_can_understand_D2_symmetry(): # noqa: N802 +def test_can_understand_d2_symmetry() -> None: """Ensure values match regression logfiles for D2 symmetry.""" data = datasets.logfiles["symmetries"]["biphenyl"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([180.57613675, 942.28140722, 1083.10838697]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 7 # noqa: PLR2004 - assert len(groups[0]) == 2 # noqa: PLR2004 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 2 # noqa: PLR2004 - assert len(groups[3]) == 4 # noqa: PLR2004 - assert len(groups[4]) == 4 # noqa: PLR2004 - assert len(groups[5]) == 4 # noqa: PLR2004 - assert len(groups[6]) == 4 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 7 + assert len(groups[0]) == 2 + assert len(groups[1]) == 2 + assert len(groups[2]) == 2 + assert len(groups[3]) == 4 + assert len(groups[4]) == 4 + assert len(groups[5]) == 4 + assert len(groups[6]) == 4 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 3 # noqa: PLR2004 - assert proper_axes[0][0] == 2 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 3 + assert proper_axes[0][0] == 2 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert proper_axes[1][1] == pytest.approx([0.0, 1.0, 0.0]) assert proper_axes[2][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -1557,7 +1558,7 @@ def test_can_understand_D2_symmetry(): # noqa: N802 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -1565,40 +1566,40 @@ def test_can_understand_D2_symmetry(): # noqa: N802 proper_axes, ) assert len(mirror_axes) == 0 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D2" - assert coords.symmetry_number(point_group) == 4 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 4 -def test_can_understand_D3_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_d3_symmetry() -> None: """Ensure values match regression logfiles for D3 symmetry.""" data = datasets.logfiles["symmetries"]["tris-ethylenediamine-RuII"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([716.90346743, 716.9163632, 1112.40527375]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 7 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 7 assert len(groups[0]) == 1 - assert len(groups[1]) == 6 # noqa: PLR2004 - assert len(groups[2]) == 6 # noqa: PLR2004 - assert len(groups[3]) == 6 # noqa: PLR2004 - assert len(groups[4]) == 6 # noqa: PLR2004 - assert len(groups[5]) == 6 # noqa: PLR2004 - assert len(groups[6]) == 6 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 6 + assert len(groups[2]) == 6 + assert len(groups[3]) == 6 + assert len(groups[4]) == 6 + assert len(groups[5]) == 6 + assert len(groups[6]) == 6 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 4 # noqa: PLR2004 - assert proper_axes[0][0] == 3 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 4 + assert proper_axes[0][0] == 3 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 assert proper_axes[1][1] == pytest.approx( [-0.007801928433068849, 0.999969564493194, -1.3114109559063874e-7], ) @@ -1608,7 +1609,7 @@ def test_can_understand_D3_symmetry(): # noqa: N802, PLR0915 assert proper_axes[3][1] == pytest.approx( [-0.8695351060281812, 0.49387058756810087, 0.0007362877823667492], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -1616,7 +1617,7 @@ def test_can_understand_D3_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -1624,38 +1625,38 @@ def test_can_understand_D3_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(mirror_axes) == 0 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D3" - assert coords.symmetry_number(point_group) == 6 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 6 data = datasets.logfiles["symmetries"]["tris-ethylenediamine-CoIII"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([661.90920375, 662.85444032, 1018.71597285]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 7 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 7 assert len(groups[0]) == 1 - assert len(groups[1]) == 6 # noqa: PLR2004 - assert len(groups[2]) == 6 # noqa: PLR2004 - assert len(groups[3]) == 6 # noqa: PLR2004 - assert len(groups[4]) == 6 # noqa: PLR2004 - assert len(groups[5]) == 6 # noqa: PLR2004 - assert len(groups[6]) == 6 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 6 + assert len(groups[2]) == 6 + assert len(groups[3]) == 6 + assert len(groups[4]) == 6 + assert len(groups[5]) == 6 + assert len(groups[6]) == 6 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 4 # noqa: PLR2004 - assert proper_axes[0][0] == 3 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 4 + assert proper_axes[0][0] == 3 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) assert proper_axes[1][1] == pytest.approx( [-8.396686394741882e-5, 0.9999999964747823, -3.439237791100686e-8], @@ -1666,7 +1667,7 @@ def test_can_understand_D3_symmetry(): # noqa: N802, PLR0915 assert proper_axes[3][1] == pytest.approx( [-0.8668052702358067, -0.49864677853044065, 0.00011727166713889237], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -1674,7 +1675,7 @@ def test_can_understand_D3_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -1682,13 +1683,13 @@ def test_can_understand_D3_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(mirror_axes) == 0 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D3" - assert coords.symmetry_number(point_group) == 6 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 6 -def test_can_understand_D5_symmetry(): # noqa: N802 +def test_can_understand_d5_symmetry() -> None: """Ensure values match regression logfiles for D5 symmetry.""" data = datasets.logfiles["symmetries"]["ferrocene-twisted"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -1704,26 +1705,26 @@ def test_can_understand_D5_symmetry(): # noqa: N802 ), abs=1e-6, ) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 - assert len(groups[1]) == 10 # noqa: PLR2004 - assert len(groups[2]) == 10 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 10 + assert len(groups[2]) == 10 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 6 # noqa: PLR2004 - assert proper_axes[0][0] == 5 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 - assert proper_axes[4][0] == 2 # noqa: PLR2004 - assert proper_axes[5][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 6 + assert proper_axes[0][0] == 5 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 + assert proper_axes[4][0] == 2 + assert proper_axes[5][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert proper_axes[1][1] == pytest.approx( [0.0, 0.309016595317643, 0.9510566459566391], @@ -1738,7 +1739,7 @@ def test_can_understand_D5_symmetry(): # noqa: N802 assert proper_axes[5][1] == pytest.approx( [0.0, 0.8090168500740541, -0.5877854509055626], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -1746,7 +1747,7 @@ def test_can_understand_D5_symmetry(): # noqa: N802 proper_axes, ) assert len(improper_axes) == 0 - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -1754,240 +1755,240 @@ def test_can_understand_D5_symmetry(): # noqa: N802 proper_axes, ) assert len(mirror_axes) == 0 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D5" - assert coords.symmetry_number(point_group) == 10 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 10 -def test_can_understand_D2h_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_d2h_symmetry() -> None: """Ensure values match regression logfiles for D2h symmetry.""" data = datasets.logfiles["symmetries"]["ethylene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([3.56497952, 17.24901988, 20.8139994]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 - assert len(groups[0]) == 2 # noqa: PLR2004 - assert len(groups[1]) == 4 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 + assert len(groups[0]) == 2 + assert len(groups[1]) == 4 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "irregular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 3 # noqa: PLR2004 - assert proper_axes[0][0] == 2 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 3 + assert proper_axes[0][0] == 2 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 3 # noqa: PLR2004 - assert improper_axes[0][0] == 2 # noqa: PLR2004 - assert improper_axes[1][0] == 2 # noqa: PLR2004 - assert improper_axes[2][0] == 2 # noqa: PLR2004 + assert len(improper_axes) == 3 + assert improper_axes[0][0] == 2 + assert improper_axes[1][0] == 2 + assert improper_axes[2][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] assert improper_axes[1][1] == proper_axes[1][1] assert improper_axes[2][1] == proper_axes[2][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 3 # noqa: PLR2004 + assert len(mirror_axes) == 3 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "h" assert mirror_axes[2][0] == "h" assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D2h" - assert coords.symmetry_number(point_group) == 4 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 4 data = datasets.logfiles["symmetries"]["diborane"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([6.26383693, 26.96388268, 29.40025824]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 - assert len(groups[0]) == 2 # noqa: PLR2004 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 4 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 + assert len(groups[0]) == 2 + assert len(groups[1]) == 2 + assert len(groups[2]) == 4 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 3 # noqa: PLR2004 - assert proper_axes[0][0] == 2 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 3 + assert proper_axes[0][0] == 2 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 3 # noqa: PLR2004 - assert improper_axes[0][0] == 2 # noqa: PLR2004 - assert improper_axes[1][0] == 2 # noqa: PLR2004 - assert improper_axes[2][0] == 2 # noqa: PLR2004 + assert len(improper_axes) == 3 + assert improper_axes[0][0] == 2 + assert improper_axes[1][0] == 2 + assert improper_axes[2][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] assert improper_axes[1][1] == proper_axes[1][1] assert improper_axes[2][1] == proper_axes[2][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 3 # noqa: PLR2004 + assert len(mirror_axes) == 3 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "h" assert mirror_axes[2][0] == "h" assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D2h" - assert coords.symmetry_number(point_group) == 4 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 4 data = datasets.logfiles["symmetries"]["1,4-dichlorobenzene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([88.31658644, 769.01913704, 857.3357217]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 - assert len(groups[0]) == 2 # noqa: PLR2004 - assert len(groups[1]) == 4 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 + assert len(groups[0]) == 2 + assert len(groups[1]) == 4 # TODO(schneiderfelipe): I believe this group below should optimally split # into 2 groups of 2 and 4 atoms each - assert len(groups[2]) == 6 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[2]) == 6 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "irregular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 3 # noqa: PLR2004 - assert proper_axes[0][0] == 2 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 3 + assert proper_axes[0][0] == 2 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert proper_axes[1][1] == pytest.approx([0.0, 1.0, 0.0]) assert proper_axes[2][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 3 # noqa: PLR2004 - assert improper_axes[0][0] == 2 # noqa: PLR2004 - assert improper_axes[1][0] == 2 # noqa: PLR2004 - assert improper_axes[2][0] == 2 # noqa: PLR2004 + assert len(improper_axes) == 3 + assert improper_axes[0][0] == 2 + assert improper_axes[1][0] == 2 + assert improper_axes[2][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] assert improper_axes[1][1] == proper_axes[1][1] assert improper_axes[2][1] == proper_axes[2][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 3 # noqa: PLR2004 + assert len(mirror_axes) == 3 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "h" assert mirror_axes[2][0] == "h" assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert mirror_axes[1][1] == pytest.approx([0.0, 1.0, 0.0]) assert mirror_axes[2][1] == pytest.approx([0.0, 0.0, 1.0]) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D2h" - assert coords.symmetry_number(point_group) == 4 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 4 data = datasets.logfiles["symmetries"]["Mn2F6"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([182.07906581, 784.89021644, 966.96922024]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 - assert len(groups[0]) == 2 # noqa: PLR2004 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 4 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 + assert len(groups[0]) == 2 + assert len(groups[1]) == 2 + assert len(groups[2]) == 4 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "irregular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 3 # noqa: PLR2004 - assert proper_axes[0][0] == 2 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 3 + assert proper_axes[0][0] == 2 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert proper_axes[1][1] == pytest.approx([0.0, 1.0, 0.0]) assert proper_axes[2][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 3 # noqa: PLR2004 - assert improper_axes[0][0] == 2 # noqa: PLR2004 - assert improper_axes[1][0] == 2 # noqa: PLR2004 - assert improper_axes[2][0] == 2 # noqa: PLR2004 + assert len(improper_axes) == 3 + assert improper_axes[0][0] == 2 + assert improper_axes[1][0] == 2 + assert improper_axes[2][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] assert improper_axes[1][1] == proper_axes[1][1] assert improper_axes[2][1] == proper_axes[2][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 3 # noqa: PLR2004 + assert len(mirror_axes) == 3 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "h" assert mirror_axes[2][0] == "h" assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert mirror_axes[1][1] == pytest.approx([0.0, 1.0, 0.0]) assert mirror_axes[2][1] == pytest.approx([0.0, 0.0, 1.0]) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D2h" - assert coords.symmetry_number(point_group) == 4 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 4 -def test_can_understand_D3h_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_d3h_symmetry() -> None: """Ensure values match regression logfiles for D3h symmetry.""" data = datasets.logfiles["ethane"]["eclipsed@B97-3c"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -2003,23 +2004,23 @@ def test_can_understand_D3h_symmetry(): # noqa: N802, PLR0915 ), abs=1e-6, ) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 - assert len(groups[0]) == 2 # noqa: PLR2004 - assert len(groups[1]) == 6 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 + assert len(groups[0]) == 2 + assert len(groups[1]) == 6 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 4 # noqa: PLR2004 - assert proper_axes[0][0] == 3 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 4 + assert proper_axes[0][0] == 3 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert proper_axes[1][1] == pytest.approx( [7.684797155608644e-5, -0.3613920169943295, 0.932413966083284], @@ -2030,7 +2031,7 @@ def test_can_understand_D3h_symmetry(): # noqa: N802, PLR0915 assert proper_axes[3][1] == pytest.approx( [-5.13760417702473e-5, 0.988178974905995, -0.15330463435343078], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -2038,16 +2039,16 @@ def test_can_understand_D3h_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 3 # noqa: PLR2004 + assert improper_axes[0][0] == 3 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 4 # noqa: PLR2004 + assert len(mirror_axes) == 4 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -2062,32 +2063,32 @@ def test_can_understand_D3h_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[3][1] == pytest.approx( [-8.738720232596221e-5, 0.9318966227508982, 0.36272396787219213], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D3h" - assert coords.symmetry_number(point_group) == 6 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 6 data = datasets.logfiles["symmetries"]["BF3"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([50.77255975, 50.7862414, 101.55880103]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 assert len(groups[0]) == 1 - assert len(groups[1]) == 3 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 3 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "regular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 4 # noqa: PLR2004 - assert proper_axes[0][0] == 3 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 4 + assert proper_axes[0][0] == 3 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 assert proper_axes[1][1] == pytest.approx( [0.786485610329844, -0.6176086014998113, 9.876227954894027e-6], ) @@ -2097,7 +2098,7 @@ def test_can_understand_D3h_symmetry(): # noqa: N802, PLR0915 assert proper_axes[3][1] == pytest.approx( [-0.9281566611554543, -0.37218975302286383, 9.876181775103538e-6], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -2105,16 +2106,16 @@ def test_can_understand_D3h_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 3 # noqa: PLR2004 + assert improper_axes[0][0] == 3 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 4 # noqa: PLR2004 + assert len(mirror_axes) == 4 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -2128,35 +2129,35 @@ def test_can_understand_D3h_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[3][1] == pytest.approx( [-0.9899127272168826, 0.14167848281949386, 1.4813107352227758e-10], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D3h" - assert coords.symmetry_number(point_group) == 6 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 6 data = datasets.logfiles["symmetries"]["PCl5"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([452.37354879, 558.48639882, 558.6442966]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 3 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 2 + assert len(groups[2]) == 3 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 4 # noqa: PLR2004 - assert proper_axes[0][0] == 3 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 4 + assert proper_axes[0][0] == 3 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -2164,16 +2165,16 @@ def test_can_understand_D3h_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 3 # noqa: PLR2004 + assert improper_axes[0][0] == 3 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 4 # noqa: PLR2004 + assert len(mirror_axes) == 4 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -2181,96 +2182,96 @@ def test_can_understand_D3h_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D3h" - assert coords.symmetry_number(point_group) == 6 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 6 -def test_can_understand_D4h_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_d4h_symmetry() -> None: """Ensure values match regression logfiles for D4h symmetry.""" data = datasets.logfiles["symmetries"]["XeF4"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([153.07544899, 153.15479772, 306.23024671]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 assert len(groups[0]) == 1 - assert len(groups[1]) == 4 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 4 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "regular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 5 # noqa: PLR2004 - assert proper_axes[0][0] == 4 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 - assert proper_axes[4][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 5 + assert proper_axes[0][0] == 4 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 + assert proper_axes[4][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 5 # noqa: PLR2004 - assert improper_axes[0][0] == 4 # noqa: PLR2004 - assert improper_axes[1][0] == 2 # noqa: PLR2004 - assert improper_axes[2][0] == 2 # noqa: PLR2004 - assert improper_axes[3][0] == 2 # noqa: PLR2004 - assert improper_axes[4][0] == 2 # noqa: PLR2004 + assert len(improper_axes) == 5 + assert improper_axes[0][0] == 4 + assert improper_axes[1][0] == 2 + assert improper_axes[2][0] == 2 + assert improper_axes[3][0] == 2 + assert improper_axes[4][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] assert improper_axes[1][1] == proper_axes[1][1] assert improper_axes[2][1] == proper_axes[2][1] assert improper_axes[3][1] == proper_axes[3][1] assert improper_axes[4][1] == proper_axes[4][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 5 # noqa: PLR2004 + assert len(mirror_axes) == 5 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" assert mirror_axes[3][0] == "v" assert mirror_axes[4][0] == "v" assert mirror_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D4h" - assert coords.symmetry_number(point_group) == 8 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 8 data = datasets.logfiles["symmetries"]["tetracarbonylnickel"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([385.29998789, 385.47071543, 770.77067351]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3), abs=1e-6) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 - assert len(groups[1]) == 4 # noqa: PLR2004 - assert len(groups[2]) == 4 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 4 + assert len(groups[2]) == 4 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "regular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 5 # noqa: PLR2004 - assert proper_axes[0][0] == 4 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 - assert proper_axes[4][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 5 + assert proper_axes[0][0] == 4 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 + assert proper_axes[4][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) assert proper_axes[1][1] == pytest.approx( [0.999999985120203, -0.00017250910677172902, -4.4908920788199634e-7], @@ -2284,32 +2285,32 @@ def test_can_understand_D4h_symmetry(): # noqa: N802, PLR0915 assert proper_axes[4][1] == pytest.approx( [-0.000153000029355287, -0.9999999882933196, -2.0860089700576687e-6], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 5 # noqa: PLR2004 - assert improper_axes[0][0] == 4 # noqa: PLR2004 - assert improper_axes[1][0] == 2 # noqa: PLR2004 - assert improper_axes[2][0] == 2 # noqa: PLR2004 - assert improper_axes[3][0] == 2 # noqa: PLR2004 - assert improper_axes[4][0] == 2 # noqa: PLR2004 + assert len(improper_axes) == 5 + assert improper_axes[0][0] == 4 + assert improper_axes[1][0] == 2 + assert improper_axes[2][0] == 2 + assert improper_axes[3][0] == 2 + assert improper_axes[4][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] assert improper_axes[1][1] == proper_axes[1][1] assert improper_axes[2][1] == proper_axes[2][1] assert improper_axes[3][1] == proper_axes[3][1] assert improper_axes[4][1] == proper_axes[4][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 5 # noqa: PLR2004 + assert len(mirror_axes) == 5 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -2328,13 +2329,13 @@ def test_can_understand_D4h_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[4][1] == pytest.approx( [0.0003752463460537577, 0.9999999166821465, 0.00016070432460672592], ) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D4h" - assert coords.symmetry_number(point_group) == 8 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 8 -def test_can_understand_D5h_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_d5h_symmetry() -> None: """Ensure values match regression logfiles for D5h symmetry.""" data = datasets.logfiles["symmetries"]["cyclopentadienyl-"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -2350,27 +2351,27 @@ def test_can_understand_D5h_symmetry(): # noqa: N802, PLR0915 ), abs=1e-6, ) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 - assert len(groups[0]) == 5 # noqa: PLR2004 - assert len(groups[1]) == 5 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 + assert len(groups[0]) == 5 + assert len(groups[1]) == 5 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "regular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 6 # noqa: PLR2004 - assert proper_axes[0][0] == 5 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 - assert proper_axes[4][0] == 2 # noqa: PLR2004 - assert proper_axes[5][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 6 + assert proper_axes[0][0] == 5 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 + assert proper_axes[4][0] == 2 + assert proper_axes[5][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -2378,16 +2379,16 @@ def test_can_understand_D5h_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 5 # noqa: PLR2004 + assert improper_axes[0][0] == 5 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 6 # noqa: PLR2004 + assert len(mirror_axes) == 6 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -2395,35 +2396,35 @@ def test_can_understand_D5h_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[4][0] == "v" assert mirror_axes[5][0] == "v" assert mirror_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D5h" - assert coords.symmetry_number(point_group) == 10 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 10 data = datasets.logfiles["symmetries"]["ferrocene-eclipsed"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([228.8186135, 480.633784, 480.63796274]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 - assert len(groups[1]) == 10 # noqa: PLR2004 - assert len(groups[2]) == 10 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 10 + assert len(groups[2]) == 10 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 6 # noqa: PLR2004 - assert proper_axes[0][0] == 5 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 - assert proper_axes[4][0] == 2 # noqa: PLR2004 - assert proper_axes[5][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 6 + assert proper_axes[0][0] == 5 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 + assert proper_axes[4][0] == 2 + assert proper_axes[5][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert proper_axes[1][1] == pytest.approx([0.0, 0.0, 1.0]) assert proper_axes[2][1] == pytest.approx( @@ -2438,7 +2439,7 @@ def test_can_understand_D5h_symmetry(): # noqa: N802, PLR0915 assert proper_axes[5][1] == pytest.approx( [-0.00026868634145792505, 0.5877676345338332, 0.8090297495161426], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -2446,16 +2447,16 @@ def test_can_understand_D5h_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 5 # noqa: PLR2004 + assert improper_axes[0][0] == 5 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 6 # noqa: PLR2004 + assert len(mirror_axes) == 6 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -2476,38 +2477,38 @@ def test_can_understand_D5h_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[5][1] == pytest.approx( [-0.00014127095221938595, 0.30903875859031504, -0.9510494339052388], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D5h" - assert coords.symmetry_number(point_group) == 10 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 10 -def test_can_understand_D6h_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_d6h_symmetry() -> None: """Ensure values match regression logfiles for D6h symmetry.""" data = datasets.logfiles["symmetries"]["benzene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([90.78768809, 90.79030869, 181.57799671]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 - assert len(groups[0]) == 6 # noqa: PLR2004 - assert len(groups[1]) == 6 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 + assert len(groups[0]) == 6 + assert len(groups[1]) == 6 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "regular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 7 # noqa: PLR2004 - assert proper_axes[0][0] == 6 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 - assert proper_axes[4][0] == 2 # noqa: PLR2004 - assert proper_axes[5][0] == 2 # noqa: PLR2004 - assert proper_axes[6][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 7 + assert proper_axes[0][0] == 6 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 + assert proper_axes[4][0] == 2 + assert proper_axes[5][0] == 2 + assert proper_axes[6][0] == 2 assert proper_axes[1][1] == pytest.approx( [0.9815106205020463, -0.19140768362000038, 2.2201659599405544e-5], ) @@ -2526,21 +2527,21 @@ def test_can_understand_D6h_symmetry(): # noqa: N802, PLR0915 assert proper_axes[6][1] == pytest.approx( [-0.19146486729407206, -0.9814994674434222, 5.848736671162612e-7], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 7 # noqa: PLR2004 - assert improper_axes[0][0] == 6 # noqa: PLR2004 - assert improper_axes[1][0] == 2 # noqa: PLR2004 - assert improper_axes[2][0] == 2 # noqa: PLR2004 - assert improper_axes[3][0] == 2 # noqa: PLR2004 - assert improper_axes[4][0] == 2 # noqa: PLR2004 - assert improper_axes[5][0] == 2 # noqa: PLR2004 - assert improper_axes[6][0] == 2 # noqa: PLR2004 + assert len(improper_axes) == 7 + assert improper_axes[0][0] == 6 + assert improper_axes[1][0] == 2 + assert improper_axes[2][0] == 2 + assert improper_axes[3][0] == 2 + assert improper_axes[4][0] == 2 + assert improper_axes[5][0] == 2 + assert improper_axes[6][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] assert improper_axes[1][1] == proper_axes[1][1] assert improper_axes[2][1] == proper_axes[2][1] @@ -2548,14 +2549,14 @@ def test_can_understand_D6h_symmetry(): # noqa: N802, PLR0915 assert improper_axes[4][1] == proper_axes[4][1] assert improper_axes[5][1] == proper_axes[5][1] assert improper_axes[6][1] == proper_axes[6][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 7 # noqa: PLR2004 + assert len(mirror_axes) == 7 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -2581,40 +2582,40 @@ def test_can_understand_D6h_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[6][1] == pytest.approx( [-0.32494344338723713, 0.9457334477707772, -6.6085126787184e-5], ) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D6h" - assert coords.symmetry_number(point_group) == 12 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 12 -def test_can_understand_D7h_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_d7h_symmetry() -> None: """Ensure values match regression logfiles for D7h symmetry.""" data = datasets.logfiles["symmetries"]["C7H7+"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([137.6924278, 137.70343972, 275.39586735]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 - assert len(groups[0]) == 7 # noqa: PLR2004 - assert len(groups[1]) == 7 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 + assert len(groups[0]) == 7 + assert len(groups[1]) == 7 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "regular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 8 # noqa: PLR2004 - assert proper_axes[0][0] == 7 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 - assert proper_axes[4][0] == 2 # noqa: PLR2004 - assert proper_axes[5][0] == 2 # noqa: PLR2004 - assert proper_axes[6][0] == 2 # noqa: PLR2004 - assert proper_axes[7][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 8 + assert proper_axes[0][0] == 7 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 + assert proper_axes[4][0] == 2 + assert proper_axes[5][0] == 2 + assert proper_axes[6][0] == 2 + assert proper_axes[7][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) assert proper_axes[1][1] == pytest.approx( [0.9899264948348552, -0.14158225346562558, -1.8098975614729268e-5], @@ -2637,7 +2638,7 @@ def test_can_understand_D7h_symmetry(): # noqa: N802, PLR0915 assert proper_axes[7][1] == pytest.approx( [-0.08224227562969463, 0.9966123646156138, 5.286325905118405e-5], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -2645,16 +2646,16 @@ def test_can_understand_D7h_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 7 # noqa: PLR2004 + assert improper_axes[0][0] == 7 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 8 # noqa: PLR2004 + assert len(mirror_axes) == 8 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -2685,13 +2686,13 @@ def test_can_understand_D7h_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[7][1] == pytest.approx( [-0.9336164234837634, 0.3582741547160115, 6.216038584942583e-5], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D7h" - assert coords.symmetry_number(point_group) == 14 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 14 -def test_can_understand_D8h_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_d8h_symmetry() -> None: """Ensure values match regression logfiles for D8h symmetry.""" data = datasets.logfiles["symmetries"]["C8H8-2"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -2707,28 +2708,28 @@ def test_can_understand_D8h_symmetry(): # noqa: N802, PLR0915 ), abs=1e-6, ) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 - assert len(groups[0]) == 8 # noqa: PLR2004 - assert len(groups[1]) == 8 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 + assert len(groups[0]) == 8 + assert len(groups[1]) == 8 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "regular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 9 # noqa: PLR2004 - assert proper_axes[0][0] == 8 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 - assert proper_axes[4][0] == 2 # noqa: PLR2004 - assert proper_axes[5][0] == 2 # noqa: PLR2004 - assert proper_axes[6][0] == 2 # noqa: PLR2004 - assert proper_axes[7][0] == 2 # noqa: PLR2004 - assert proper_axes[8][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 9 + assert proper_axes[0][0] == 8 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 + assert proper_axes[4][0] == 2 + assert proper_axes[5][0] == 2 + assert proper_axes[6][0] == 2 + assert proper_axes[7][0] == 2 + assert proper_axes[8][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) assert proper_axes[1][1] == pytest.approx( [0.9898081173368313, -0.1424074815286812, 7.666555040225157e-6], @@ -2754,23 +2755,23 @@ def test_can_understand_D8h_symmetry(): # noqa: N802, PLR0915 assert proper_axes[8][1] == pytest.approx( [-0.5992048424224103, 0.8005957511766552, 3.927016327532347e-6], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 9 # noqa: PLR2004 - assert improper_axes[0][0] == 8 # noqa: PLR2004 - assert improper_axes[1][0] == 2 # noqa: PLR2004 - assert improper_axes[2][0] == 2 # noqa: PLR2004 - assert improper_axes[3][0] == 2 # noqa: PLR2004 - assert improper_axes[4][0] == 2 # noqa: PLR2004 - assert improper_axes[5][0] == 2 # noqa: PLR2004 - assert improper_axes[6][0] == 2 # noqa: PLR2004 - assert improper_axes[7][0] == 2 # noqa: PLR2004 - assert improper_axes[8][0] == 2 # noqa: PLR2004 + assert len(improper_axes) == 9 + assert improper_axes[0][0] == 8 + assert improper_axes[1][0] == 2 + assert improper_axes[2][0] == 2 + assert improper_axes[3][0] == 2 + assert improper_axes[4][0] == 2 + assert improper_axes[5][0] == 2 + assert improper_axes[6][0] == 2 + assert improper_axes[7][0] == 2 + assert improper_axes[8][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] assert improper_axes[1][1] == proper_axes[1][1] assert improper_axes[2][1] == proper_axes[2][1] @@ -2780,14 +2781,14 @@ def test_can_understand_D8h_symmetry(): # noqa: N802, PLR0915 assert improper_axes[6][1] == proper_axes[6][1] assert improper_axes[7][1] == proper_axes[7][1] assert improper_axes[8][1] == proper_axes[8][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 9 # noqa: PLR2004 + assert len(mirror_axes) == 9 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -2822,35 +2823,35 @@ def test_can_understand_D8h_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[8][1] == pytest.approx( [-0.8599694047950066, 0.5103455914146812, 1.1837289236101089e-5], ) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D8h" - assert coords.symmetry_number(point_group) == 16 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 16 -def test_can_understand_D2d_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_d2d_symmetry() -> None: """Ensure values match regression logfiles for D2d symmetry.""" data = datasets.logfiles["symmetries"]["allene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([3.59943307, 58.28028795, 58.2804547]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 4 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 2 + assert len(groups[2]) == 4 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 3 # noqa: PLR2004 - assert proper_axes[0][0] == 2 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 3 + assert proper_axes[0][0] == 2 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert proper_axes[1][1] == pytest.approx( [1.0104893446543213e-5, -0.9309114503766126, -0.36524494720064615], @@ -2858,7 +2859,7 @@ def test_can_understand_D2d_symmetry(): # noqa: N802, PLR0915 assert proper_axes[2][1] == pytest.approx( [-0.00012735231509610425, 0.365345598359124, -0.9308719447598587], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -2866,16 +2867,16 @@ def test_can_understand_D2d_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 4 # noqa: PLR2004 + assert improper_axes[0][0] == 4 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 2 # noqa: PLR2004 + assert len(mirror_axes) == 2 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[0][1] == pytest.approx( @@ -2884,33 +2885,33 @@ def test_can_understand_D2d_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[1][1] == pytest.approx( [-9.719161506363647e-5, 0.9165428631171116, -0.39993645823165147], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D2d" - assert coords.symmetry_number(point_group) == 4 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 4 data = datasets.logfiles["symmetries"]["cyclooctatetraene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([191.055088155, 191.055088155, 338.69081546]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 - assert len(groups[0]) == 8 # noqa: PLR2004 - assert len(groups[1]) == 8 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 + assert len(groups[0]) == 8 + assert len(groups[1]) == 8 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 3 # noqa: PLR2004 - assert proper_axes[0][0] == 2 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 3 + assert proper_axes[0][0] == 2 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 assert proper_axes[2][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -2918,16 +2919,16 @@ def test_can_understand_D2d_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 4 # noqa: PLR2004 + assert improper_axes[0][0] == 4 assert improper_axes[0][1] == proper_axes[2][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 2 # noqa: PLR2004 + assert len(mirror_axes) == 2 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[0][1] == pytest.approx( @@ -2936,13 +2937,13 @@ def test_can_understand_D2d_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[1][1] == pytest.approx( [-0.707106781007808, -0.7071067813652863, 3.143117640046285e-8], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D2d" - assert coords.symmetry_number(point_group) == 4 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 4 -def test_can_understand_D3d_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_d3d_symmetry() -> None: """Ensure values match regression logfiles for D3d symmetry.""" data = datasets.logfiles["ethane"]["staggered@B97-3c"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -2958,23 +2959,23 @@ def test_can_understand_D3d_symmetry(): # noqa: N802, PLR0915 ), abs=1e-6, ) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 - assert len(groups[0]) == 2 # noqa: PLR2004 - assert len(groups[1]) == 6 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 + assert len(groups[0]) == 2 + assert len(groups[1]) == 6 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 4 # noqa: PLR2004 - assert proper_axes[0][0] == 3 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 4 + assert proper_axes[0][0] == 3 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert proper_axes[1][1] == pytest.approx( [5.114492593761218e-8, -0.7705968636328516, -0.6373228959948086], @@ -2985,30 +2986,30 @@ def test_can_understand_D3d_symmetry(): # noqa: N802, PLR0915 assert proper_axes[3][1] == pytest.approx( [-0.00015396128883686421, 0.1666592192271586, -0.9860145439812312], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 4 # noqa: PLR2004 - assert improper_axes[0][0] == 6 # noqa: PLR2004 - assert improper_axes[1][0] == 2 # noqa: PLR2004 - assert improper_axes[2][0] == 2 # noqa: PLR2004 - assert improper_axes[3][0] == 2 # noqa: PLR2004 + assert len(improper_axes) == 4 + assert improper_axes[0][0] == 6 + assert improper_axes[1][0] == 2 + assert improper_axes[2][0] == 2 + assert improper_axes[3][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] assert improper_axes[1][1] == proper_axes[1][1] assert improper_axes[2][1] == proper_axes[2][1] assert improper_axes[3][1] == proper_axes[3][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 3 # noqa: PLR2004 + assert len(mirror_axes) == 3 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -3021,33 +3022,33 @@ def test_can_understand_D3d_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[2][1] == pytest.approx( [-0.00015439235712643497, 0.16665964180691425, -0.9860144724880011], ) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D3d" - assert coords.symmetry_number(point_group) == 6 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 6 data = datasets.logfiles["symmetries"]["cyclohexane-chair"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([119.83069224, 119.84744745, 209.85483434]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 - assert len(groups[0]) == 6 # noqa: PLR2004 - assert len(groups[1]) == 6 # noqa: PLR2004 - assert len(groups[2]) == 6 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 + assert len(groups[0]) == 6 + assert len(groups[1]) == 6 + assert len(groups[2]) == 6 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 4 # noqa: PLR2004 - assert proper_axes[0][0] == 3 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 4 + assert proper_axes[0][0] == 3 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) assert proper_axes[1][1] == pytest.approx( [0.9793333381651573, 0.20225284225808615, -2.3596930174470247e-5], @@ -3058,30 +3059,30 @@ def test_can_understand_D3d_symmetry(): # noqa: N802, PLR0915 assert proper_axes[3][1] == pytest.approx( [0.3145021354292675, 0.9492567628633137, -7.048895828035251e-5], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 4 # noqa: PLR2004 - assert improper_axes[0][0] == 6 # noqa: PLR2004 - assert improper_axes[1][0] == 2 # noqa: PLR2004 - assert improper_axes[2][0] == 2 # noqa: PLR2004 - assert improper_axes[3][0] == 2 # noqa: PLR2004 + assert len(improper_axes) == 4 + assert improper_axes[0][0] == 6 + assert improper_axes[1][0] == 2 + assert improper_axes[2][0] == 2 + assert improper_axes[3][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] assert improper_axes[1][1] == proper_axes[1][1] assert improper_axes[2][1] == proper_axes[2][1] assert improper_axes[3][1] == proper_axes[3][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 3 # noqa: PLR2004 + assert len(mirror_axes) == 3 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -3094,35 +3095,35 @@ def test_can_understand_D3d_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[2][1] == pytest.approx( [-0.6648303780404605, 0.7469943548888298, -4.689135533812219e-5], ) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D3d" - assert coords.symmetry_number(point_group) == 6 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 6 -def test_can_understand_D4d_symmetry(): # noqa: N802 +def test_can_understand_d4d_symmetry() -> None: """Ensure values match regression logfiles for D4d symmetry.""" data = datasets.logfiles["symmetries"]["S8"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([810.52396682, 810.88788286, 1489.78398196]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 1 - assert len(groups[0]) == 8 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[0]) == 8 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 5 # noqa: PLR2004 - assert proper_axes[0][0] == 4 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 - assert proper_axes[4][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 5 + assert proper_axes[0][0] == 4 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 + assert proper_axes[4][0] == 2 assert proper_axes[1][1] == pytest.approx( [0.963244226087016, 0.26862717752913695, -2.0068760230898394e-5], ) @@ -3135,7 +3136,7 @@ def test_can_understand_D4d_symmetry(): # noqa: N802 assert proper_axes[4][1] == pytest.approx( [-0.49116983754349636, -0.8710638121055401, 0.00016102068144324463], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -3143,16 +3144,16 @@ def test_can_understand_D4d_symmetry(): # noqa: N802 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 8 # noqa: PLR2004 + assert improper_axes[0][0] == 8 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 4 # noqa: PLR2004 + assert len(mirror_axes) == 4 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -3169,13 +3170,13 @@ def test_can_understand_D4d_symmetry(): # noqa: N802 assert mirror_axes[3][1] == pytest.approx( [0.12051512195987304, 0.9927114721259069, 0.0001961851471428286], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D4d" - assert coords.symmetry_number(point_group) == 8 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 8 -def test_can_understand_D5d_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_d5d_symmetry() -> None: """Ensure values match regression logfiles for D5d symmetry.""" data = datasets.logfiles["symmetries"]["ferrocene-staggered"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -3191,26 +3192,26 @@ def test_can_understand_D5d_symmetry(): # noqa: N802, PLR0915 ), abs=1e-6, ) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 - assert len(groups[1]) == 10 # noqa: PLR2004 - assert len(groups[2]) == 10 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 10 + assert len(groups[2]) == 10 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 6 # noqa: PLR2004 - assert proper_axes[0][0] == 5 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 - assert proper_axes[4][0] == 2 # noqa: PLR2004 - assert proper_axes[5][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 6 + assert proper_axes[0][0] == 5 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 + assert proper_axes[4][0] == 2 + assert proper_axes[5][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) assert proper_axes[1][1] == pytest.approx( [3.573651507251015e-5, -0.8090202704430335, 0.5877807420587906], @@ -3225,34 +3226,34 @@ def test_can_understand_D5d_symmetry(): # noqa: N802, PLR0915 assert proper_axes[5][1] == pytest.approx( [-4.784454416974403e-6, -0.30902881328774495, -0.951052676004372], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 6 # noqa: PLR2004 - assert improper_axes[0][0] == 10 # noqa: PLR2004 - assert improper_axes[1][0] == 2 # noqa: PLR2004 - assert improper_axes[2][0] == 2 # noqa: PLR2004 - assert improper_axes[3][0] == 2 # noqa: PLR2004 - assert improper_axes[4][0] == 2 # noqa: PLR2004 - assert improper_axes[5][0] == 2 # noqa: PLR2004 + assert len(improper_axes) == 6 + assert improper_axes[0][0] == 10 + assert improper_axes[1][0] == 2 + assert improper_axes[2][0] == 2 + assert improper_axes[3][0] == 2 + assert improper_axes[4][0] == 2 + assert improper_axes[5][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] assert improper_axes[1][1] == proper_axes[1][1] assert improper_axes[2][1] == proper_axes[2][1] assert improper_axes[3][1] == proper_axes[3][1] assert improper_axes[4][1] == proper_axes[4][1] assert improper_axes[5][1] == proper_axes[5][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 5 # noqa: PLR2004 + assert len(mirror_axes) == 5 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -3271,13 +3272,13 @@ def test_can_understand_D5d_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[4][1] == pytest.approx( [-3.573651507251015e-5, -0.8090202704430335, -0.5877807420587906], ) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "D5d" - assert coords.symmetry_number(point_group) == 10 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 10 -def test_can_understand_S4_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_s4_symmetry() -> None: """Ensure values match regression logfiles for S4 symmetry.""" data = datasets.logfiles["symmetries"]["tetrachloroneopentane"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -3293,24 +3294,24 @@ def test_can_understand_S4_symmetry(): # noqa: N802, PLR0915 ), abs=1e-6, ) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 4 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 4 assert len(groups[0]) == 1 - assert len(groups[1]) == 4 # noqa: PLR2004 - assert len(groups[2]) == 4 # noqa: PLR2004 - assert len(groups[3]) == 8 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 4 + assert len(groups[2]) == 4 + assert len(groups[3]) == 8 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 + assert proper_axes[0][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -3318,9 +3319,9 @@ def test_can_understand_S4_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 4 # noqa: PLR2004 + assert improper_axes[0][0] == 4 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -3328,32 +3329,32 @@ def test_can_understand_S4_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(mirror_axes) == 0 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "S4" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 data = datasets.logfiles["symmetries"]["1,3,5,7-tetrachlorocyclooctatetraene"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([1124.75960399, 1124.76010676, 1717.87114398]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 - assert len(groups[0]) == 4 # noqa: PLR2004 - assert len(groups[1]) == 4 # noqa: PLR2004 - assert len(groups[2]) == 8 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 + assert len(groups[0]) == 4 + assert len(groups[1]) == 4 + assert len(groups[2]) == 8 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 + assert proper_axes[0][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -3361,9 +3362,9 @@ def test_can_understand_S4_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 4 # noqa: PLR2004 + assert improper_axes[0][0] == 4 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -3371,41 +3372,41 @@ def test_can_understand_S4_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(mirror_axes) == 0 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "S4" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 data = datasets.logfiles["symmetries"]["tetraphenylborate-"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([2328.48397615, 2573.6635109, 2573.66376861]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 12 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 12 assert len(groups[0]) == 1 - assert len(groups[1]) == 4 # noqa: PLR2004 - assert len(groups[2]) == 4 # noqa: PLR2004 - assert len(groups[3]) == 4 # noqa: PLR2004 - assert len(groups[4]) == 4 # noqa: PLR2004 - assert len(groups[5]) == 4 # noqa: PLR2004 - assert len(groups[6]) == 4 # noqa: PLR2004 - assert len(groups[7]) == 4 # noqa: PLR2004 - assert len(groups[8]) == 4 # noqa: PLR2004 - assert len(groups[9]) == 4 # noqa: PLR2004 - assert len(groups[10]) == 4 # noqa: PLR2004 - assert len(groups[11]) == 4 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 4 + assert len(groups[2]) == 4 + assert len(groups[3]) == 4 + assert len(groups[4]) == 4 + assert len(groups[5]) == 4 + assert len(groups[6]) == 4 + assert len(groups[7]) == 4 + assert len(groups[8]) == 4 + assert len(groups[9]) == 4 + assert len(groups[10]) == 4 + assert len(groups[11]) == 4 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 + assert proper_axes[0][0] == 2 assert proper_axes[0][1] == pytest.approx([1.0, 0.0, 0.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -3413,9 +3414,9 @@ def test_can_understand_S4_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 4 # noqa: PLR2004 + assert improper_axes[0][0] == 4 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, @@ -3423,13 +3424,13 @@ def test_can_understand_S4_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(mirror_axes) == 0 - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "S4" - assert coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 2 -def test_can_understand_Td_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_td_symmetry() -> None: """Ensure values match regression logfiles for Td symmetry.""" data = datasets.logfiles["tanaka1996"][ "methane@UMP2/6-311G(2df,2pd)" @@ -3438,26 +3439,26 @@ def test_can_understand_Td_symmetry(): # noqa: N802, PLR0915 assert moments == pytest.approx([3.182947905, 3.182947905, 3.182947905], 1e-2) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 assert len(groups[0]) == 1 - assert len(groups[1]) == 4 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 4 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("spheric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 7 # noqa: PLR2004 - assert proper_axes[0][0] == 3 # noqa: PLR2004 - assert proper_axes[1][0] == 3 # noqa: PLR2004 - assert proper_axes[2][0] == 3 # noqa: PLR2004 - assert proper_axes[3][0] == 3 # noqa: PLR2004 - assert proper_axes[4][0] == 2 # noqa: PLR2004 - assert proper_axes[5][0] == 2 # noqa: PLR2004 - assert proper_axes[6][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 7 + assert proper_axes[0][0] == 3 + assert proper_axes[1][0] == 3 + assert proper_axes[2][0] == 3 + assert proper_axes[3][0] == 3 + assert proper_axes[4][0] == 2 + assert proper_axes[5][0] == 2 + assert proper_axes[6][0] == 2 assert proper_axes[0][1] == pytest.approx( [0.5773502691896257, 0.5773502691896257, 0.5773502691896257], ) @@ -3473,28 +3474,28 @@ def test_can_understand_Td_symmetry(): # noqa: N802, PLR0915 assert proper_axes[4][1] == pytest.approx([0.0, 0.0, -1.0]) assert proper_axes[5][1] == pytest.approx([0.0, -1.0, 0.0]) assert proper_axes[6][1] == pytest.approx([-1.0, 0.0, 0.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 3 # noqa: PLR2004 - assert improper_axes[0][0] == 4 # noqa: PLR2004 - assert improper_axes[1][0] == 4 # noqa: PLR2004 - assert improper_axes[2][0] == 4 # noqa: PLR2004 + assert len(improper_axes) == 3 + assert improper_axes[0][0] == 4 + assert improper_axes[1][0] == 4 + assert improper_axes[2][0] == 4 assert improper_axes[0][1] == proper_axes[4][1] assert improper_axes[1][1] == proper_axes[5][1] assert improper_axes[2][1] == proper_axes[6][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 6 # noqa: PLR2004 + assert len(mirror_axes) == 6 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -3519,36 +3520,36 @@ def test_can_understand_Td_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[5][1] == pytest.approx( [-0.7071067811865476, -0.7071067811865476, 0.0], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "Td" - assert coords.symmetry_number(point_group) == 12 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 12 data = datasets.logfiles["symmetries"]["tetrahedrane"] # tetrahedron moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([37.54433184, 37.54433184, 37.54433184]) assert axes.T @ axes == pytest.approx(np.eye(3)) assert axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 - assert len(groups[0]) == 4 # noqa: PLR2004 - assert len(groups[1]) == 4 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 + assert len(groups[0]) == 4 + assert len(groups[1]) == 4 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("spheric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 7 # noqa: PLR2004 - assert proper_axes[0][0] == 3 # noqa: PLR2004 - assert proper_axes[1][0] == 3 # noqa: PLR2004 - assert proper_axes[2][0] == 3 # noqa: PLR2004 - assert proper_axes[3][0] == 3 # noqa: PLR2004 - assert proper_axes[4][0] == 2 # noqa: PLR2004 - assert proper_axes[5][0] == 2 # noqa: PLR2004 - assert proper_axes[6][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 7 + assert proper_axes[0][0] == 3 + assert proper_axes[1][0] == 3 + assert proper_axes[2][0] == 3 + assert proper_axes[3][0] == 3 + assert proper_axes[4][0] == 2 + assert proper_axes[5][0] == 2 + assert proper_axes[6][0] == 2 assert proper_axes[0][1] == pytest.approx( [0.5773502691896257, 0.5773502691896257, 0.5773502691896257], ) @@ -3564,28 +3565,28 @@ def test_can_understand_Td_symmetry(): # noqa: N802, PLR0915 assert proper_axes[4][1] == pytest.approx([1.0, 0.0, 0.0]) assert proper_axes[5][1] == pytest.approx([0.0, 0.0, 1.0]) assert proper_axes[6][1] == pytest.approx([0.0, -1.0, 0.0]) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 3 # noqa: PLR2004 - assert improper_axes[0][0] == 4 # noqa: PLR2004 - assert improper_axes[1][0] == 4 # noqa: PLR2004 - assert improper_axes[2][0] == 4 # noqa: PLR2004 + assert len(improper_axes) == 3 + assert improper_axes[0][0] == 4 + assert improper_axes[1][0] == 4 + assert improper_axes[2][0] == 4 assert improper_axes[0][1] == proper_axes[4][1] assert improper_axes[1][1] == proper_axes[5][1] assert improper_axes[2][1] == proper_axes[6][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 6 # noqa: PLR2004 + assert len(mirror_axes) == 6 assert mirror_axes[0][0] == "v" assert mirror_axes[1][0] == "v" assert mirror_axes[2][0] == "v" @@ -3610,13 +3611,13 @@ def test_can_understand_Td_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[5][1] == pytest.approx( [-0.7071067811865476, -0.7071067811865476, 0.0], ) - assert not coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert not coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "Td" - assert coords.symmetry_number(point_group) == 12 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 12 -def test_can_understand_Oh_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_oh_symmetry() -> None: """Ensure values match regression logfiles for Oh symmetry.""" data = datasets.logfiles["symmetries"]["cubane"] # hexahedron aka cube moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) @@ -3632,32 +3633,32 @@ def test_can_understand_Oh_symmetry(): # noqa: N802, PLR0915 ), abs=1e-6, ) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 - assert len(groups[0]) == 8 # noqa: PLR2004 - assert len(groups[1]) == 8 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 + assert len(groups[0]) == 8 + assert len(groups[1]) == 8 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("spheric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 13 # noqa: PLR2004 - assert proper_axes[0][0] == 4 # noqa: PLR2004 - assert proper_axes[1][0] == 4 # noqa: PLR2004 - assert proper_axes[2][0] == 4 # noqa: PLR2004 - assert proper_axes[3][0] == 3 # noqa: PLR2004 - assert proper_axes[4][0] == 3 # noqa: PLR2004 - assert proper_axes[5][0] == 3 # noqa: PLR2004 - assert proper_axes[6][0] == 3 # noqa: PLR2004 - assert proper_axes[7][0] == 2 # noqa: PLR2004 - assert proper_axes[8][0] == 2 # noqa: PLR2004 - assert proper_axes[9][0] == 2 # noqa: PLR2004 - assert proper_axes[10][0] == 2 # noqa: PLR2004 - assert proper_axes[11][0] == 2 # noqa: PLR2004 - assert proper_axes[12][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 13 + assert proper_axes[0][0] == 4 + assert proper_axes[1][0] == 4 + assert proper_axes[2][0] == 4 + assert proper_axes[3][0] == 3 + assert proper_axes[4][0] == 3 + assert proper_axes[5][0] == 3 + assert proper_axes[6][0] == 3 + assert proper_axes[7][0] == 2 + assert proper_axes[8][0] == 2 + assert proper_axes[9][0] == 2 + assert proper_axes[10][0] == 2 + assert proper_axes[11][0] == 2 + assert proper_axes[12][0] == 2 assert proper_axes[0][1] == pytest.approx( [0.968308520495324, -0.11479281066604227, -0.22181347965249296], ) @@ -3697,27 +3698,27 @@ def test_can_understand_Oh_symmetry(): # noqa: N802, PLR0915 assert proper_axes[12][1] == pytest.approx( [-0.5856129657464667, -0.26164449901693576, 0.7672024572978141], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 13 # noqa: PLR2004 - assert improper_axes[0][0] == 6 # noqa: PLR2004 - assert improper_axes[1][0] == 6 # noqa: PLR2004 - assert improper_axes[2][0] == 6 # noqa: PLR2004 - assert improper_axes[3][0] == 6 # noqa: PLR2004 - assert improper_axes[4][0] == 4 # noqa: PLR2004 - assert improper_axes[5][0] == 4 # noqa: PLR2004 - assert improper_axes[6][0] == 4 # noqa: PLR2004 - assert improper_axes[7][0] == 2 # noqa: PLR2004 - assert improper_axes[8][0] == 2 # noqa: PLR2004 - assert improper_axes[9][0] == 2 # noqa: PLR2004 - assert improper_axes[10][0] == 2 # noqa: PLR2004 - assert improper_axes[11][0] == 2 # noqa: PLR2004 - assert improper_axes[12][0] == 2 # noqa: PLR2004 + assert len(improper_axes) == 13 + assert improper_axes[0][0] == 6 + assert improper_axes[1][0] == 6 + assert improper_axes[2][0] == 6 + assert improper_axes[3][0] == 6 + assert improper_axes[4][0] == 4 + assert improper_axes[5][0] == 4 + assert improper_axes[6][0] == 4 + assert improper_axes[7][0] == 2 + assert improper_axes[8][0] == 2 + assert improper_axes[9][0] == 2 + assert improper_axes[10][0] == 2 + assert improper_axes[11][0] == 2 + assert improper_axes[12][0] == 2 assert improper_axes[0][1] == proper_axes[3][1] assert improper_axes[1][1] == proper_axes[4][1] assert improper_axes[2][1] == proper_axes[5][1] @@ -3731,14 +3732,14 @@ def test_can_understand_Oh_symmetry(): # noqa: N802, PLR0915 assert improper_axes[10][1] == proper_axes[10][1] assert improper_axes[11][1] == proper_axes[11][1] assert improper_axes[12][1] == proper_axes[12][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 9 # noqa: PLR2004 + assert len(mirror_axes) == 9 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "h" assert mirror_axes[2][0] == "h" @@ -3775,41 +3776,41 @@ def test_can_understand_Oh_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[8][1] == pytest.approx( [-0.8309038705883419, -0.531787711389286, -0.16370885088063244], ) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "Oh" - assert coords.symmetry_number(point_group) == 24 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 24 data = datasets.logfiles["symmetries"]["SF6"] # octahedron moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([195.62987814, 195.64569248, 195.66607271]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 assert len(groups[0]) == 1 - assert len(groups[1]) == 6 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 6 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("spheric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 13 # noqa: PLR2004 - assert proper_axes[0][0] == 4 # noqa: PLR2004 - assert proper_axes[1][0] == 4 # noqa: PLR2004 - assert proper_axes[2][0] == 4 # noqa: PLR2004 - assert proper_axes[3][0] == 3 # noqa: PLR2004 - assert proper_axes[4][0] == 3 # noqa: PLR2004 - assert proper_axes[5][0] == 3 # noqa: PLR2004 - assert proper_axes[6][0] == 3 # noqa: PLR2004 - assert proper_axes[7][0] == 2 # noqa: PLR2004 - assert proper_axes[8][0] == 2 # noqa: PLR2004 - assert proper_axes[9][0] == 2 # noqa: PLR2004 - assert proper_axes[10][0] == 2 # noqa: PLR2004 - assert proper_axes[11][0] == 2 # noqa: PLR2004 - assert proper_axes[12][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 13 + assert proper_axes[0][0] == 4 + assert proper_axes[1][0] == 4 + assert proper_axes[2][0] == 4 + assert proper_axes[3][0] == 3 + assert proper_axes[4][0] == 3 + assert proper_axes[5][0] == 3 + assert proper_axes[6][0] == 3 + assert proper_axes[7][0] == 2 + assert proper_axes[8][0] == 2 + assert proper_axes[9][0] == 2 + assert proper_axes[10][0] == 2 + assert proper_axes[11][0] == 2 + assert proper_axes[12][0] == 2 assert proper_axes[0][1] == pytest.approx( [0.20842728261025004, 0.9069406581468825, 0.36608292839711426], ) @@ -3849,27 +3850,27 @@ def test_can_understand_Oh_symmetry(): # noqa: N802, PLR0915 assert proper_axes[12][1] == pytest.approx( [-0.9770164502779867, 0.21020438400853103, 0.03539735625433769], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(improper_axes) == 13 # noqa: PLR2004 - assert improper_axes[0][0] == 6 # noqa: PLR2004 - assert improper_axes[1][0] == 6 # noqa: PLR2004 - assert improper_axes[2][0] == 6 # noqa: PLR2004 - assert improper_axes[3][0] == 6 # noqa: PLR2004 - assert improper_axes[4][0] == 4 # noqa: PLR2004 - assert improper_axes[5][0] == 4 # noqa: PLR2004 - assert improper_axes[6][0] == 4 # noqa: PLR2004 - assert improper_axes[7][0] == 2 # noqa: PLR2004 - assert improper_axes[8][0] == 2 # noqa: PLR2004 - assert improper_axes[9][0] == 2 # noqa: PLR2004 - assert improper_axes[10][0] == 2 # noqa: PLR2004 - assert improper_axes[11][0] == 2 # noqa: PLR2004 - assert improper_axes[12][0] == 2 # noqa: PLR2004 + assert len(improper_axes) == 13 + assert improper_axes[0][0] == 6 + assert improper_axes[1][0] == 6 + assert improper_axes[2][0] == 6 + assert improper_axes[3][0] == 6 + assert improper_axes[4][0] == 4 + assert improper_axes[5][0] == 4 + assert improper_axes[6][0] == 4 + assert improper_axes[7][0] == 2 + assert improper_axes[8][0] == 2 + assert improper_axes[9][0] == 2 + assert improper_axes[10][0] == 2 + assert improper_axes[11][0] == 2 + assert improper_axes[12][0] == 2 assert improper_axes[0][1] == proper_axes[3][1] assert improper_axes[1][1] == proper_axes[4][1] assert improper_axes[2][1] == proper_axes[5][1] @@ -3883,14 +3884,14 @@ def test_can_understand_Oh_symmetry(): # noqa: N802, PLR0915 assert improper_axes[10][1] == proper_axes[10][1] assert improper_axes[11][1] == proper_axes[11][1] assert improper_axes[12][1] == proper_axes[12][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 9 # noqa: PLR2004 + assert len(mirror_axes) == 9 assert mirror_axes[0][0] == "h" assert mirror_axes[1][0] == "h" assert mirror_axes[2][0] == "h" @@ -3927,36 +3928,36 @@ def test_can_understand_Oh_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[8][1] == pytest.approx( [-0.3636141885662752, 0.5638940339581285, 0.7414905531021403], ) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "Oh" - assert coords.symmetry_number(point_group) == 24 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 24 -def test_can_understand_Ih_symmetry(): # noqa: N802, PLR0915 +def test_can_understand_ih_symmetry() -> None: """Ensure values match regression logfiles for Ih symmetry.""" data = datasets.logfiles["symmetries"]["B12H12-2"] # icosahedron moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([323.38198873, 323.39397591, 323.41051849]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 - assert len(groups[0]) == 12 # noqa: PLR2004 - assert len(groups[1]) == 12 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 + assert len(groups[0]) == 12 + assert len(groups[1]) == 12 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("spheric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 5 # noqa: PLR2004 + assert proper_axes[0][0] == 5 assert proper_axes[0][1] == pytest.approx( [0.32276287512969803, -0.8506628423519896, 0.41496608907192073], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 + improper_axes = coords._get_improper_axes( atomcoords, groups, axes, @@ -3964,26 +3965,26 @@ def test_can_understand_Ih_symmetry(): # noqa: N802, PLR0915 proper_axes, ) assert len(improper_axes) == 1 - assert improper_axes[0][0] == 10 # noqa: PLR2004 + assert improper_axes[0][0] == 10 assert improper_axes[0][1] == proper_axes[0][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 15 # noqa: PLR2004 - assert mirror_axes[0][0] == "" # noqa: PLC1901 - assert mirror_axes[1][0] == "" # noqa: PLC1901 - assert mirror_axes[2][0] == "" # noqa: PLC1901 - assert mirror_axes[3][0] == "" # noqa: PLC1901 - assert mirror_axes[4][0] == "" # noqa: PLC1901 - assert mirror_axes[5][0] == "" # noqa: PLC1901 - assert mirror_axes[6][0] == "" # noqa: PLC1901 - assert mirror_axes[7][0] == "" # noqa: PLC1901 - assert mirror_axes[8][0] == "" # noqa: PLC1901 - assert mirror_axes[9][0] == "" # noqa: PLC1901 + assert len(mirror_axes) == 15 + assert mirror_axes[0][0] == "" + assert mirror_axes[1][0] == "" + assert mirror_axes[2][0] == "" + assert mirror_axes[3][0] == "" + assert mirror_axes[4][0] == "" + assert mirror_axes[5][0] == "" + assert mirror_axes[6][0] == "" + assert mirror_axes[7][0] == "" + assert mirror_axes[8][0] == "" + assert mirror_axes[9][0] == "" assert mirror_axes[10][0] == "v" assert mirror_axes[11][0] == "v" assert mirror_axes[12][0] == "v" @@ -4034,88 +4035,88 @@ def test_can_understand_Ih_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[14][1] == pytest.approx( [-0.945553936415154, -0.30903900618757657, 0.10209136096850731], ) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "Ih" - assert coords.symmetry_number(point_group) == 60 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 60 data = datasets.logfiles["symmetries"]["dodecahedrane"] # dodecahedron moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([913.24407956, 913.29418754, 913.31698587]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 - assert len(groups[0]) == 20 # noqa: PLR2004 - assert len(groups[1]) == 20 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 + assert len(groups[0]) == 20 + assert len(groups[1]) == 20 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("spheric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 - atomcoords, - groups, - axes, - rotor_class, - ) - assert len(proper_axes) == 26 # noqa: PLR2004 - assert proper_axes[0][0] == 5 # noqa: PLR2004 - assert proper_axes[1][0] == 3 # noqa: PLR2004 - assert proper_axes[2][0] == 3 # noqa: PLR2004 - assert proper_axes[3][0] == 3 # noqa: PLR2004 - assert proper_axes[4][0] == 3 # noqa: PLR2004 - assert proper_axes[5][0] == 3 # noqa: PLR2004 - assert proper_axes[6][0] == 3 # noqa: PLR2004 - assert proper_axes[7][0] == 3 # noqa: PLR2004 - assert proper_axes[8][0] == 3 # noqa: PLR2004 - assert proper_axes[9][0] == 3 # noqa: PLR2004 - assert proper_axes[10][0] == 3 # noqa: PLR2004 - assert proper_axes[11][0] == 2 # noqa: PLR2004 - assert proper_axes[12][0] == 2 # noqa: PLR2004 - assert proper_axes[13][0] == 2 # noqa: PLR2004 - assert proper_axes[14][0] == 2 # noqa: PLR2004 - assert proper_axes[15][0] == 2 # noqa: PLR2004 - assert proper_axes[16][0] == 2 # noqa: PLR2004 - assert proper_axes[17][0] == 2 # noqa: PLR2004 - assert proper_axes[18][0] == 2 # noqa: PLR2004 - assert proper_axes[19][0] == 2 # noqa: PLR2004 - assert proper_axes[20][0] == 2 # noqa: PLR2004 - assert proper_axes[21][0] == 2 # noqa: PLR2004 - assert proper_axes[22][0] == 2 # noqa: PLR2004 - assert proper_axes[23][0] == 2 # noqa: PLR2004 - assert proper_axes[24][0] == 2 # noqa: PLR2004 - assert proper_axes[25][0] == 2 # noqa: PLR2004 - improper_axes = coords._get_improper_axes( # noqa: SLF001 - atomcoords, - groups, - axes, - rotor_class, - proper_axes, - ) - assert len(improper_axes) == 26 # noqa: PLR2004 - assert improper_axes[0][0] == 10 # noqa: PLR2004 - assert improper_axes[1][0] == 6 # noqa: PLR2004 - assert improper_axes[2][0] == 6 # noqa: PLR2004 - assert improper_axes[3][0] == 6 # noqa: PLR2004 - assert improper_axes[4][0] == 6 # noqa: PLR2004 - assert improper_axes[5][0] == 6 # noqa: PLR2004 - assert improper_axes[6][0] == 6 # noqa: PLR2004 - assert improper_axes[7][0] == 6 # noqa: PLR2004 - assert improper_axes[8][0] == 6 # noqa: PLR2004 - assert improper_axes[9][0] == 6 # noqa: PLR2004 - assert improper_axes[10][0] == 6 # noqa: PLR2004 - assert improper_axes[11][0] == 2 # noqa: PLR2004 - assert improper_axes[12][0] == 2 # noqa: PLR2004 - assert improper_axes[13][0] == 2 # noqa: PLR2004 - assert improper_axes[14][0] == 2 # noqa: PLR2004 - assert improper_axes[15][0] == 2 # noqa: PLR2004 - assert improper_axes[16][0] == 2 # noqa: PLR2004 - assert improper_axes[17][0] == 2 # noqa: PLR2004 - assert improper_axes[18][0] == 2 # noqa: PLR2004 - assert improper_axes[19][0] == 2 # noqa: PLR2004 - assert improper_axes[20][0] == 2 # noqa: PLR2004 - assert improper_axes[21][0] == 2 # noqa: PLR2004 - assert improper_axes[22][0] == 2 # noqa: PLR2004 - assert improper_axes[23][0] == 2 # noqa: PLR2004 - assert improper_axes[24][0] == 2 # noqa: PLR2004 - assert improper_axes[25][0] == 2 # noqa: PLR2004 + proper_axes = coords._get_proper_axes( + atomcoords, + groups, + axes, + rotor_class, + ) + assert len(proper_axes) == 26 + assert proper_axes[0][0] == 5 + assert proper_axes[1][0] == 3 + assert proper_axes[2][0] == 3 + assert proper_axes[3][0] == 3 + assert proper_axes[4][0] == 3 + assert proper_axes[5][0] == 3 + assert proper_axes[6][0] == 3 + assert proper_axes[7][0] == 3 + assert proper_axes[8][0] == 3 + assert proper_axes[9][0] == 3 + assert proper_axes[10][0] == 3 + assert proper_axes[11][0] == 2 + assert proper_axes[12][0] == 2 + assert proper_axes[13][0] == 2 + assert proper_axes[14][0] == 2 + assert proper_axes[15][0] == 2 + assert proper_axes[16][0] == 2 + assert proper_axes[17][0] == 2 + assert proper_axes[18][0] == 2 + assert proper_axes[19][0] == 2 + assert proper_axes[20][0] == 2 + assert proper_axes[21][0] == 2 + assert proper_axes[22][0] == 2 + assert proper_axes[23][0] == 2 + assert proper_axes[24][0] == 2 + assert proper_axes[25][0] == 2 + improper_axes = coords._get_improper_axes( + atomcoords, + groups, + axes, + rotor_class, + proper_axes, + ) + assert len(improper_axes) == 26 + assert improper_axes[0][0] == 10 + assert improper_axes[1][0] == 6 + assert improper_axes[2][0] == 6 + assert improper_axes[3][0] == 6 + assert improper_axes[4][0] == 6 + assert improper_axes[5][0] == 6 + assert improper_axes[6][0] == 6 + assert improper_axes[7][0] == 6 + assert improper_axes[8][0] == 6 + assert improper_axes[9][0] == 6 + assert improper_axes[10][0] == 6 + assert improper_axes[11][0] == 2 + assert improper_axes[12][0] == 2 + assert improper_axes[13][0] == 2 + assert improper_axes[14][0] == 2 + assert improper_axes[15][0] == 2 + assert improper_axes[16][0] == 2 + assert improper_axes[17][0] == 2 + assert improper_axes[18][0] == 2 + assert improper_axes[19][0] == 2 + assert improper_axes[20][0] == 2 + assert improper_axes[21][0] == 2 + assert improper_axes[22][0] == 2 + assert improper_axes[23][0] == 2 + assert improper_axes[24][0] == 2 + assert improper_axes[25][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] assert improper_axes[1][1] == proper_axes[1][1] assert improper_axes[2][1] == proper_axes[2][1] @@ -4142,76 +4143,76 @@ def test_can_understand_Ih_symmetry(): # noqa: N802, PLR0915 assert improper_axes[23][1] == proper_axes[23][1] assert improper_axes[24][1] == proper_axes[24][1] assert improper_axes[25][1] == proper_axes[25][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 15 # noqa: PLR2004 - assert mirror_axes[0][0] == "" # noqa: PLC1901 - assert mirror_axes[1][0] == "" # noqa: PLC1901 - assert mirror_axes[2][0] == "" # noqa: PLC1901 - assert mirror_axes[3][0] == "" # noqa: PLC1901 - assert mirror_axes[4][0] == "" # noqa: PLC1901 - assert mirror_axes[5][0] == "" # noqa: PLC1901 - assert mirror_axes[6][0] == "" # noqa: PLC1901 - assert mirror_axes[7][0] == "" # noqa: PLC1901 - assert mirror_axes[8][0] == "" # noqa: PLC1901 - assert mirror_axes[9][0] == "" # noqa: PLC1901 + assert len(mirror_axes) == 15 + assert mirror_axes[0][0] == "" + assert mirror_axes[1][0] == "" + assert mirror_axes[2][0] == "" + assert mirror_axes[3][0] == "" + assert mirror_axes[4][0] == "" + assert mirror_axes[5][0] == "" + assert mirror_axes[6][0] == "" + assert mirror_axes[7][0] == "" + assert mirror_axes[8][0] == "" + assert mirror_axes[9][0] == "" assert mirror_axes[10][0] == "v" assert mirror_axes[11][0] == "v" assert mirror_axes[12][0] == "v" assert mirror_axes[13][0] == "v" assert mirror_axes[14][0] == "v" - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "Ih" - assert coords.symmetry_number(point_group) == 60 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 60 data = datasets.logfiles["symmetries"]["C60"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([6133.59929944, 6133.81659269, 6134.15217423]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) assert len(groups) == 1 - assert len(groups[0]) == 60 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[0]) == 60 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("spheric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 - atomcoords, - groups, - axes, - rotor_class, - ) - assert len(proper_axes) == 26 # noqa: PLR2004 - assert proper_axes[0][0] == 5 # noqa: PLR2004 - assert proper_axes[1][0] == 3 # noqa: PLR2004 - assert proper_axes[2][0] == 3 # noqa: PLR2004 - assert proper_axes[3][0] == 3 # noqa: PLR2004 - assert proper_axes[4][0] == 3 # noqa: PLR2004 - assert proper_axes[5][0] == 3 # noqa: PLR2004 - assert proper_axes[6][0] == 3 # noqa: PLR2004 - assert proper_axes[7][0] == 3 # noqa: PLR2004 - assert proper_axes[8][0] == 3 # noqa: PLR2004 - assert proper_axes[9][0] == 3 # noqa: PLR2004 - assert proper_axes[10][0] == 3 # noqa: PLR2004 - assert proper_axes[11][0] == 2 # noqa: PLR2004 - assert proper_axes[12][0] == 2 # noqa: PLR2004 - assert proper_axes[13][0] == 2 # noqa: PLR2004 - assert proper_axes[14][0] == 2 # noqa: PLR2004 - assert proper_axes[15][0] == 2 # noqa: PLR2004 - assert proper_axes[16][0] == 2 # noqa: PLR2004 - assert proper_axes[17][0] == 2 # noqa: PLR2004 - assert proper_axes[18][0] == 2 # noqa: PLR2004 - assert proper_axes[19][0] == 2 # noqa: PLR2004 - assert proper_axes[20][0] == 2 # noqa: PLR2004 - assert proper_axes[21][0] == 2 # noqa: PLR2004 - assert proper_axes[22][0] == 2 # noqa: PLR2004 - assert proper_axes[23][0] == 2 # noqa: PLR2004 - assert proper_axes[24][0] == 2 # noqa: PLR2004 - assert proper_axes[25][0] == 2 # noqa: PLR2004 + proper_axes = coords._get_proper_axes( + atomcoords, + groups, + axes, + rotor_class, + ) + assert len(proper_axes) == 26 + assert proper_axes[0][0] == 5 + assert proper_axes[1][0] == 3 + assert proper_axes[2][0] == 3 + assert proper_axes[3][0] == 3 + assert proper_axes[4][0] == 3 + assert proper_axes[5][0] == 3 + assert proper_axes[6][0] == 3 + assert proper_axes[7][0] == 3 + assert proper_axes[8][0] == 3 + assert proper_axes[9][0] == 3 + assert proper_axes[10][0] == 3 + assert proper_axes[11][0] == 2 + assert proper_axes[12][0] == 2 + assert proper_axes[13][0] == 2 + assert proper_axes[14][0] == 2 + assert proper_axes[15][0] == 2 + assert proper_axes[16][0] == 2 + assert proper_axes[17][0] == 2 + assert proper_axes[18][0] == 2 + assert proper_axes[19][0] == 2 + assert proper_axes[20][0] == 2 + assert proper_axes[21][0] == 2 + assert proper_axes[22][0] == 2 + assert proper_axes[23][0] == 2 + assert proper_axes[24][0] == 2 + assert proper_axes[25][0] == 2 assert proper_axes[0][1] == pytest.approx( [-0.43323728588212457, -0.29725084310715066, -0.8508509801331712], ) @@ -4290,40 +4291,40 @@ def test_can_understand_Ih_symmetry(): # noqa: N802, PLR0915 assert proper_axes[25][1] == pytest.approx( [-0.8700854547086772, 0.38413725024405565, 0.30885251250286183], ) - improper_axes = coords._get_improper_axes( # noqa: SLF001 - atomcoords, - groups, - axes, - rotor_class, - proper_axes, - ) - assert len(improper_axes) == 26 # noqa: PLR2004 - assert improper_axes[0][0] == 10 # noqa: PLR2004 - assert improper_axes[1][0] == 6 # noqa: PLR2004 - assert improper_axes[2][0] == 6 # noqa: PLR2004 - assert improper_axes[3][0] == 6 # noqa: PLR2004 - assert improper_axes[4][0] == 6 # noqa: PLR2004 - assert improper_axes[5][0] == 6 # noqa: PLR2004 - assert improper_axes[6][0] == 6 # noqa: PLR2004 - assert improper_axes[7][0] == 6 # noqa: PLR2004 - assert improper_axes[8][0] == 6 # noqa: PLR2004 - assert improper_axes[9][0] == 6 # noqa: PLR2004 - assert improper_axes[10][0] == 6 # noqa: PLR2004 - assert improper_axes[11][0] == 2 # noqa: PLR2004 - assert improper_axes[12][0] == 2 # noqa: PLR2004 - assert improper_axes[13][0] == 2 # noqa: PLR2004 - assert improper_axes[14][0] == 2 # noqa: PLR2004 - assert improper_axes[15][0] == 2 # noqa: PLR2004 - assert improper_axes[16][0] == 2 # noqa: PLR2004 - assert improper_axes[17][0] == 2 # noqa: PLR2004 - assert improper_axes[18][0] == 2 # noqa: PLR2004 - assert improper_axes[19][0] == 2 # noqa: PLR2004 - assert improper_axes[20][0] == 2 # noqa: PLR2004 - assert improper_axes[21][0] == 2 # noqa: PLR2004 - assert improper_axes[22][0] == 2 # noqa: PLR2004 - assert improper_axes[23][0] == 2 # noqa: PLR2004 - assert improper_axes[24][0] == 2 # noqa: PLR2004 - assert improper_axes[25][0] == 2 # noqa: PLR2004 + improper_axes = coords._get_improper_axes( + atomcoords, + groups, + axes, + rotor_class, + proper_axes, + ) + assert len(improper_axes) == 26 + assert improper_axes[0][0] == 10 + assert improper_axes[1][0] == 6 + assert improper_axes[2][0] == 6 + assert improper_axes[3][0] == 6 + assert improper_axes[4][0] == 6 + assert improper_axes[5][0] == 6 + assert improper_axes[6][0] == 6 + assert improper_axes[7][0] == 6 + assert improper_axes[8][0] == 6 + assert improper_axes[9][0] == 6 + assert improper_axes[10][0] == 6 + assert improper_axes[11][0] == 2 + assert improper_axes[12][0] == 2 + assert improper_axes[13][0] == 2 + assert improper_axes[14][0] == 2 + assert improper_axes[15][0] == 2 + assert improper_axes[16][0] == 2 + assert improper_axes[17][0] == 2 + assert improper_axes[18][0] == 2 + assert improper_axes[19][0] == 2 + assert improper_axes[20][0] == 2 + assert improper_axes[21][0] == 2 + assert improper_axes[22][0] == 2 + assert improper_axes[23][0] == 2 + assert improper_axes[24][0] == 2 + assert improper_axes[25][0] == 2 assert improper_axes[0][1] == proper_axes[0][1] assert improper_axes[1][1] == proper_axes[1][1] assert improper_axes[2][1] == proper_axes[2][1] @@ -4350,24 +4351,24 @@ def test_can_understand_Ih_symmetry(): # noqa: N802, PLR0915 assert improper_axes[23][1] == proper_axes[23][1] assert improper_axes[24][1] == proper_axes[24][1] assert improper_axes[25][1] == proper_axes[25][1] - mirror_axes = coords._get_mirror_planes( # noqa: SLF001 + mirror_axes = coords._get_mirror_planes( atomcoords, groups, axes, rotor_class, proper_axes, ) - assert len(mirror_axes) == 15 # noqa: PLR2004 - assert mirror_axes[0][0] == "" # noqa: PLC1901 - assert mirror_axes[1][0] == "" # noqa: PLC1901 - assert mirror_axes[2][0] == "" # noqa: PLC1901 - assert mirror_axes[3][0] == "" # noqa: PLC1901 - assert mirror_axes[4][0] == "" # noqa: PLC1901 - assert mirror_axes[5][0] == "" # noqa: PLC1901 - assert mirror_axes[6][0] == "" # noqa: PLC1901 - assert mirror_axes[7][0] == "" # noqa: PLC1901 - assert mirror_axes[8][0] == "" # noqa: PLC1901 - assert mirror_axes[9][0] == "" # noqa: PLC1901 + assert len(mirror_axes) == 15 + assert mirror_axes[0][0] == "" + assert mirror_axes[1][0] == "" + assert mirror_axes[2][0] == "" + assert mirror_axes[3][0] == "" + assert mirror_axes[4][0] == "" + assert mirror_axes[5][0] == "" + assert mirror_axes[6][0] == "" + assert mirror_axes[7][0] == "" + assert mirror_axes[8][0] == "" + assert mirror_axes[9][0] == "" assert mirror_axes[10][0] == "v" assert mirror_axes[11][0] == "v" assert mirror_axes[12][0] == "v" @@ -4418,37 +4419,37 @@ def test_can_understand_Ih_symmetry(): # noqa: N802, PLR0915 assert mirror_axes[14][1] == pytest.approx( [-0.565929883314664, 0.8244533722328923, -6.469360643961685e-5], ) - assert coords._has_inversion_center(atomcoords, groups) # noqa: SLF001 + assert coords._has_inversion_center(atomcoords, groups) point_group = coords.find_point_group(data.atommasses, atomcoords, proper_axes) assert point_group == "Ih" - assert coords.symmetry_number(point_group) == 60 # noqa: PLR2004 + assert coords.symmetry_number(point_group) == 60 # TODO(schneiderfelipe): allocate the function below to others and delete it. -def test_match_regression_logfiles(): # noqa: PLR0915 +def test_match_regression_logfiles() -> None: """Ensure calculated values minimally match regression logfiles.""" # borane data = datasets.logfiles["symmetries"]["BH3"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([2.24732283, 2.2473566, 4.4946784]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 2 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 2 assert len(groups[0]) == 1 - assert len(groups[1]) == 3 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 3 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric oblate", "regular planar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) - assert len(proper_axes) == 4 # noqa: PLR2004 - assert proper_axes[0][0] == 3 # noqa: PLR2004 - assert proper_axes[1][0] == 2 # noqa: PLR2004 - assert proper_axes[2][0] == 2 # noqa: PLR2004 - assert proper_axes[3][0] == 2 # noqa: PLR2004 + assert len(proper_axes) == 4 + assert proper_axes[0][0] == 3 + assert proper_axes[1][0] == 2 + assert proper_axes[2][0] == 2 + assert proper_axes[3][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 0.0, 1.0]) assert proper_axes[1][1] == pytest.approx( [-0.11625570934711942, -0.9932192710921326, 0.00029929151507175205], @@ -4465,46 +4466,46 @@ def test_match_regression_logfiles(): # noqa: PLR0915 moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([3.32736206, 39.32328864, 39.32328864]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 assert len(groups[1]) == 1 - assert len(groups[2]) == 3 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[2]) == 3 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("symmetric prolate", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 3 # noqa: PLR2004 + assert proper_axes[0][0] == 3 # dichloromethane data = datasets.logfiles["symmetries"]["dichloromethane"] moments, axes, atomcoords = coords.inertia(data.atommasses, data.atomcoords) assert moments == pytest.approx([16.0098287, 161.95533621, 174.59725576]) assert axes.T @ axes == pytest.approx(np.eye(3)) - groups = coords._equivalent_atoms(data.atommasses, atomcoords) # noqa: SLF001 - assert len(groups) == 3 # noqa: PLR2004 + groups = coords._equivalent_atoms(data.atommasses, atomcoords) + assert len(groups) == 3 assert len(groups[0]) == 1 - assert len(groups[1]) == 2 # noqa: PLR2004 - assert len(groups[2]) == 2 # noqa: PLR2004 - rotor_class = coords._classify_rotor(moments) # noqa: SLF001 + assert len(groups[1]) == 2 + assert len(groups[2]) == 2 + rotor_class = coords._classify_rotor(moments) assert rotor_class == ("asymmetric", "nonplanar") - proper_axes = coords._get_proper_axes( # noqa: SLF001 + proper_axes = coords._get_proper_axes( atomcoords, groups, axes, rotor_class, ) assert len(proper_axes) == 1 - assert proper_axes[0][0] == 2 # noqa: PLR2004 + assert proper_axes[0][0] == 2 assert proper_axes[0][1] == pytest.approx([0.0, 1.0, 0.0]) -def test_can_rotate_to_principal_axes(): +def test_can_rotate_to_principal_axes() -> None: """Ensure we are able to rotate molecules to their principal axes.""" data = datasets.logfiles["symmetries"]["water"] diff --git a/tests/test_core.py b/tests/test_core.py index ff61b340..cbd6fdbc 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,13 +1,13 @@ -#!/usr/bin/env python3 # noqa: INP001, EXE001 - """Tests for core module.""" +from __future__ import annotations + import numpy as np import overreact as rx -def test_parse_works(): # noqa: PLR0915 +def test_parse_works() -> None: """Test parsing of reactions.""" scheme = rx.parse_reactions("A -> B // a direct reaction") assert scheme[0] == ("A", "B") @@ -119,51 +119,48 @@ def test_parse_works(): # noqa: PLR0915 assert np.all(np.array([[-1.0], [1.0], [0.0], [0.0]]) == scheme[4]) -def test_private_functions_work(): +def test_private_functions_work() -> None: """Ensure private functions work as expected.""" - assert list(rx.core._parse_side("A")) == [(1, "A")] # noqa: SLF001 - assert list(rx.core._parse_side("A")) == list( # noqa: SLF001 - rx.core._parse_side("1 A"), # noqa: SLF001 + assert list(rx.core._parse_side("A")) == [(1, "A")] + assert list(rx.core._parse_side("A")) == list( + rx.core._parse_side("1 A"), ) - assert list(rx.core._parse_side("A")) == list( # noqa: SLF001 - rx.core._parse_side("1A"), # noqa: SLF001 + assert list(rx.core._parse_side("A")) == list( + rx.core._parse_side("1A"), ) - assert list(rx.core._parse_side("500 A")) == [(500, "A")] # noqa: SLF001 - assert list(rx.core._parse_side("A + 2 B + 500 D")) == [ # noqa: SLF001 + assert list(rx.core._parse_side("500 A")) == [(500, "A")] + assert list(rx.core._parse_side("A + 2 B + 500 D")) == [ (1, "A"), (2, "B"), (500, "D"), ] - assert rx.core._unparse_side([(1, "A")]) == "A" # noqa: SLF001 - assert rx.core._unparse_side([(500, "A")]) == "500 A" # noqa: SLF001 - assert ( - rx.core._unparse_side([(1, "A"), (2, "B"), (500, "D")]) # noqa: SLF001 - == "A + 2 B + 500 D" # noqa: RUF100, SLF001 - ) # noqa: RUF100, SLF001 + assert rx.core._unparse_side([(1, "A")]) == "A" + assert rx.core._unparse_side([(500, "A")]) == "500 A" + assert rx.core._unparse_side([(1, "A"), (2, "B"), (500, "D")]) == "A + 2 B + 500 D" assert ( - rx.core._unparse_side( # noqa: SLF001 - rx.core._parse_side( # noqa: SLF001 + rx.core._unparse_side( + rx.core._parse_side( " 2 *A*1* + 40B1 + chlorophyll", ), ) == "2 *A*1* + 40 B1 + chlorophyll" ) - assert list(rx.core._parse_reactions("A -> B")) == [ # noqa: SLF001 + assert list(rx.core._parse_reactions("A -> B")) == [ (((1, "A"),), ((1, "B"),), False), ] - assert list(rx.core._parse_reactions("A <=> B")) == [ # noqa: SLF001 + assert list(rx.core._parse_reactions("A <=> B")) == [ (((1, "A"),), ((1, "B"),), True), (((1, "B"),), ((1, "A"),), True), ] - assert list(rx.core._parse_reactions("2 A -> B\nA -> 20B")) == [ # noqa: SLF001 + assert list(rx.core._parse_reactions("2 A -> B\nA -> 20B")) == [ (((2, "A"),), ((1, "B"),), False), (((1, "A"),), ((20, "B"),), False), ] assert list( - rx.core._parse_reactions("E + S <=> ES -> ES‡ -> E + P"), # noqa: SLF001 + rx.core._parse_reactions("E + S <=> ES -> ES‡ -> E + P"), ) == [ (((1, "E"), (1, "S")), ((1, "ES"),), True), (((1, "ES"),), ((1, "E"), (1, "S")), True), @@ -172,12 +169,12 @@ def test_private_functions_work(): ] assert list( - rx.core._unparse_reactions([(((1, "A"),), ((1, "B"),), True)]), # noqa: SLF001 + rx.core._unparse_reactions([(((1, "A"),), ((1, "B"),), True)]), ) == [ "A -> B", ] assert list( - rx.core._unparse_reactions( # noqa: SLF001 + rx.core._unparse_reactions( [ (((2, "A"),), ((3, "B"),), True), (((1, "A"),), ((2, "C"),), True), @@ -186,7 +183,7 @@ def test_private_functions_work(): ), ) == ["2 A -> 3 B", "A -> 2 C", "50 A -> D"] assert list( - rx.core._unparse_reactions( # noqa: SLF001 + rx.core._unparse_reactions( [ (((1, "E"), (1, "S")), ((1, "ES"),), True), (((1, "ES"),), ((1, "E"), (1, "S")), True), @@ -197,8 +194,8 @@ def test_private_functions_work(): ) == ["E + S -> ES", "ES -> E + S", "ES -> ES‡", "ES‡ -> E + P"] assert list( - rx.core._unparse_reactions( # noqa: SLF001 - rx.core._parse_reactions( # noqa: SLF001 + rx.core._unparse_reactions( + rx.core._parse_reactions( "1 A -> 2 B <- C <=> 40 D <- E\nA -> 2 B <=> C", ), ), diff --git a/tests/test_datasets.py b/tests/test_datasets.py index 95af2d85..3dd6b997 100644 --- a/tests/test_datasets.py +++ b/tests/test_datasets.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python3 # noqa: INP001, EXE001 - """Tests for module datasets.""" +from __future__ import annotations + import os import numpy as np @@ -11,10 +11,10 @@ from overreact import _datasets as datasets -def test_logfile_retrieval(): +def test_logfile_retrieval() -> None: """Ensure logfiles are properly lazily evaluated.""" data1 = rx.io.read_logfile( - os.path.join( # noqa: PTH118 + os.path.join( datasets.data_path, "tanaka1996", "UMP2/6-311G(2df,2pd)", @@ -29,7 +29,7 @@ def test_logfile_retrieval(): assert np.asarray(data1[key]) == pytest.approx(np.asarray(data2[key])) data1 = rx.io.read_logfile( - os.path.join( # noqa: PTH118 + os.path.join( datasets.data_path, "symmetries", "ferrocene-staggered.out", diff --git a/tests/test_io.py b/tests/test_io.py index 93ba5daa..ae8575f5 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python3 # noqa: INP001, EXE001 - """Tests for module io.""" +from __future__ import annotations + import numpy as np import pytest @@ -10,7 +10,7 @@ from overreact import coords -def test_parse_model_raises_filenotfounderror(): +def test_parse_model_raises_filenotfounderror() -> None: """Ensure parse_model raises FileNotFoundError when appropriate.""" with pytest.raises(FileNotFoundError): rx.io.parse_model("not/available") @@ -22,7 +22,7 @@ def test_parse_model_raises_filenotfounderror(): rx.io.parse_model("unreachable.jk") -def test_sanity_for_absolute_thermochemistry(): # noqa: PLR0915 +def test_sanity_for_absolute_thermochemistry() -> None: """Ensure we have decent quality for (absolute) thermochemical analysis. This partially ensures we do similar analysis as Gaussian, see @@ -66,7 +66,7 @@ def test_sanity_for_absolute_thermochemistry(): # noqa: PLR0915 7e-2, ) assert data.vibfreqs == pytest.approx(vibfreqs, 1.8) # just for sanity - zpe = rx.thermo._gas.calc_vib_energy(data.vibfreqs, temperature=0.0) # noqa: SLF001 + zpe = rx.thermo._gas.calc_vib_energy(data.vibfreqs, temperature=0.0) assert zpe == pytest.approx(204885.0, 6e-2) assert zpe / constants.kcal == pytest.approx(48.96870, 6e-2) assert zpe / (constants.hartree * constants.N_A) == pytest.approx(0.078037, 6e-2) @@ -169,7 +169,7 @@ def test_sanity_for_absolute_thermochemistry(): # noqa: PLR0915 6e-2, ) assert data.vibfreqs == pytest.approx(vibfreqs, 3e-1) - zpe = rx.thermo._gas.calc_vib_energy(data.vibfreqs, temperature=0.0) # noqa: SLF001 + zpe = rx.thermo._gas.calc_vib_energy(data.vibfreqs, temperature=0.0) assert zpe == pytest.approx(204885.0, 6e-2) assert zpe / constants.kcal == pytest.approx(48.96870, 6e-2) assert zpe / (constants.hartree * constants.N_A) == pytest.approx(0.078037, 6e-2) @@ -260,7 +260,7 @@ def test_sanity_for_absolute_thermochemistry(): # noqa: PLR0915 ) # ORCA logfile -def test_compare_rrho_with_orca_logfile(): # noqa: PLR0915 +def test_compare_rrho_with_orca_logfile() -> None: """Ensure we have decent quality for RRHO thermochemical analysis. Values from ORCA logfiles are tested. @@ -274,24 +274,24 @@ def test_compare_rrho_with_orca_logfile(): # noqa: PLR0915 symmetry_number = coords.symmetry_number( coords.find_point_group(data.atommasses, data.atomcoords), ) - assert symmetry_number == 12 # ORCA fails to find D6h symmetry! # noqa: PLR2004 + assert symmetry_number == 12 # ORCA fails to find D6h symmetry! internal_energy = rx.thermo.calc_internal_energy( energy=data.energy, degeneracy=data.mult, moments=moments, vibfreqs=data.vibfreqs, ) - zpe = rx.thermo._gas.calc_vib_energy( # noqa: SLF001 + zpe = rx.thermo._gas.calc_vib_energy( vibfreqs=data.vibfreqs, temperature=0.0, ) - elec_energy = rx.thermo._gas.calc_elec_energy( # noqa: SLF001 + elec_energy = rx.thermo._gas.calc_elec_energy( energy=data.energy, degeneracy=data.mult, ) - vib_energy = rx.thermo._gas.calc_vib_energy(vibfreqs=data.vibfreqs) # noqa: SLF001 - rot_energy = rx.thermo._gas.calc_rot_energy(moments=moments) # noqa: SLF001 - trans_energy = rx.thermo._gas.calc_trans_energy() # noqa: SLF001 + vib_energy = rx.thermo._gas.calc_vib_energy(vibfreqs=data.vibfreqs) + rot_energy = rx.thermo._gas.calc_rot_energy(moments=moments) + trans_energy = rx.thermo._gas.calc_trans_energy() enthalpy = rx.thermo.calc_enthalpy( energy=data.energy, degeneracy=data.mult, @@ -306,14 +306,14 @@ def test_compare_rrho_with_orca_logfile(): # noqa: PLR0915 symmetry_number=symmetry_number, vibfreqs=data.vibfreqs, ) - elec_entropy = rx.thermo._gas.calc_elec_entropy( # noqa: SLF001 + elec_entropy = rx.thermo._gas.calc_elec_entropy( energy=data.energy, degeneracy=data.mult, ) - vib_entropy = rx.thermo._gas.calc_vib_entropy( # noqa: SLF001 + vib_entropy = rx.thermo._gas.calc_vib_entropy( vibfreqs=data.vibfreqs, ) - rot_entropy = rx.thermo._gas.calc_rot_entropy( # noqa: SLF001 + rot_entropy = rx.thermo._gas.calc_rot_entropy( moments=moments, symmetry_number=symmetry_number, ) @@ -444,7 +444,7 @@ def test_compare_rrho_with_orca_logfile(): # noqa: PLR0915 ) # ORCA logfile -def test_compare_qrrho_with_orca_logfile(): # noqa: PLR0915 +def test_compare_qrrho_with_orca_logfile() -> None: """Ensure we have decent quality for QRRHO thermochemical analysis. Values from ORCA logfiles are tested. @@ -458,7 +458,7 @@ def test_compare_qrrho_with_orca_logfile(): # noqa: PLR0915 symmetry_number = coords.symmetry_number( coords.find_point_group(data.atommasses, data.atomcoords), ) - assert symmetry_number == 3 # noqa: PLR2004 + assert symmetry_number == 3 internal_energy = rx.thermo.calc_internal_energy( energy=data.energy, degeneracy=data.mult, @@ -466,21 +466,21 @@ def test_compare_qrrho_with_orca_logfile(): # noqa: PLR0915 vibfreqs=data.vibfreqs, qrrho=False, ) - zpe = rx.thermo._gas.calc_vib_energy( # noqa: SLF001 + zpe = rx.thermo._gas.calc_vib_energy( vibfreqs=data.vibfreqs, qrrho=False, temperature=0.0, ) - elec_energy = rx.thermo._gas.calc_elec_energy( # noqa: SLF001 + elec_energy = rx.thermo._gas.calc_elec_energy( energy=data.energy, degeneracy=data.mult, ) - vib_energy = rx.thermo._gas.calc_vib_energy( # noqa: SLF001 + vib_energy = rx.thermo._gas.calc_vib_energy( vibfreqs=data.vibfreqs, qrrho=False, ) - rot_energy = rx.thermo._gas.calc_rot_energy(moments=moments) # noqa: SLF001 - trans_energy = rx.thermo._gas.calc_trans_energy() # noqa: SLF001 + rot_energy = rx.thermo._gas.calc_rot_energy(moments=moments) + trans_energy = rx.thermo._gas.calc_trans_energy() enthalpy = rx.thermo.calc_enthalpy( energy=data.energy, degeneracy=data.mult, @@ -496,14 +496,14 @@ def test_compare_qrrho_with_orca_logfile(): # noqa: PLR0915 symmetry_number=symmetry_number, vibfreqs=data.vibfreqs, ) - elec_entropy = rx.thermo._gas.calc_elec_entropy( # noqa: SLF001 + elec_entropy = rx.thermo._gas.calc_elec_entropy( energy=data.energy, degeneracy=data.mult, ) - vib_entropy = rx.thermo._gas.calc_vib_entropy( # noqa: SLF001 + vib_entropy = rx.thermo._gas.calc_vib_entropy( vibfreqs=data.vibfreqs, ) - rot_entropy = rx.thermo._gas.calc_rot_entropy( # noqa: SLF001 + rot_entropy = rx.thermo._gas.calc_rot_entropy( moments=moments, symmetry_number=symmetry_number, ) @@ -633,7 +633,7 @@ def test_compare_qrrho_with_orca_logfile(): # noqa: PLR0915 ) # ORCA logfile -def test_read_logfile(): +def test_read_logfile() -> None: """Ensure read_logfile returns correct data.""" fields = { "logfile", @@ -651,7 +651,7 @@ def test_read_logfile(): assert set(data) == fields assert data.logfile == "data/tanaka1996/UMP2/6-311G(2df,2pd)/Cl·.out" assert data.energy == pytest.approx(-1206891740.7180765, 3e-5) - assert data.mult == 2 # noqa: PLR2004 + assert data.mult == 2 assert data.atomnos == pytest.approx(np.array([17])) assert data.atommasses == pytest.approx(np.array([35.453])) assert data.atomcoords == pytest.approx(np.array([[0.0, 0.0, 0.0]])) @@ -660,7 +660,7 @@ def test_read_logfile(): data = rx.io.read_logfile("data/symmetries/chlorobromofluoromethane.out") assert set(data) == fields assert data.logfile == "data/symmetries/chlorobromofluoromethane.out" - assert data.energy == -8327995636.7634325 # noqa: PLR2004 + assert data.energy == -8327995636.7634325 assert data.mult == 1 assert data.atomnos == pytest.approx(np.array([6, 35, 17, 9, 1])) assert data.atommasses == pytest.approx( @@ -677,7 +677,7 @@ def test_read_logfile(): ], ), ) - assert len(data.vibfreqs) == 9 # noqa: PLR2004 + assert len(data.vibfreqs) == 9 assert data.vibfreqs == pytest.approx( np.array( [ @@ -695,7 +695,7 @@ def test_read_logfile(): ) -def test_read_logfile_from_orca_xtb(): +def test_read_logfile_from_orca_xtb() -> None: """Ensure read_logfile correctly reads an XTB2 ORCA logfile.""" fields = { "logfile", @@ -710,7 +710,7 @@ def test_read_logfile_from_orca_xtb(): data = rx.io.read_logfile("data/symmetries/Xe.out") assert set(data) == fields assert data.logfile == "data/symmetries/Xe.out" - assert data.energy == -10194122.6419248 # noqa: PLR2004 + assert data.energy == -10194122.6419248 assert data.mult == 1 assert data.atomnos == pytest.approx(np.array([54])) assert data.atommasses == pytest.approx(np.array([131.293])) @@ -771,7 +771,7 @@ def test_read_logfile_from_orca_xtb(): ), abs=1e-2, ) - assert len(data.vibfreqs) == 42 # noqa: PLR2004 + assert len(data.vibfreqs) == 42 assert data.vibfreqs == pytest.approx( np.array( [ diff --git a/tests/test_misc.py b/tests/test_misc.py index 6c917b15..f34e4e38 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -1,17 +1,17 @@ -#!/usr/bin/env python3 # noqa: INP001, EXE001 - """Tests for misc module.""" +from __future__ import annotations + import numpy as np import pytest import overreact as rx -def test_broaden_spectrum_works(): +def test_broaden_spectrum_works() -> None: """Ensure we can broad a simple spectrum.""" x = np.linspace(50, 200, num=15) - s = rx._misc.broaden_spectrum(x, [150, 100], [2, 1], scale=20.0) # noqa: SLF001 + s = rx._misc.broaden_spectrum(x, [150, 100], [2, 1], scale=20.0) assert s == pytest.approx( [ 0.04316864, diff --git a/tests/test_rates.py b/tests/test_rates.py index 8563ce9e..4886ba13 100644 --- a/tests/test_rates.py +++ b/tests/test_rates.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python3 # noqa: INP001, EXE001 - """Tests for rates module.""" +from __future__ import annotations + import numpy as np import pytest @@ -9,51 +9,47 @@ from overreact import _constants as constants -def test_sanity_for_chemical_kinetics(): +def test_sanity_for_chemical_kinetics() -> None: """Ensure we have decent quality for chemical kinetics analysis. This partially ensures we do similar analysis as Gaussian, see https://gaussian.com/thermo/. """ - freeenergies_H = np.array( # noqa: N806 + freeenergies_h = np.array( [-98.579127, -454.557870, -553.109488, -98.001318, -455.146251], ) - freeenergies_D = np.array( # noqa: N806 + freeenergies_d = np.array( [-98.582608, -454.557870, -553.110424, -98.001318, -455.149092], ) scheme = rx.parse_reactions("FH + Cl -> FHCl‡ -> F + HCl") - delta_freeenergies_H = rx.thermo.get_delta(scheme.B, freeenergies_H)[ # noqa: N806 - 0 - ] # noqa: RUF100 - delta_freeenergies_D = rx.thermo.get_delta(scheme.B, freeenergies_D)[ # noqa: N806 - 0 - ] # noqa: RUF100 - assert delta_freeenergies_H == pytest.approx(0.027509) - assert delta_freeenergies_H * (constants.hartree * constants.N_A) / ( + delta_freeenergies_h = rx.thermo.get_delta(scheme.B, freeenergies_h)[0] + delta_freeenergies_d = rx.thermo.get_delta(scheme.B, freeenergies_d)[0] + assert delta_freeenergies_h == pytest.approx(0.027509) + assert delta_freeenergies_h * (constants.hartree * constants.N_A) / ( constants.kcal ) == pytest.approx(17.26, 2e-4) - assert delta_freeenergies_D == pytest.approx(0.030054) - assert delta_freeenergies_D * (constants.hartree * constants.N_A) / ( + assert delta_freeenergies_d == pytest.approx(0.030054) + assert delta_freeenergies_d * (constants.hartree * constants.N_A) / ( constants.kcal ) == pytest.approx(18.86, 5e-5) - k_H = rx.get_k( # noqa: N806 + k_h = rx.get_k( scheme, - delta_freeenergies=delta_freeenergies_H * constants.hartree * constants.N_A, + delta_freeenergies=delta_freeenergies_h * constants.hartree * constants.N_A, ) - k_D = rx.get_k( # noqa: N806 + k_d = rx.get_k( scheme, - delta_freeenergies=delta_freeenergies_D * constants.hartree * constants.N_A, + delta_freeenergies=delta_freeenergies_d * constants.hartree * constants.N_A, ) - assert k_H == pytest.approx(1.38, 4e-4) - assert k_D == pytest.approx(0.0928, 5e-3) + assert k_h == pytest.approx(1.38, 4e-4) + assert k_d == pytest.approx(0.0928, 5e-3) - kie = k_H / k_D + kie = k_h / k_d assert kie == pytest.approx(1.38 / 0.0928, 4e-3) -def test_eyring_calculates_reaction_barrier(): +def test_eyring_calculates_reaction_barrier() -> None: """Ensure Eyring rates are correct.""" barrier1 = 17.26 * constants.kcal barrier2 = 18.86 * constants.kcal @@ -81,7 +77,7 @@ def test_eyring_calculates_reaction_barrier(): ) == pytest.approx([1.38, 3.2513e9], 4e-3) -def test_smoluchowski_calculates_diffusion_limited_reaction_rates(): +def test_smoluchowski_calculates_diffusion_limited_reaction_rates() -> None: """Ensure Smoluchowski rates are correct.""" radii = np.array([2.59, 2.71]) * constants.angstrom assert rx.rates.smoluchowski( @@ -113,7 +109,7 @@ def test_smoluchowski_calculates_diffusion_limited_reaction_rates(): ) -def test_liquid_viscosities_are_correct(): +def test_liquid_viscosities_are_correct() -> None: """Ensure viscosity values agree with the literature. The following data were collected from many different sources, whose DOIs @@ -233,7 +229,7 @@ def test_liquid_viscosities_are_correct(): ) -def test_conversion_of_rate_constants_work(): +def test_conversion_of_rate_constants_work() -> None: """Ensure converting reaction rate constants work.""" assert rx.rates.convert_rate_constant( 12345e5, @@ -255,7 +251,7 @@ def test_conversion_of_rate_constants_work(): ) -def test_conversion_rates_know_about_reaction_order(): +def test_conversion_rates_know_about_reaction_order() -> None: """Ensure calculated factors satisfy the reaction order requirements.""" assert rx.rates.convert_rate_constant( 1.0, @@ -294,7 +290,7 @@ def test_conversion_rates_know_about_reaction_order(): ) -def test_second_order_conversion_rate_example(): +def test_second_order_conversion_rate_example() -> None: """Test a simple example from a set of lecture notes. The example can be found at @@ -309,7 +305,7 @@ def test_second_order_conversion_rate_example(): ) == pytest.approx(1.2e10, 4e-3) -def test_second_order_conversion_rates_match_literature(): # noqa: PLR0915 +def test_second_order_conversion_rates_match_literature() -> None: """Ensure calculated second order factors are correct. References are given in the comments. @@ -705,7 +701,7 @@ def test_second_order_conversion_rates_match_literature(): # noqa: PLR0915 ) == pytest.approx(7.34e21 / temperature, 2e-4) -def test_third_order_conversion_rates_match_literature(): +def test_third_order_conversion_rates_match_literature() -> None: """Ensure calculated third order factors are correct. References are given in the comments. diff --git a/tests/test_regressions.py b/tests/test_regressions.py index 4a6f576f..c7a0b3ca 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -1,10 +1,10 @@ -#!/usr/bin/env python3 # noqa: INP001, EXE001 - """Regressions against experimental/reference values. This also tests the high-level application programming interface. """ +from __future__ import annotations + import numpy as np import pytest from scipy import stats @@ -17,7 +17,7 @@ # values to this file. -def test_basic_example_for_solvation_equilibria(): +def test_basic_example_for_solvation_equilibria() -> None: """Reproduce literature data for AcOH(g) <=> AcOH(aq). Data is as cited in doi:10.1021/jp810292n and doi:10.1063/1.1416902, and @@ -25,9 +25,9 @@ def test_basic_example_for_solvation_equilibria(): """ model = rx.parse_model("data/acetate/Orca4/model.k") temperature = 298.15 - pK = 4.756 # doi:10.1063/1.1416902 # noqa: N806 + p_k = 4.756 # doi:10.1063/1.1416902 - acid_energy = -constants.R * temperature * np.log(10**-pK) / constants.kcal + acid_energy = -constants.R * temperature * np.log(10**-p_k) / constants.kcal solv_energy = ( -229.04018997 - -229.075245654407 @@ -76,7 +76,7 @@ def test_basic_example_for_solvation_equilibria(): # the following tests the reaction free energy from doi:10.1063/1.1416902 assert delta_freeenergies[0] == pytest.approx(27.147 * constants.kilo, 7e-3) assert delta_freeenergies[0] == pytest.approx( - -constants.R * temperature * np.log(10**-pK), + -constants.R * temperature * np.log(10**-p_k), 7e-3, ) @@ -86,10 +86,10 @@ def test_basic_example_for_solvation_equilibria(): temperature=temperature, qrrho=qrrho, ) - assert -np.log10(k[0] / k[1]) == pytest.approx(pK, 7e-3) + assert -np.log10(k[0] / k[1]) == pytest.approx(p_k, 7e-3) -def test_basic_example_for_solvation_phase_kinetics(): +def test_basic_example_for_solvation_phase_kinetics() -> None: """Reproduce literature data for NH3(w) + OH·(w) -> NH2·(w) + H2O(w). This uses raw data from from doi:10.1002/qua.25686 and no calls from @@ -157,7 +157,7 @@ def test_basic_example_for_solvation_phase_kinetics(): ) -def test_basic_example_for_gas_phase_kinetics(): +def test_basic_example_for_gas_phase_kinetics() -> None: """Reproduce literature data for CH4 + Cl⋅ -> CH3· + HCl. This uses raw data from from doi:10.1002/qua.25686 and no calls from @@ -234,7 +234,7 @@ def test_basic_example_for_gas_phase_kinetics(): ) -def test_rate_constants_for_hickel1992(): +def test_rate_constants_for_hickel1992() -> None: """Reproduce literature data for NH3(w) + OH·(w) -> NH2·(w) + H2O(w). Data is as cited in doi:10.1002/qua.25686 and is experimental except when @@ -293,11 +293,11 @@ def test_rate_constants_for_hickel1992(): assert linregress.rvalue**2 == pytest.approx(1.0, tols[2]) assert linregress.pvalue == pytest.approx(0.0, abs=tols[3]) - assert linregress.pvalue < 0.01 # noqa: PLR2004 + assert linregress.pvalue < 0.01 assert linregress.stderr == pytest.approx(0.0, abs=tols[4]) -def test_rate_constants_for_tanaka1996(): +def test_rate_constants_for_tanaka1996() -> None: """Reproduce literature data for CH4 + Cl⋅ -> CH3· + HCl. Data is as cited in doi:10.1007/BF00058703 and doi:10.1002/qua.25686 and @@ -407,11 +407,11 @@ def test_rate_constants_for_tanaka1996(): assert linregress.rvalue**2 == pytest.approx(1.0, tols[2]) assert linregress.pvalue == pytest.approx(0.0, abs=tols[3]) - assert linregress.pvalue < 0.01 # noqa: PLR2004 + assert linregress.pvalue < 0.01 assert linregress.stderr == pytest.approx(0.0, abs=tols[4]) -def test_delta_energies_for_hickel1992(): +def test_delta_energies_for_hickel1992() -> None: """Reproduce literature data for NH3(w) + OH·(w) -> NH2·(w) + H2O(w). Data is as cited in doi:10.1002/qua.25686 and is experimental except when @@ -453,7 +453,7 @@ def test_delta_energies_for_hickel1992(): # extra symmetry is required for this reaction since the transition state # is nonsymmetric - assert model.compounds["NH3·OH#(w)"].symmetry == 3 # noqa: PLR2004 + assert model.compounds["NH3·OH#(w)"].symmetry == 3 delta_freeenergies_ref = [7.9, 7.9, 8.1, 8.3, 8.5, 8.7, 8.8] assert delta_freeenergies / constants.kcal == pytest.approx( @@ -462,7 +462,7 @@ def test_delta_energies_for_hickel1992(): ) # M06-2X/6-311++G(d,p) from doi:10.1002/qua.25686 -def test_delta_energies_for_tanaka1996(): +def test_delta_energies_for_tanaka1996() -> None: """Reproduce literature data for CH4 + Cl⋅ -> CH3· + HCl. Data is as cited in doi:10.1007/BF00058703 and doi:10.1002/qua.25686 and @@ -524,7 +524,7 @@ def test_delta_energies_for_tanaka1996(): ) # UMP2/6-311G(3d,2p) from doi:10.1002/qua.25686 -def test_logfiles_for_hickel1992(): +def test_logfiles_for_hickel1992() -> None: """Reproduce literature data for NH3(w) + OH·(w) -> NH2·(w) + H2O(w). Data is as cited in doi:10.1002/qua.25686 and is experimental except when @@ -538,7 +538,7 @@ def test_logfiles_for_hickel1992(): data = datasets.logfiles["hickel1992"][f"NH3@{theory}/{basisset}"] point_group = rx.coords.find_point_group(data.atommasses, data.atomcoords) - assert rx.coords.symmetry_number(point_group) == 3 # noqa: PLR2004 + assert rx.coords.symmetry_number(point_group) == 3 assert data.vibfreqs == pytest.approx( [1022, 1691, 1691, 3506, 3577, 3577], @@ -561,7 +561,7 @@ def test_logfiles_for_hickel1992(): data = datasets.logfiles["hickel1992"][f"NH2·@{theory}/{basisset}"] point_group = rx.coords.find_point_group(data.atommasses, data.atomcoords) - assert rx.coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert rx.coords.symmetry_number(point_group) == 2 assert data.vibfreqs == pytest.approx( [1497.3, 3220.0, 3301.1], @@ -574,7 +574,7 @@ def test_logfiles_for_hickel1992(): data = datasets.logfiles["hickel1992"][f"H2O@{theory}/{basisset}"] point_group = rx.coords.find_point_group(data.atommasses, data.atomcoords) - assert rx.coords.symmetry_number(point_group) == 2 # noqa: PLR2004 + assert rx.coords.symmetry_number(point_group) == 2 assert data.vibfreqs == pytest.approx( [1594.6, 3656.7, 3755.8], @@ -593,7 +593,7 @@ def test_logfiles_for_hickel1992(): # this transition state. -def test_logfiles_for_tanaka1996(): +def test_logfiles_for_tanaka1996() -> None: """Reproduce literature data for CH4 + Cl⋅ -> CH3· + HCl. Data is as cited in doi:10.1007/BF00058703 and doi:10.1002/qua.25686 and @@ -608,7 +608,7 @@ def test_logfiles_for_tanaka1996(): # CH4 data = datasets.logfiles["tanaka1996"][f"methane@{theory}/{basisset}"] point_group = rx.coords.find_point_group(data.atommasses, data.atomcoords) - assert rx.coords.symmetry_number(point_group) == 12 # noqa: PLR2004 + assert rx.coords.symmetry_number(point_group) == 12 assert data.vibfreqs == pytest.approx( [1306, 1306, 1306, 1534, 1534, 2917, 3019, 3019, 3019], @@ -622,7 +622,7 @@ def test_logfiles_for_tanaka1996(): # CH3· data = datasets.logfiles["tanaka1996"][f"CH3·@{theory}/{basisset}"] point_group = rx.coords.find_point_group(data.atommasses, data.atomcoords) - assert rx.coords.symmetry_number(point_group) == 6 # noqa: PLR2004 + assert rx.coords.symmetry_number(point_group) == 6 assert data.vibfreqs == pytest.approx( [580, 1383, 1383, 3002, 3184, 3184], @@ -652,7 +652,7 @@ def test_logfiles_for_tanaka1996(): # CH3-H-Cl data = datasets.logfiles["tanaka1996"][f"H3CHCl‡@{theory}/{basisset}"] point_group = rx.coords.find_point_group(data.atommasses, data.atomcoords) - assert rx.coords.symmetry_number(point_group) == 3 # noqa: PLR2004 + assert rx.coords.symmetry_number(point_group) == 3 # NOTE(schneiderfelipe): vibrations are from an UMP2/6-311G(3d,2p) # calculation, see the reference in doi:10.1007/BF00058703 diff --git a/tests/test_simulate.py b/tests/test_simulate.py index a34e91f2..8acce270 100644 --- a/tests/test_simulate.py +++ b/tests/test_simulate.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python3 # noqa: INP001, EXE001 - """Tests for simulate module.""" +from __future__ import annotations + import numpy as np import pytest @@ -9,7 +9,7 @@ from overreact import simulate -def test_get_dydt_calculates_reaction_rate(): +def test_get_dydt_calculates_reaction_rate() -> None: """Ensure get_dydt gives correct reaction rates.""" scheme = rx.Scheme( compounds=["A", "B"], @@ -30,7 +30,7 @@ def test_get_dydt_calculates_reaction_rate(): assert dydt(0.0, np.array([10.0, 0.0])) == pytest.approx([-20.0, 20.0]) -def test_get_y_propagates_reaction_automatically(): +def test_get_y_propagates_reaction_automatically() -> None: """Ensure get_y properly propagates reactions with automatic time span.""" scheme = rx.Scheme( compounds=["A", "B", "AB4"], @@ -45,8 +45,8 @@ def test_get_y_propagates_reaction_automatically(): k = np.array([1.0, 1.0]) y, r = simulate.get_y(simulate.get_dydt(scheme, k), y0=y0) - assert y.t_min == 0.0 # noqa: PLR2004 - assert y.t_max >= 300.0 # noqa: PLR2004 + assert y.t_min == 0.0 + assert y.t_max >= 300.0 assert y(y.t_min) == pytest.approx(y0) assert y(y.t_max) == pytest.approx( [1.668212890625, 0.6728515625, 0.341787109375], @@ -56,7 +56,7 @@ def test_get_y_propagates_reaction_automatically(): assert r(y.t_max) == pytest.approx([0.0, 0.0, 0.0], abs=3e-3) -def test_get_y_propagates_reaction_with_fixed_time(): +def test_get_y_propagates_reaction_with_fixed_time() -> None: """Ensure get_y properly propagates reactions when given time span.""" scheme = rx.Scheme( compounds=["A", "B", "AB4"], @@ -87,7 +87,7 @@ def test_get_y_propagates_reaction_with_fixed_time(): assert r(y.t_max) == pytest.approx([0.0, 0.0, 0.0], abs=1.3e-2) -def test_get_y_conservation_in_equilibria(): +def test_get_y_conservation_in_equilibria() -> None: """Ensure get_y properly conserves matter in a toy equilibrium.""" scheme = rx.parse_reactions("A <=> B") y0 = [1, 0] @@ -97,8 +97,8 @@ def test_get_y_conservation_in_equilibria(): y, r = simulate.get_y(simulate.get_dydt(scheme, k), y0=y0) t = np.linspace(y.t_min, y.t_max, num=100) - assert y.t_min == 0.0 # noqa: PLR2004 - assert y.t_max >= 3.0 # noqa: PLR2004 + assert y.t_min == 0.0 + assert y.t_max >= 3.0 assert y(y.t_min) == pytest.approx(y0) assert y(y.t_max) == pytest.approx([0.5, 0.5], 3e-3) assert r(y.t_min) == pytest.approx([-1, 1]) @@ -121,7 +121,13 @@ def test_get_y_conservation_in_equilibria(): for method in ("RK23", "LSODA") ], ) -def test_simple_michaelis_menten(cat0, sub0, keq, kcat, method): +def test_simple_michaelis_menten( + cat0: float, + sub0: float, + keq: float, + kcat: float, + method: str, +) -> None: """ Test a simple Michaelis-Menten model. @@ -163,7 +169,13 @@ def test_simple_michaelis_menten(cat0, sub0, keq, kcat, method): for method in ("RK23", "LSODA") ], ) -def test_consuming_michaelis_menten(cat0, sub0, keq, kcat, method): +def test_consuming_michaelis_menten( + cat0: float, + sub0: float, + keq: float, + kcat: float, + method: str, +) -> None: """Test a faulty system as suggested by @bmounssefjr.""" scheme = rx.parse_reactions( """ diff --git a/tests/test_thermo_gas.py b/tests/test_thermo_gas.py index e92ae1ae..47c25df0 100644 --- a/tests/test_thermo_gas.py +++ b/tests/test_thermo_gas.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python3 # noqa: INP001, EXE001 - """Tests for gas phase using the `thermo` module.""" +from __future__ import annotations + import numpy as np import pytest from scipy.special import factorial @@ -23,7 +23,7 @@ # so on. -def test_sanity_for_relative_thermochemistry(): +def test_sanity_for_relative_thermochemistry() -> None: """Ensure we have decent quality for (relative) thermochemical analysis. This partially ensures we do similar analysis as Gaussian, see @@ -48,7 +48,7 @@ def test_sanity_for_relative_thermochemistry(): ) == pytest.approx(11.18, 9e-4) -def test_sanity_for_absolute_thermochemistry(): +def test_sanity_for_absolute_thermochemistry() -> None: """Ensure we have decent quality for (absolute) thermochemical analysis. This partially ensures we do similar analysis as Gaussian, see @@ -59,7 +59,7 @@ def test_sanity_for_absolute_thermochemistry(): * constants.atomic_mass * constants.bohr**2 ) - assert rx.thermo._gas._rotational_temperature( # noqa: SLF001 + assert rx.thermo._gas._rotational_temperature( moments / (constants.atomic_mass * constants.angstrom**2), ) == pytest.approx([3.67381, 0.98044, 0.98043], 2e-5) assert ( @@ -89,22 +89,22 @@ def test_sanity_for_absolute_thermochemistry(): ], ) vibfreqs = vibtemps * constants.k * constants.centi / (constants.h * constants.c) - assert rx.thermo._gas._vibrational_temperature( # noqa: SLF001 + assert rx.thermo._gas._vibrational_temperature( vibfreqs, ) == pytest.approx( vibtemps, ) - zpe = rx.thermo._gas.calc_vib_energy(vibfreqs, temperature=0.0) # noqa: SLF001 + zpe = rx.thermo._gas.calc_vib_energy(vibfreqs, temperature=0.0) assert zpe == pytest.approx(204885.0, 7e-5) assert zpe / constants.kcal == pytest.approx(48.96870, 7e-5) assert zpe / (constants.hartree * constants.N_A) == pytest.approx(0.078037, 8e-5) - elec_internal_energy = rx.thermo._gas.calc_elec_energy(0.0, 1.0) # noqa: SLF001 - trans_internal_energy = rx.thermo._gas.calc_trans_energy() # noqa: SLF001 - rot_internal_energy = rx.thermo._gas.calc_rot_energy( # noqa: SLF001 + elec_internal_energy = rx.thermo._gas.calc_elec_energy(0.0, 1.0) + trans_internal_energy = rx.thermo._gas.calc_trans_energy() + rot_internal_energy = rx.thermo._gas.calc_rot_energy( moments / (constants.atomic_mass * constants.angstrom**2), ) - vib_internal_energy = rx.thermo._gas.calc_vib_energy(vibfreqs) # noqa: SLF001 + vib_internal_energy = rx.thermo._gas.calc_vib_energy(vibfreqs) internal_energy = rx.thermo.calc_internal_energy( 0.0, 1.0, @@ -133,12 +133,12 @@ def test_sanity_for_absolute_thermochemistry(): 1.00783, 1.00783, ] - elec_entropy = rx.thermo._gas.calc_elec_entropy(0.0, 1.0) # noqa: SLF001 + elec_entropy = rx.thermo._gas.calc_elec_entropy(0.0, 1.0) trans_entropy = rx.thermo.calc_trans_entropy(atommasses) - rot_entropy = rx.thermo._gas.calc_rot_entropy( # noqa: SLF001 + rot_entropy = rx.thermo._gas.calc_rot_entropy( moments=moments / (constants.atomic_mass * constants.angstrom**2), ) - vib_entropy = rx.thermo._gas.calc_vib_entropy(vibfreqs) # noqa: SLF001 + vib_entropy = rx.thermo._gas.calc_vib_entropy(vibfreqs) entropy = rx.thermo.calc_entropy( atommasses, energy=0.0, @@ -156,7 +156,7 @@ def test_sanity_for_absolute_thermochemistry(): assert entropy / constants.calorie == pytest.approx(57.118, 3e-5) -def test_enthalpy_ideal_gases(): # noqa: PLR0915 +def test_enthalpy_ideal_gases() -> None: """Calculate enthalpy of some ideal gases. We only check whether enthalpy matches the correct relationship with internal energy @@ -319,7 +319,7 @@ def test_enthalpy_ideal_gases(): # noqa: PLR0915 assert enthalpy - internal_energy == pytest.approx(constants.R * temperature) -def test_entropy_ideal_monoatomic_gases(): +def test_entropy_ideal_monoatomic_gases() -> None: """Reproduce experimental entropies of some ideal monoatomic gases. Reference experimental data is from Table 5-3 of Statistical @@ -409,7 +409,7 @@ def test_entropy_ideal_monoatomic_gases(): ) / constants.calorie == pytest.approx(41.8, 1e-3) -def test_internal_energy_ideal_monoatomic_gases(): +def test_internal_energy_ideal_monoatomic_gases() -> None: """Calculate internal energies of some ideal monoatomic gases. Atomic energy states are from the NIST atomic data @@ -474,7 +474,7 @@ def test_internal_energy_ideal_monoatomic_gases(): ) -def test_entropy_ideal_diatomic_gases(): +def test_entropy_ideal_diatomic_gases() -> None: """Reproduce experimental entropies of some ideal diatomic gases. Reference experimental data is from Table 6-3 of Statistical @@ -594,7 +594,7 @@ def test_entropy_ideal_diatomic_gases(): ) -def test_internal_energy_ideal_diatomic_gases(): +def test_internal_energy_ideal_diatomic_gases() -> None: """Calculate internal energies of some ideal diatomic gases. Vibrational and rotational temperatures are from Table 6-1 of Statistical @@ -694,7 +694,7 @@ def test_internal_energy_ideal_diatomic_gases(): ) == pytest.approx(19090.38, 4e-6) -def test_entropy_ideal_polyatomic_gases(): +def test_entropy_ideal_polyatomic_gases() -> None: """Reproduce experimental entropies of some ideal polyatomic gases. Reference experimental data is from Table 8-3 of Statistical @@ -874,7 +874,7 @@ def test_entropy_ideal_polyatomic_gases(): ) / constants.calorie == pytest.approx(64.4, 1e-2) -def test_internal_energy_ideal_polyatomic_gases(): +def test_internal_energy_ideal_polyatomic_gases() -> None: """Calculate internal energies of some ideal polyatomic gases. Vibrational and rotational temperatures are from Table 8-1 of Statistical @@ -1027,7 +1027,7 @@ def test_internal_energy_ideal_polyatomic_gases(): ) == pytest.approx(267700.49, 2e-4) -def test_heat_capacity_ideal_gases(): +def test_heat_capacity_ideal_gases() -> None: """Calculate heat capacities of some ideal monoatomic gases. Reference data is from Table 8-2 of Statistical Thermodynamics, McQuarrie. @@ -1129,7 +1129,7 @@ def test_heat_capacity_ideal_gases(): ) / constants.R == pytest.approx(3.03, 1e-3) -def test_get_delta_works(): +def test_get_delta_works() -> None: """Ensure safe usage of get_delta.""" assert rx.thermo.get_delta([-1, 2], [-5.0, 5.0]) == pytest.approx(15.0) assert rx.thermo.get_delta([[-1, -1], [2, 1]], [-5.0, 5.0]) == pytest.approx( @@ -1137,16 +1137,14 @@ def test_get_delta_works(): ) -def test_equilibrium_constant_works(): +def test_equilibrium_constant_works() -> None: """Ensure equilibrium_constant gives correct numbers.""" - assert rx.thermo.equilibrium_constant(0.0) == 1.0 # noqa: PLR2004 + assert rx.thermo.equilibrium_constant(0.0) == 1.0 assert rx.thermo.equilibrium_constant(1000.0) == pytest.approx(0.668, 1e-4) assert rx.thermo.equilibrium_constant(1718.5) == pytest.approx(0.5, 1e-4) assert rx.thermo.equilibrium_constant(68497.0) == pytest.approx(0.0) - assert ( - rx.thermo.equilibrium_constant(0.0, temperature=14.01) == 1.0 # noqa: PLR2004 - ) # noqa: PLR2004, RUF100 + assert rx.thermo.equilibrium_constant(0.0, temperature=14.01) == 1.0 assert rx.thermo.equilibrium_constant(1000.0, temperature=14.01) == pytest.approx( 1.87e-4, 1e-3, @@ -1175,7 +1173,7 @@ def test_equilibrium_constant_works(): ) == pytest.approx([2.65e-5, 4.30e-3, 1.39e3, 1.04e5, 1.14e-7], 1.55e-2) -def test_molar_volume_is_precise(): +def test_molar_volume_is_precise() -> None: """Ensure our molar volumes are as precise as possible. Values below were taken from @@ -1195,7 +1193,7 @@ def test_molar_volume_is_precise(): assert rx.thermo.molar_volume() == pytest.approx(0.024465, 1e-4) -def test_molar_volume_works_with_sequences(): +def test_molar_volume_works_with_sequences() -> None: """Ensure molar volumes can be calculated for many temperatures at once.""" assert rx.thermo.molar_volume([273.15, 298.15], constants.bar) == pytest.approx( [0.02271098038, 0.02478959842], @@ -1211,7 +1209,7 @@ def test_molar_volume_works_with_sequences(): ) == pytest.approx([0.022414, 0.02271098038], 1e-5) -def test_change_reference_state_works_for_symmetry(): +def test_change_reference_state_works_for_symmetry() -> None: """Ensure that change_reference_state works for symmetry contributions.""" assert -200.0 * rx.change_reference_state(4, 1, temperature=200.0) / ( constants.kcal @@ -1239,46 +1237,46 @@ def test_change_reference_state_works_for_symmetry(): # file. # TODO(schneiderfelipe): test and compare solutions to small imaginary # frequencies using the QRRHO model. -def test_head_gordon_damping(): +def test_head_gordon_damping() -> None: """Ensure the Head-Gordon damping for the treatment of QRRHO is done correctly.""" - assert rx.thermo._gas._head_gordon_damping(-70.0) == pytest.approx( # noqa: SLF001 + assert rx.thermo._gas._head_gordon_damping(-70.0) == pytest.approx( [], ) - assert rx.thermo._gas._head_gordon_damping(-40.0) == pytest.approx( # noqa: SLF001 - rx.thermo._gas._head_gordon_damping(40.0), # noqa: SLF001 + assert rx.thermo._gas._head_gordon_damping(-40.0) == pytest.approx( + rx.thermo._gas._head_gordon_damping(40.0), ) - assert rx.thermo._gas._head_gordon_damping(-10.0) == pytest.approx( # noqa: SLF001 - rx.thermo._gas._head_gordon_damping(10.0), # noqa: SLF001 + assert rx.thermo._gas._head_gordon_damping(-10.0) == pytest.approx( + rx.thermo._gas._head_gordon_damping(10.0), ) - assert rx.thermo._gas._head_gordon_damping(1.0) == pytest.approx( # noqa: SLF001 + assert rx.thermo._gas._head_gordon_damping(1.0) == pytest.approx( 8.67669882e-9, ) - assert rx.thermo._gas._head_gordon_damping(10.0) == pytest.approx( # noqa: SLF001 + assert rx.thermo._gas._head_gordon_damping(10.0) == pytest.approx( 8.67594611e-5, ) - assert rx.thermo._gas._head_gordon_damping(100.0) == pytest.approx( # noqa: SLF001 + assert rx.thermo._gas._head_gordon_damping(100.0) == pytest.approx( 0.5, 8e-2, ) - assert rx.thermo._gas._head_gordon_damping(200.0) == pytest.approx( # noqa: SLF001 + assert rx.thermo._gas._head_gordon_damping(200.0) == pytest.approx( 1.0, 7e-2, ) - assert rx.thermo._gas._head_gordon_damping(300.0) == pytest.approx( # noqa: SLF001 + assert rx.thermo._gas._head_gordon_damping(300.0) == pytest.approx( 1.0, 2e-2, ) - assert rx.thermo._gas._head_gordon_damping(1000.0) == pytest.approx( # noqa: SLF001 + assert rx.thermo._gas._head_gordon_damping(1000.0) == pytest.approx( 1.0, 2e-4, ) - assert rx.thermo._gas._head_gordon_damping( # noqa: SLF001 + assert rx.thermo._gas._head_gordon_damping( [-70.0, -10.0, 10.0, 100.0, 200.0, 300.0, 1000.0], ) == pytest.approx([8.67594611e-5, 8.67594611e-5, 0.5, 1.0, 1.0, 1.0], 8e-2) -def test_can_calculate_reaction_entropies(): +def test_can_calculate_reaction_entropies() -> None: """Ensure we can calculate reaction translational entropies. This contribution is due to indistinguishability of some reactants or diff --git a/tests/test_thermo_solv.py b/tests/test_thermo_solv.py index abee56b3..616d8fc6 100644 --- a/tests/test_thermo_solv.py +++ b/tests/test_thermo_solv.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python3 # noqa: INP001, EXE001 - """Tests for solvation using the `thermo` module.""" +from __future__ import annotations + import pytest import overreact as rx @@ -10,7 +10,7 @@ from overreact import coords -def test_entropy_liquid_phase(): +def test_entropy_liquid_phase() -> None: """Validate selected values from Table 1 of doi:10.1021/acs.jctc.9b00214. Experimental values are actually used as reference. @@ -159,7 +159,7 @@ def test_entropy_liquid_phase(): ) -def test_translational_entropy_liquid_phase(): # noqa: PLR0915 +def test_translational_entropy_liquid_phase() -> None: """Validate calculated volumes from Table S3 of doi:10.1039/C9CP03226F. The original data seems to have errors, some severe. I *assumed* this is @@ -177,10 +177,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(30.93, 8e-2) assert vdw_volume == pytest.approx(19.16, 8e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -214,10 +214,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(55.28, 7e-2) assert vdw_volume == pytest.approx(36.64, 8e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -254,9 +254,9 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert vdw_volume == pytest.approx(53.66, 8e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -293,9 +293,9 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(100.25, 7e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -332,10 +332,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(100.50, 7e-2) assert vdw_volume == pytest.approx(69.95, 8e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -372,10 +372,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(123.34, 7e-2) assert vdw_volume == pytest.approx(87.13, 8e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -412,10 +412,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(122.05, 6e-2) assert vdw_volume == pytest.approx(86.83, 8e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -452,10 +452,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.2550 # noqa: PLR2004 + assert err < 0.2550 assert cav_volume == pytest.approx(122.17, 7e-2) assert vdw_volume == pytest.approx(86.83, 8e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -492,10 +492,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(59.41, 5e-2) assert vdw_volume == pytest.approx(39.04, 4e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -532,10 +532,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(82.32, 5e-2) assert vdw_volume == pytest.approx(55.00, 4e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -572,10 +572,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(68.88, 5e-2) assert vdw_volume == pytest.approx(45.26, 4e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -612,10 +612,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(77.29, 5e-2) assert vdw_volume == pytest.approx(51.53, 4e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -652,10 +652,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(94.20, 6e-2) assert vdw_volume == pytest.approx(65.29, 7e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -688,10 +688,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(104.64, 5e-2) assert vdw_volume == pytest.approx(71.19, 4e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -724,10 +724,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(108.71, 7e-2) assert vdw_volume == pytest.approx(76.59, 6e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -764,10 +764,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(118.78, 5e-2) assert vdw_volume == pytest.approx(83.36, 4e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -804,10 +804,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(128.54, 5e-2) assert vdw_volume == pytest.approx(84.22, 2e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -844,10 +844,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(134.53, 8e-2) assert vdw_volume == pytest.approx(95.84, 9e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -886,7 +886,7 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 ) assert cav_volume == pytest.approx(156.61, 8e-2) assert vdw_volume == pytest.approx(112.34, 9e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -923,10 +923,10 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 full_output=True, method="izato", ) - assert err < 0.263 # noqa: PLR2004 + assert err < 0.263 assert cav_volume == pytest.approx(138.74, 7e-2) assert vdw_volume == pytest.approx(100.50, 7e-2) - free_volume = rx.thermo._solv.molar_free_volume( # noqa: SLF001 + free_volume = rx.thermo._solv.molar_free_volume( data.atomnos, data.atomcoords, method="izato", @@ -956,7 +956,7 @@ def test_translational_entropy_liquid_phase(): # noqa: PLR0915 ) == pytest.approx(59.83, 1e-2) -def test_sackur_tetrode_given_free_volumes(): +def test_sackur_tetrode_given_free_volumes() -> None: """Reproduce calculated values from Table S3 of doi:10.1039/C9CP03226F. The original data seems to have errors, some severe. I assumed this is due @@ -964,127 +964,127 @@ def test_sackur_tetrode_given_free_volumes(): each entry accordingly. """ # H2O - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 18.01, 0.0993e-30 * constants.N_A, ) == pytest.approx(37.36, 1e-4) # CH3OH - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 32.04, 0.116e-30 * constants.N_A, ) == pytest.approx(45.85, 1e-3) # C2H5OH - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 46.05, 0.125e-30 * constants.N_A, ) == pytest.approx(51.01, 1e-3) # 1-C3H7OH - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 60.06, 0.144e-30 * constants.N_A, ) == pytest.approx(55.70, 1e-2) # 2-C3H7OH - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 60.06, 0.148e-30 * constants.N_A, ) == pytest.approx(46.81, 1.9e-1) # 1-C4H9OH - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 74.07, 0.161e-30 * constants.N_A, ) == pytest.approx(59.90, 5e-2) # 2-C4H9OH - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 74.07, 0.151e-30 * constants.N_A, ) == pytest.approx(51.64, 1.4e-1) # i-C4H9OH - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 74.07, 0.152e-30 * constants.N_A, ) == pytest.approx(58.71, 1e-2) # HCOOH - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 46.01, 0.133e-30 * constants.N_A, ) == pytest.approx(51.45, 1e-3) # CH3COOH - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 60.02, 0.164e-30 * constants.N_A, ) == pytest.approx(56.52, 1e-3) # CH3CN - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 41.03, 0.153e-30 * constants.N_A, ) == pytest.approx(51.25, 1e-3) # CH3NO2 - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 61.02, 0.156e-30 * constants.N_A, ) == pytest.approx(56.34, 1e-4) # Acetone - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 58.04, 0.143e-30 * constants.N_A, ) == pytest.approx(55.01, 1e-3) # DMSO - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 78.01, 0.183e-30 * constants.N_A, ) == pytest.approx(60.73, 1e-4) # THF - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 72.06, 0.145e-30 * constants.N_A, ) == pytest.approx(57.82, 1e-3) # Benzene - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 78.05, 0.164e-30 * constants.N_A, ) == pytest.approx(74.42, 2e-1) # CCl4 - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 151.88, 0.292e-30 * constants.N_A, ) == pytest.approx(61.39, 1.9e-1) # C5H12 - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 72.09, 0.164e-30 * constants.N_A, ) == pytest.approx(58.84, 1e-3) # C6H14 - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 87.12, 0.180e-30 * constants.N_A, ) == pytest.approx(61.98, 1e-3) # cyc-C6H12 - assert rx.thermo._gas._sackur_tetrode( # noqa: SLF001 + assert rx.thermo._gas._sackur_tetrode( 84.09, 0.147e-30 * constants.N_A, ) == pytest.approx(59.83, 1e-3) -def test_change_reference_state_works_for_gas_to_liquid_standard_states(): +def test_change_reference_state_works_for_gas_to_liquid_standard_states() -> None: """Ensure change_reference_state works for gas to solv. state change.""" # different reference temperatures assert 200.0 * rx.change_reference_state(temperature=200.0) / ( diff --git a/tests/test_tunnel.py b/tests/test_tunnel.py index 95866c1c..8da34890 100644 --- a/tests/test_tunnel.py +++ b/tests/test_tunnel.py @@ -1,15 +1,15 @@ -#!/usr/bin/env python3 # noqa: INP001, EXE001 - """Tests for tunnel module.""" +from __future__ import annotations + import pytest import overreact as rx -def test_wigner_tunneling_corrections_are_correct(): +def test_wigner_tunneling_corrections_are_correct() -> None: """Ensure Wigner tunneling values are correct.""" - with pytest.raises(ValueError): # noqa: PT011 + with pytest.raises(ValueError, match="vibfreq should not be zero for tunneling"): rx.tunnel.wigner(0.0) assert rx.tunnel.wigner(0.1) == pytest.approx(1.0, 1e-8) @@ -25,12 +25,12 @@ def test_wigner_tunneling_corrections_are_correct(): ) -def test_eckart_tunneling_corrections_are_correct(): +def test_eckart_tunneling_corrections_are_correct() -> None: """Ensure Eckart tunneling values are correct.""" - with pytest.raises(ValueError): # noqa: PT011 + with pytest.raises(ValueError, match="vibfreq should not be zero for tunneling"): rx.tunnel.eckart(0.0, 15781.6) - with pytest.raises(ValueError): # noqa: PT011 + with pytest.raises(ValueError, match="vibfreq should not be zero for tunneling"): rx.tunnel.eckart(0.0, 56813.61, 94689.35) # values below are at the lower limit for which Eckart is computable @@ -46,15 +46,15 @@ def test_eckart_tunneling_corrections_are_correct(): assert rx.tunnel.eckart(2486.7, 56813.61, 94689.35) == pytest.approx(3920, 1e-4) -def test_eckart_is_symmetric(): +def test_eckart_is_symmetric() -> None: """Ensure Eckart has symmetry under interchange of H1 and H2.""" vibfreq = 3e3 - H1 = 1e4 # noqa: N806 - H2 = 10 * H1 # noqa: N806 - assert rx.tunnel.eckart(vibfreq, H1, H2) == rx.tunnel.eckart(vibfreq, H2, H1) + h1 = 1e4 + h2 = 10 * h1 + assert rx.tunnel.eckart(vibfreq, h1, h2) == rx.tunnel.eckart(vibfreq, h2, h1) -def test_low_level_eckart_against_johnston1962(): # noqa: C901, PLR0912, PLR0915 +def test_low_level_eckart_against_johnston1962() -> None: """Reproduce all values from Table 1 of doi:10.1021/j100809a040.""" us = [2, 3, 4, 5, 6, 8, 10, 12, 16] # columns @@ -67,84 +67,84 @@ def test_low_level_eckart_against_johnston1962(): # noqa: C901, PLR0912, PLR091 gammas = [1.16, 1.25, 1.34, 1.44, 1.55, 1.80, 2.09, 2.42, 3.26] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 0.5) == pytest.approx(gamma, 2e-2) # noqa: SLF001 + assert rx.tunnel._eckart(u, 0.5) == pytest.approx(gamma, 2e-2) gammas = [1.13, 1.21, 1.29, 1.38, 1.47, 1.68, 1.93, 2.22, 2.94] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 0.5, 1) == pytest.approx( # noqa: SLF001 + assert rx.tunnel._eckart(u, 0.5, 1) == pytest.approx( gamma, 2e-2, ) gammas = [1.09, 1.14, 1.20, 1.27, 1.34, 1.51, 1.71, 1.94, 2.53] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 0.5, 2) == pytest.approx( # noqa: SLF001 + assert rx.tunnel._eckart(u, 0.5, 2) == pytest.approx( gamma, 9e-3, ) gammas = [1.04, 1.07, 1.11, 1.16, 1.22, 1.35, 1.50, 1.69, 2.16] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 0.5, 4) == pytest.approx( # noqa: SLF001 + assert rx.tunnel._eckart(u, 0.5, 4) == pytest.approx( gamma, 1e-2, ) gammas = [0.99, 1.00, 1.03, 1.06, 1.11, 1.21, 1.34, 1.49, 1.88] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 0.5, 8) == pytest.approx( # noqa: SLF001 + assert rx.tunnel._eckart(u, 0.5, 8) == pytest.approx( gamma, 9e-3, ) gammas = [0.96, 0.97, 0.99, 1.02, 1.06, 1.15, 1.26, 1.40, 1.76] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 0.5, 12) == pytest.approx( # noqa: SLF001 + assert rx.tunnel._eckart(u, 0.5, 12) == pytest.approx( gamma, 8e-3, ) gammas = [0.94, 0.95, 0.97, 0.99, 1.02, 1.11, 1.22, 1.35, 1.68] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 0.5, 16) == pytest.approx( # noqa: SLF001 + assert rx.tunnel._eckart(u, 0.5, 16) == pytest.approx( gamma, 8e-3, ) gammas = [0.93, 0.94, 0.95, 0.97, 1.00, 1.08, 1.19, 1.31, 1.64] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 0.5, 20) == pytest.approx( # noqa: SLF001 + assert rx.tunnel._eckart(u, 0.5, 20) == pytest.approx( gamma, 1e-2, ) gammas = [1.27, 1.43, 1.62, 1.83, 2.09, 2.72, 3.56, 4.68, 8.19] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 1) == pytest.approx(gamma, 2e-2) # noqa: SLF001 + assert rx.tunnel._eckart(u, 1) == pytest.approx(gamma, 2e-2) gammas = [1.21, 1.35, 1.51, 1.71, 1.93, 2.50, 3.26, 4.28, 7.48] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 1, 2) == pytest.approx(gamma, 6e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 1, 2) == pytest.approx(gamma, 6e-3) gammas = [1.14, 1.24, 1.37, 1.53, 1.71, 2.16, 2.78, 3.60, 6.16] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 1, 4) == pytest.approx(gamma, 5e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 1, 4) == pytest.approx(gamma, 5e-3) gammas = [1.08, 1.16, 1.26, 1.39, 1.54, 1.92, 2.43, 3.12, 5.25] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 1, 8) == pytest.approx(gamma, 5e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 1, 8) == pytest.approx(gamma, 5e-3) gammas = [1.06, 1.12, 1.21, 1.33, 1.46, 1.81, 2.28, 2.91, 4.88] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 1, 12) == pytest.approx(gamma, 9e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 1, 12) == pytest.approx(gamma, 9e-3) gammas = [1.04, 1.10, 1.18, 1.29, 1.42, 1.75, 2.20, 2.80, 4.66] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 1, 16) == pytest.approx(gamma, 5e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 1, 16) == pytest.approx(gamma, 5e-3) gammas = [1.03, 1.08, 1.16, 1.26, 1.39, 1.70, 2.14, 2.72, 4.52] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 1, 20) == pytest.approx(gamma, 7e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 1, 20) == pytest.approx(gamma, 7e-3) # The next examples are not in the imaginary region anymore and our # precision is improved. I believe that here are the most important cases @@ -153,47 +153,47 @@ def test_low_level_eckart_against_johnston1962(): # noqa: C901, PLR0912, PLR091 gammas = [1.32, 1.58, 1.91, 2.34, 2.90, 4.55, 7.34, 12.1, 34.0] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 2) == pytest.approx(gamma, 4e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 2) == pytest.approx(gamma, 4e-3) gammas = [1.26, 1.47, 1.77, 2.16, 2.66, 4.20, 6.85, 11.4, 33.4] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 2, 4) == pytest.approx(gamma, 5e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 2, 4) == pytest.approx(gamma, 5e-3) gammas = [1.19, 1.36, 1.61, 1.93, 2.36, 3.65, 5.87, 9.69, 28.0] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 2, 8) == pytest.approx(gamma, 4e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 2, 8) == pytest.approx(gamma, 4e-3) gammas = [1.16, 1.32, 1.54, 1.84, 2.23, 3.41, 5.44, 8.94, 25.6] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 2, 12) == pytest.approx(gamma, 5e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 2, 12) == pytest.approx(gamma, 5e-3) gammas = [1.14, 1.29, 1.50, 1.78, 2.15, 3.27, 5.20, 8.51, 24.2] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 2, 16) == pytest.approx(gamma, 4e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 2, 16) == pytest.approx(gamma, 4e-3) gammas = [1.12, 1.27, 1.47, 1.74, 2.10, 3.18, 5.03, 8.22, 23.3] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 2, 20) == pytest.approx(gamma, 4e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 2, 20) == pytest.approx(gamma, 4e-3) gammas = [1.30, 1.58, 2.02, 2.69, 3.69, 7.60, 17.3, 42.4, 304] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 4, 4) == pytest.approx(gamma, 8e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 4, 4) == pytest.approx(gamma, 8e-3) gammas = [1.25, 1.51, 1.93, 2.56, 3.56, 7.57, 18.0, 46.7, 376] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 4, 8) == pytest.approx(gamma, 5e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 4, 8) == pytest.approx(gamma, 5e-3) gammas = [1.22, 1.47, 1.86, 2.46, 3.39, 7.16, 17.0, 44.0, 354] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 4, 12) == pytest.approx(gamma, 3e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 4, 12) == pytest.approx(gamma, 3e-3) gammas = [1.20, 1.44, 1.81, 2.39, 3.28, 6.88, 16.2, 41.9, 335] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 4, 16) == pytest.approx(gamma, 3e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 4, 16) == pytest.approx(gamma, 3e-3) gammas = [1.19, 1.42, 1.78, 2.34, 3.20, 6.68, 15.7, 40.3, 321] for u, gamma in zip(us, gammas): - assert rx.tunnel._eckart(u, 4, 20) == pytest.approx(gamma, 2e-3) # noqa: SLF001 + assert rx.tunnel._eckart(u, 4, 20) == pytest.approx(gamma, 2e-3) # The examples below have larger tunneling corrections and the precision of # our implementation is again reduced, but we still reproduce all decimal @@ -201,58 +201,58 @@ def test_low_level_eckart_against_johnston1962(): # noqa: C901, PLR0912, PLR091 gammas = [1.24, 1.56, 2.04, 2.94, 4.54, 13.8, 57.0, 307] for u, gamma in zip(us[:-1], gammas): - assert rx.tunnel._eckart(u, 8, 8) == pytest.approx(gamma, 2e-2) # noqa: SLF001 + assert rx.tunnel._eckart(u, 8, 8) == pytest.approx(gamma, 2e-2) gammas = [1.22, 1.54, 2.04, 2.96, 4.68, 15.4, 71.7, 445] for u, gamma in zip(us[:-1], gammas): - assert rx.tunnel._eckart(u, 8, 12) == pytest.approx(gamma, 2e-2) # noqa: SLF001 + assert rx.tunnel._eckart(u, 8, 12) == pytest.approx(gamma, 2e-2) gammas = [1.21, 1.53, 2.02, 2.93, 4.65, 15.6, 74.4, 473] for u, gamma in zip(us[:-1], gammas): - assert rx.tunnel._eckart(u, 8, 16) == pytest.approx(gamma, 2e-2) # noqa: SLF001 + assert rx.tunnel._eckart(u, 8, 16) == pytest.approx(gamma, 2e-2) gammas = [1.20, 1.51, 2.00, 2.90, 4.61, 15.5, 74.2, 474] for u, gamma in zip(us[:-1], gammas): - assert rx.tunnel._eckart(u, 8, 20) == pytest.approx(gamma, 2e-2) # noqa: SLF001 + assert rx.tunnel._eckart(u, 8, 20) == pytest.approx(gamma, 2e-2) gammas = [1.2, 1.5, 2.1, 3.1, 5.2, 22, 162, 1970] for u, gamma in zip(us[:-1], gammas): - assert rx.tunnel._eckart(u, 12, 12) == pytest.approx( # noqa: SLF001 + assert rx.tunnel._eckart(u, 12, 12) == pytest.approx( gamma, 2e-2, ) gammas = [1.2, 1.5, 2.1, 3.1, 5.4, 25, 220, 3300] for u, gamma in zip(us[:-1], gammas): - assert rx.tunnel._eckart(u, 12, 16) == pytest.approx( # noqa: SLF001 + assert rx.tunnel._eckart(u, 12, 16) == pytest.approx( gamma, 2e-2, ) gammas = [1.2, 1.5, 2.1, 3.1, 5.4, 26, 246, 3920] for u, gamma in zip(us[:-1], gammas): - assert rx.tunnel._eckart(u, 12, 20) == pytest.approx( # noqa: SLF001 + assert rx.tunnel._eckart(u, 12, 20) == pytest.approx( gamma, 2e-2, ) gammas = [1.2, 1.5, 2.1, 3.2, 5.7, 32, 437] for u, gamma in zip(us[:-2], gammas): - assert rx.tunnel._eckart(u, 16, 16) == pytest.approx( # noqa: SLF001 + assert rx.tunnel._eckart(u, 16, 16) == pytest.approx( gamma, 2e-2, ) gammas = [1.2, 1.5, 2.1, 3.2, 5.9, 37, 616] for u, gamma in zip(us[:-2], gammas): - assert rx.tunnel._eckart(u, 16, 20) == pytest.approx( # noqa: SLF001 + assert rx.tunnel._eckart(u, 16, 20) == pytest.approx( gamma, 2e-2, ) gammas = [1.2, 1.5, 2.1, 3.2, 6.1, 46, 1150] for u, gamma in zip(us[:-2], gammas): - assert rx.tunnel._eckart(u, 20, 20) == pytest.approx( # noqa: SLF001 + assert rx.tunnel._eckart(u, 20, 20) == pytest.approx( gamma, 4e-2, )