Skip to content

Commit

Permalink
Add NPY and leave out FURB
Browse files Browse the repository at this point in the history
  • Loading branch information
tovrstra committed May 23, 2024
1 parent 52d448e commit 1a360a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
12 changes: 5 additions & 7 deletions iodata/test/test_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions iodata/test/test_orbitals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down

0 comments on commit 1a360a3

Please sign in to comment.