From 860c00994b5fdd5bc2562bf9eea7f75a0903b49f Mon Sep 17 00:00:00 2001 From: Philipp Weiler Date: Fri, 12 Apr 2024 13:39:02 +0200 Subject: [PATCH] Update assertion accuracy --- tests/preprocessing/test_moments.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/preprocessing/test_moments.py b/tests/preprocessing/test_moments.py index e6e4b167..7adf4837 100644 --- a/tests/preprocessing/test_moments.py +++ b/tests/preprocessing/test_moments.py @@ -55,7 +55,7 @@ def test_first_moments( f"-layer={layer}-mode={mode}_first_moment.npy" ) ) - np.testing.assert_almost_equal(first_order_moment, ground_truth) + np.testing.assert_almost_equal(first_order_moment, ground_truth, decimal=3) @pytest.mark.parametrize("dataset", ["pancreas", "dentategyrus"]) @pytest.mark.parametrize("n_obs", [50, 100]) @@ -84,7 +84,7 @@ def test_second_moments( f"-layer={layer}-mode={mode}_second_moment.npy" ) ) - np.testing.assert_almost_equal(second_order_moment, ground_truth) + np.testing.assert_almost_equal(second_order_moment, ground_truth, decimal=3) @pytest.mark.parametrize("dataset", ["pancreas", "dentategyrus"]) @pytest.mark.parametrize("n_obs", [50, 100]) @@ -117,7 +117,7 @@ def test_passing_array_for_layer( f"-layer={layer}-mode={mode}_first_moment.npy" ) ) - np.testing.assert_almost_equal(first_order_moment, ground_truth) + np.testing.assert_almost_equal(first_order_moment, ground_truth, decimal=3) @pytest.mark.parametrize("sparse", [True, False]) def test_analytic_example(self, sparse: bool): @@ -187,7 +187,7 @@ def _compare_adatas(self, adata_1, adata_2): ) assert issparse(adata_1.obsp["distances"]) np.testing.assert_almost_equal( - adata_1.obsp["distances"].A, adata_2.obsp["distances"].A, decimal=4 + adata_1.obsp["distances"].A, adata_2.obsp["distances"].A, decimal=3 ) # Check `.uns` is unchanged @@ -377,7 +377,9 @@ def test_raw_input(self, adata, dataset: str, n_obs: int): f"first_moment_spliced.npy" ) ) - np.testing.assert_almost_equal(adata.layers["Ms"], ground_truth_spliced) + np.testing.assert_almost_equal( + adata.layers["Ms"], ground_truth_spliced, decimal=3 + ) class TestSecondOrderMoments: @@ -497,4 +499,4 @@ def test_output(self, adata, dataset: str, n_obs: int): f"-layer=unspliced-mode=connectivities_second_moment.npy" ) ) - np.testing.assert_almost_equal(second_order_moment, ground_truth) + np.testing.assert_almost_equal(second_order_moment, ground_truth, decimal=3)