Skip to content

Commit

Permalink
Fix mypy: yes, it is crap sometimes
Browse files Browse the repository at this point in the history
  • Loading branch information
JosePizarro3 committed Jun 3, 2024
1 parent 7771834 commit 976adf5
Showing 1 changed file with 45 additions and 43 deletions.
88 changes: 45 additions & 43 deletions tests/test_band_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,72 +88,73 @@ def test_default_quantities(self, n_bands: Optional[int], rank: Optional[list]):
# assert electronic_eigenvalues.validate_occupation(logger) == result

@pytest.mark.parametrize(
'occupation, value, result',
'occupation, value, result_validation, result',
[
(
None,
[[3, -2], [3, 1], [4, -2], [5, -1], [4, 0], [2, 0], [2, 1], [4, -3]],
False,
(None, None),
),
(
[],
[[3, -2], [3, 1], [4, -2], [5, -1], [4, 0], [2, 0], [2, 1], [4, -3]],
False,
(None, None),
),
(
[[2, 2], [0, 0]],
[[3, -2], [3, 1], [4, -2], [5, -1], [4, 0], [2, 0], [2, 1], [4, -3]],
False,
(None, None),
), # `value` and `occupation` must have same shape
(
[[0, 2], [0, 1], [0, 2], [0, 2], [0, 1.5], [0, 1.5], [0, 1], [0, 2]],
None,
False,
(None, None),
),
(
[[0, 2], [0, 1], [0, 2], [0, 2], [0, 1.5], [0, 1.5], [0, 1], [0, 2]],
[[3, -2], [3, 1], [4, -2], [5, -1], [4, 0], [2, 0], [2, 1], [4, -3]],
True,
(
np.array(
[
-3,
-2,
-2,
-1,
0,
0,
1,
1,
2,
2,
3,
3,
4,
4,
4,
5,
]
),
np.array(
[
2.0,
2.0,
2.0,
2.0,
1.5,
1.5,
1.0,
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
]
),
[
-3,
-2,
-2,
-1,
0,
0,
1,
1,
2,
2,
3,
3,
4,
4,
4,
5,
],
[
2.0,
2.0,
2.0,
2.0,
1.5,
1.5,
1.0,
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
],
),
),
],
Expand All @@ -162,7 +163,8 @@ def test_order_eigenvalues(
self,
occupation: Optional[list],
value: Optional[list],
result,
result_validation: bool,
result: Tuple[list, list],
):
"""
Test the `order_eigenvalues` method.
Expand All @@ -173,7 +175,7 @@ def test_order_eigenvalues(
)
order_result = electronic_eigenvalues.order_eigenvalues()
if not order_result:
assert order_result == result
assert order_result == result_validation
else:
sorted_value, sorted_occupation = order_result
assert electronic_eigenvalues.m_cache['sorted_eigenvalues']
Expand Down

0 comments on commit 976adf5

Please sign in to comment.