diff --git a/tests/conftest.py b/tests/conftest.py index 8a2a2b6d4..f86b26d3b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -260,8 +260,8 @@ def gt_tm_annotation() -> np.ndarray: for i in range(10): tm[i][i] = 1 for i in range(10, 15): - tm[i-5][i] = 1 - for j in range(2,5): - for i in range(2,5): + tm[i - 5][i] = 1 + for j in range(2, 5): + for i in range(2, 5): tm[i][j] = 0.3 if i != j else 0.4 return tm diff --git a/tests/problems/cross_modality/test_mixins.py b/tests/problems/cross_modality/test_mixins.py index 7721bf877..079e153a4 100644 --- a/tests/problems/cross_modality/test_mixins.py +++ b/tests/problems/cross_modality/test_mixins.py @@ -109,7 +109,7 @@ def test_cell_transition_pipeline( @pytest.mark.fast() @pytest.mark.parametrize("forward", [True, False]) - @pytest.mark.parametrize("mapping_mode",["max", "sum"]) + @pytest.mark.parametrize("mapping_mode", ["max", "sum"]) @pytest.mark.parametrize("problem_kind", ["cross_modality"]) def test_annotation_mapping( self, adata_anno: Tuple[AnnData, AnnData], forward: bool, mapping_mode, gt_tm_annotation @@ -122,14 +122,14 @@ def test_annotation_mapping( tp[problem_keys].set_solution(MockSolverOutput(gt_tm_annotation), overwrite=True) annotation_label = "celltype1" if forward else "celltype2" result = tp.annotation_mapping( - mapping_mode=mapping_mode, - annotation_label=annotation_label, - forward=forward, - source="src", - target="tgt" + mapping_mode=mapping_mode, annotation_label=annotation_label, forward=forward, source="src", target="tgt" ) if forward: - expected_result = adata_src.uns["expected_max1"] if mapping_mode == "max" else adata_src.uns["expected_sum1"] + expected_result = ( + adata_src.uns["expected_max1"] if mapping_mode == "max" else adata_src.uns["expected_sum1"] + ) else: - expected_result = adata_tgt.uns["expected_max2"] if mapping_mode == "max" else adata_tgt.uns["expected_sum2"] + expected_result = ( + adata_tgt.uns["expected_max2"] if mapping_mode == "max" else adata_tgt.uns["expected_sum2"] + ) assert (result[annotation_label] == expected_result).all() diff --git a/tests/problems/space/test_mixins.py b/tests/problems/space/test_mixins.py index ec337f592..a6b70031c 100644 --- a/tests/problems/space/test_mixins.py +++ b/tests/problems/space/test_mixins.py @@ -112,11 +112,16 @@ def test_annotation_mapping(self, adata_anno: AnnData, forward: bool, mapping_mo forward=forward, ) if forward: - expected_result = adata_anno.uns["expected_max1"] if mapping_mode == "max" else adata_anno.uns["expected_sum1"] + expected_result = ( + adata_anno.uns["expected_max1"] if mapping_mode == "max" else adata_anno.uns["expected_sum1"] + ) else: - expected_result = adata_anno.uns["expected_max2"] if mapping_mode == "max" else adata_anno.uns["expected_sum2"] + expected_result = ( + adata_anno.uns["expected_max2"] if mapping_mode == "max" else adata_anno.uns["expected_sum2"] + ) assert (result[annotation_label] == expected_result).all() + class TestSpatialMappingAnalysisMixin: @pytest.mark.parametrize("sc_attr", [{"attr": "X"}, {"attr": "obsm", "key": "X_pca"}]) @pytest.mark.parametrize("var_names", ["0", [str(i) for i in range(20)]]) diff --git a/tests/problems/time/test_mixins.py b/tests/problems/time/test_mixins.py index 6fcb58baf..cb2d9ea2a 100644 --- a/tests/problems/time/test_mixins.py +++ b/tests/problems/time/test_mixins.py @@ -51,7 +51,7 @@ def test_cell_transition_full_pipeline(self, gt_temporal_adata: AnnData, forward np.testing.assert_allclose(present_cell_type_marginal, 1.0) @pytest.mark.fast() - @pytest.mark.parametrize("forward",[True, False]) + @pytest.mark.parametrize("forward", [True, False]) @pytest.mark.parametrize("mapping_mode", ["max", "sum"]) @pytest.mark.parametrize("problem_kind", ["temporal"]) def test_annotation_mapping(self, adata_anno: AnnData, forward: bool, mapping_mode, gt_tm_annotation): @@ -63,11 +63,15 @@ def test_annotation_mapping(self, adata_anno: AnnData, forward: bool, mapping_mo annotation_label = "celltype1" if forward else "celltype2" result = problem.annotation_mapping( mapping_mode=mapping_mode, annotation_label=annotation_label, forward=forward, source=0, target=1 - ) + ) if forward: - expected_result = adata_anno.uns["expected_max1"] if mapping_mode == "max" else adata_anno.uns["expected_sum1"] + expected_result = ( + adata_anno.uns["expected_max1"] if mapping_mode == "max" else adata_anno.uns["expected_sum1"] + ) else: - expected_result = adata_anno.uns["expected_max2"] if mapping_mode == "max" else adata_anno.uns["expected_sum2"] + expected_result = ( + adata_anno.uns["expected_max2"] if mapping_mode == "max" else adata_anno.uns["expected_sum2"] + ) assert (result[annotation_label] == expected_result).all() @pytest.mark.fast()