Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 17, 2024
1 parent 4d3c8db commit e2b9c5b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 8 additions & 8 deletions tests/problems/cross_modality/test_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
9 changes: 7 additions & 2 deletions tests/problems/space/test_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]])
Expand Down
12 changes: 8 additions & 4 deletions tests/problems/time/test_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()
Expand Down

0 comments on commit e2b9c5b

Please sign in to comment.