From 976adf5dcb30031d3d08537b311d6b703aaf7c93 Mon Sep 17 00:00:00 2001 From: JosePizarro3 Date: Mon, 3 Jun 2024 11:10:41 +0200 Subject: [PATCH] Fix mypy: yes, it is crap sometimes --- tests/test_band_structure.py | 88 ++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/tests/test_band_structure.py b/tests/test_band_structure.py index 351f68d2..c7b920ac 100644 --- a/tests/test_band_structure.py +++ b/tests/test_band_structure.py @@ -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, + ], ), ), ], @@ -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. @@ -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']