From 1a360a3cc836de1adfdf79968f8d24184de11993 Mon Sep 17 00:00:00 2001 From: Toon Verstraelen Date: Thu, 23 May 2024 10:57:19 +0200 Subject: [PATCH] Add NPY and leave out FURB --- iodata/test/test_basis.py | 12 +++++------- iodata/test/test_orbitals.py | 18 ++++++++++++------ pyproject.toml | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/iodata/test/test_basis.py b/iodata/test/test_basis.py index d2c127f1..2fe6dc24 100644 --- a/iodata/test/test_basis.py +++ b/iodata/test/test_basis.py @@ -171,14 +171,11 @@ def test_nbasis1(): def test_get_segmented(): + rng = np.random.default_rng(1) obasis0 = MolecularBasis( [ - Shell( - 0, [0, 1], ["c", "c"], np.random.uniform(0, 1, 5), np.random.uniform(-1, 1, (5, 2)) - ), - Shell( - 1, [2, 3], ["p", "p"], np.random.uniform(0, 1, 7), np.random.uniform(-1, 1, (7, 2)) - ), + Shell(0, [0, 1], ["c", "c"], rng.uniform(0, 1, 5), rng.uniform(-1, 1, (5, 2))), + Shell(1, [2, 3], ["p", "p"], rng.uniform(0, 1, 7), rng.uniform(-1, 1, (7, 2))), ], CP2K_CONVENTIONS, "L2", @@ -279,7 +276,8 @@ def test_convert_convention_obasis(): permutation, signs = convert_conventions(obasis, new_convention) assert_equal(permutation, [0, 1, 2, 4, 3, 5, 6, 8, 7, 12, 10, 9, 11, 13]) assert_equal(signs, [-1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1]) - vec1 = np.random.uniform(-1, 1, obasis.nbasis) + rng = np.random.default_rng(1) + vec1 = rng.uniform(-1, 1, obasis.nbasis) vec2 = vec1[permutation] * signs permutation, signs = convert_conventions(obasis, new_convention, reverse=True) vec3 = vec2[permutation] * signs diff --git a/iodata/test/test_orbitals.py b/iodata/test/test_orbitals.py index ea809f40..78652d7e 100644 --- a/iodata/test/test_orbitals.py +++ b/iodata/test/test_orbitals.py @@ -78,7 +78,8 @@ def test_restricted_occs(): def test_restricted_coeffs(): - coeffs = np.random.uniform(-1, 1, (7, 5)) + rng = np.random.default_rng(1) + coeffs = rng.uniform(-1, 1, (7, 5)) with pytest.raises(TypeError): MolecularOrbitals("restricted", 3, 3, coeffs=coeffs) mo = MolecularOrbitals("restricted", 5, 5, coeffs=coeffs) @@ -99,7 +100,8 @@ def test_restricted_coeffs(): def test_restricted_energies(): - energies = np.random.uniform(-1, 1, 5) + rng = np.random.default_rng(1) + energies = rng.uniform(-1, 1, 5) with pytest.raises(TypeError): MolecularOrbitals("restricted", 3, 3, energies=energies) mo = MolecularOrbitals("restricted", 5, 5, energies=energies) @@ -186,7 +188,8 @@ def test_unrestricted_occs(): def test_unrestricted_coeffs(): - coeffs = np.random.uniform(-1, 1, (7, 8)) + rng = np.random.default_rng(1) + coeffs = rng.uniform(-1, 1, (7, 8)) with pytest.raises(TypeError): MolecularOrbitals("unrestricted", 3, 2, coeffs=coeffs) mo = MolecularOrbitals("unrestricted", 5, 3, coeffs=coeffs) @@ -207,7 +210,8 @@ def test_unrestricted_coeffs(): def test_unrestricted_energies(): - energies = np.random.uniform(-1, 1, 8) + rng = np.random.default_rng(1) + energies = rng.uniform(-1, 1, 8) with pytest.raises(TypeError): MolecularOrbitals("unrestricted", 3, 2, energies=energies) mo = MolecularOrbitals("unrestricted", 5, 3, energies=energies) @@ -310,7 +314,8 @@ def test_generalized_occs(): def test_generalized_coeffs(): - coeffs = np.random.uniform(-1, 1, (10, 7)) + rng = np.random.default_rng(1) + coeffs = rng.uniform(-1, 1, (10, 7)) mo = MolecularOrbitals("generalized", None, None, coeffs=coeffs) assert mo.norba is None assert mo.norbb is None @@ -338,7 +343,8 @@ def test_generalized_coeffs(): def test_generalized_energies(): - energies = np.random.uniform(-1, 1, 7) + rng = np.random.default_rng(1) + energies = rng.uniform(-1, 1, 7) mo = MolecularOrbitals("generalized", None, None, energies=energies) assert mo.norba is None assert mo.norbb is None diff --git a/pyproject.toml b/pyproject.toml index d73424ff..e6e0ce4e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,7 +56,7 @@ target-version = "py39" [tool.ruff.lint] select = [ "E", "W", "F", "I", "N", "UP", "B", "BLE", "A", "EXE", "ISC", "ICN", "PIE", "PYI", "PT", - "PL", "RUF", "C4", "RSE", "RET", "SLF", "FURB" + "PL", "RUF", "C4", "RSE", "RET", "SLF", "NPY" ] ignore = [ "PLR0904", # https://docs.astral.sh/ruff/rules/too-many-public-methods/