diff --git a/tests/backends/ott/test_backend.py b/tests/backends/ott/test_backend.py index d0b8cbb60..3962c53d1 100644 --- a/tests/backends/ott/test_backend.py +++ b/tests/backends/ott/test_backend.py @@ -29,7 +29,7 @@ class TestSinkhorn: - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("jit", [False, True]) @pytest.mark.parametrize("eps", [None, 1e-2, 1e-1]) def test_matches_ott(self, x: Geom_t, eps: Optional[float], jit: bool): @@ -212,7 +212,7 @@ def test_matches_ott(self, x: Geom_t, y: Geom_t, xy: Geom_t, eps: Optional[float assert isinstance(solver.xy, PointCloud) np.testing.assert_allclose(gt.matrix, pred.transport_matrix, rtol=RTOL, atol=ATOL) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("alpha", [0.1, 0.9]) def test_alpha(self, x: Geom_t, y: Geom_t, xy: Geom_t, alpha: float) -> None: thresh, eps = 5e-2, 1e-1 diff --git a/tests/conftest.py b/tests/conftest.py index 95f13f5dc..0a0614630 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -39,7 +39,7 @@ def _close_figure(): plt.close() -@pytest.fixture() +@pytest.fixture def x() -> Geom_t: rng = np.random.RandomState(0) n = 20 # number of points in the first distribution @@ -51,7 +51,7 @@ def x() -> Geom_t: return jnp.asarray(xs) -@pytest.fixture() +@pytest.fixture def y() -> Geom_t: rng = np.random.RandomState(1) n2 = 30 # number of points in the second distribution @@ -63,7 +63,7 @@ def y() -> Geom_t: return jnp.asarray(xt) -@pytest.fixture() +@pytest.fixture def xy() -> Tuple[Geom_t, Geom_t]: rng = np.random.RandomState(2) n = 20 # number of points in the first distribution @@ -83,36 +83,36 @@ def xy() -> Tuple[Geom_t, Geom_t]: return jnp.asarray(ys), jnp.asarray(yt) -@pytest.fixture() +@pytest.fixture def ab() -> Tuple[np.ndarray, np.ndarray]: rng = np.random.RandomState(42) return rng.normal(size=(20, 2)), rng.normal(size=(30, 4)) -@pytest.fixture() +@pytest.fixture def x_cost(x: Geom_t) -> jnp.ndarray: return ((x[:, None, :] - x[None, ...]) ** 2).sum(-1) -@pytest.fixture() +@pytest.fixture def y_cost(y: Geom_t) -> jnp.ndarray: return ((y[:, None, :] - y[None, ...]) ** 2).sum(-1) -@pytest.fixture() +@pytest.fixture def xy_cost(xy: Geom_t) -> jnp.ndarray: x, y = xy return ((x[:, None, :] - y[None, ...]) ** 2).sum(-1) -@pytest.fixture() +@pytest.fixture def adata_x(x: Geom_t) -> AnnData: rng = np.random.RandomState(43) pc = rng.normal(size=(len(x), 4)) return AnnData(X=np.asarray(x, dtype=float), obsm={"X_pca": pc}) -@pytest.fixture() +@pytest.fixture def adata_y(y: Geom_t) -> AnnData: rng = np.random.RandomState(44) pc = rng.normal(size=(len(y), 4)) @@ -126,7 +126,7 @@ def creat_prob(n: int, *, uniform: bool = False, seed: Optional[int] = None) -> return jnp.asarray(a) -@pytest.fixture() +@pytest.fixture def adata_time() -> AnnData: rng = np.random.RandomState(42) @@ -156,7 +156,7 @@ def adata_time() -> AnnData: return adata -@pytest.fixture() +@pytest.fixture def gt_temporal_adata() -> AnnData: adata = _gt_temporal_adata.copy() # TODO(michalk8): remove both lines once data has been regenerated @@ -165,7 +165,7 @@ def gt_temporal_adata() -> AnnData: return adata -@pytest.fixture() +@pytest.fixture def adata_space_rotate() -> AnnData: rng = np.random.RandomState(31) grid = _make_grid(10) @@ -182,7 +182,7 @@ def adata_space_rotate() -> AnnData: return adata -@pytest.fixture() +@pytest.fixture def adata_mapping() -> AnnData: grid = _make_grid(10) adataref, adata1, adata2 = _make_adata(grid, n=3, seed=17, cat_key="covariate", num_categories=3) @@ -190,7 +190,7 @@ def adata_mapping() -> AnnData: return ad.concat([adataref, adata1, adata2], label="batch", join="outer", index_unique="-") -@pytest.fixture() +@pytest.fixture def adata_translation() -> AnnData: rng = np.random.RandomState(31) adatas = [AnnData(X=csr_matrix(rng.normal(size=(100, 60)))) for _ in range(3)] @@ -202,7 +202,7 @@ def adata_translation() -> AnnData: return adata -@pytest.fixture() +@pytest.fixture def adata_translation_split(adata_translation) -> Tuple[AnnData, AnnData]: rng = np.random.RandomState(15) adata_src = adata_translation[adata_translation.obs.batch != "0"].copy() @@ -212,7 +212,7 @@ def adata_translation_split(adata_translation) -> Tuple[AnnData, AnnData]: return adata_src, adata_tgt -@pytest.fixture() +@pytest.fixture def adata_anno( problem_kind: Literal["temporal", "cross_modality", "alignment", "mapping"], ) -> Union[AnnData, Tuple[AnnData, AnnData]]: @@ -258,7 +258,7 @@ def adata_anno( return adata -@pytest.fixture() +@pytest.fixture def gt_tm_annotation() -> np.ndarray: tm = np.zeros((10, 15)) for i in range(10): diff --git a/tests/datasets/test_dataset.py b/tests/datasets/test_dataset.py index f75655ed7..d02a9d286 100644 --- a/tests/datasets/test_dataset.py +++ b/tests/datasets/test_dataset.py @@ -9,7 +9,7 @@ class TestSimulateData: - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("n_distributions", [2, 4]) @pytest.mark.parametrize("key", ["batch", "day"]) def test_n_distributions(self, n_distributions: int, key: str): @@ -17,7 +17,7 @@ def test_n_distributions(self, n_distributions: int, key: str): assert key in adata.obs.columns assert adata.obs[key].nunique() == n_distributions - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("obs_to_add", [{"celltype": 2}, {"celltype": 5, "cluster": 4}]) def test_obs_to_add(self, obs_to_add: Mapping[str, int]): adata = simulate_data(obs_to_add=obs_to_add) @@ -26,7 +26,7 @@ def test_obs_to_add(self, obs_to_add: Mapping[str, int]): assert colname in adata.obs.columns assert adata.obs[colname].nunique() == k - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("spatial_dim", [None, 2, 3]) def test_quad_term_spatial(self, spatial_dim: Optional[int]): kwargs = {} @@ -40,7 +40,7 @@ def test_quad_term_spatial(self, spatial_dim: Optional[int]): else: assert adata.obsm["spatial"].shape[1] == spatial_dim - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("n_intBCs", [None, 4, 7]) @pytest.mark.parametrize("barcode_dim", [None, 5, 8]) def test_quad_term_barcode(self, n_intBCs: Optional[int], barcode_dim: Optional[int]): @@ -63,7 +63,7 @@ def test_quad_term_barcode(self, n_intBCs: Optional[int], barcode_dim: Optional[ else: assert len(np.unique(adata.obsm["barcode"])) <= n_intBCs - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("n_initial_nodes", [None, 4, 7]) @pytest.mark.parametrize("n_distributions", [3, 6]) def test_quad_term_tree(self, n_initial_nodes: Optional[int], n_distributions: int): diff --git a/tests/plotting/conftest.py b/tests/plotting/conftest.py index 50ba864bf..baf0b04f8 100644 --- a/tests/plotting/conftest.py +++ b/tests/plotting/conftest.py @@ -24,7 +24,7 @@ DPI = 40 -@pytest.fixture() +@pytest.fixture def adata_pl_cell_transition(gt_temporal_adata: AnnData) -> AnnData: plot_vars = { "transition_matrix": gt_temporal_adata.uns["cell_transition_10_105_forward"], @@ -38,7 +38,7 @@ def adata_pl_cell_transition(gt_temporal_adata: AnnData) -> AnnData: return gt_temporal_adata -@pytest.fixture() +@pytest.fixture def adata_pl_push(adata_time: AnnData) -> AnnData: rng = np.random.RandomState(0) plot_vars = {"key": "time", "data": "celltype", "subset": "A", "source": 0, "target": 1} @@ -57,7 +57,7 @@ def adata_pl_push(adata_time: AnnData) -> AnnData: return adata_time -@pytest.fixture() +@pytest.fixture def adata_pl_pull(adata_time: AnnData) -> AnnData: rng = np.random.RandomState(0) plot_vars = {"key": "time", "data": "celltype", "subset": "A", "source": 0, "target": 1} @@ -75,7 +75,7 @@ def adata_pl_pull(adata_time: AnnData) -> AnnData: return adata_time -@pytest.fixture() +@pytest.fixture def adata_pl_sankey(adata_time: AnnData) -> AnnData: rng = np.random.RandomState(0) celltypes = ["A", "B", "C", "D", "E"] diff --git a/tests/problems/base/test_compound_problem.py b/tests/problems/base/test_compound_problem.py index 12a75a69f..5810f3349 100644 --- a/tests/problems/base/test_compound_problem.py +++ b/tests/problems/base/test_compound_problem.py @@ -68,7 +68,7 @@ def test_sc_pipeline(self, adata_time: AnnData): assert problem[key].solution is problem.solutions[key] @pytest.mark.parametrize("scale", [True, False]) - @pytest.mark.fast() + @pytest.mark.fast def test_default_callback(self, adata_time: AnnData, mocker: MockerFixture, scale: bool): subproblem = OTProblem(adata_time, adata_tgt=adata_time.copy()) xy_callback_kwargs = {"n_comps": 5, "scale": scale} @@ -88,7 +88,7 @@ def test_default_callback(self, adata_time: AnnData, mocker: MockerFixture, scal assert isinstance(problem.problems, dict) spy.assert_called_with("xy", subproblem.adata_src, subproblem.adata_tgt, **xy_callback_kwargs) - @pytest.mark.fast() + @pytest.mark.fast def test_custom_callback_lin(self, adata_time: AnnData, mocker: MockerFixture): expected_keys = [(0, 1), (1, 2)] spy = mocker.spy(TestCompoundProblem, "xy_callback") @@ -106,7 +106,7 @@ def test_custom_callback_lin(self, adata_time: AnnData, mocker: MockerFixture): assert spy.call_count == len(expected_keys) - @pytest.mark.fast() + @pytest.mark.fast def test_custom_callback_quad(self, adata_time: AnnData, mocker: MockerFixture): expected_keys = [(0, 1), (1, 2)] spy_x = mocker.spy(TestCompoundProblem, "x_callback") @@ -164,7 +164,7 @@ def test_different_passings_linear(self, adata_with_cost_matrix: AnnData): np.testing.assert_allclose(gt.matrix, p1_tmap, rtol=RTOL, atol=ATOL) np.testing.assert_allclose(gt.matrix, p2_tmap, rtol=RTOL, atol=ATOL) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("cost", [("sq_euclidean", SqEuclidean), ("euclidean", Euclidean), ("cosine", Cosine)]) def test_prepare_cost(self, adata_time: AnnData, cost: Tuple[str, Any]): problem = Problem(adata=adata_time) @@ -179,7 +179,7 @@ def test_prepare_cost(self, adata_time: AnnData, cost: Tuple[str, Any]): assert isinstance(problem[0, 1].x.cost, cost[1]) assert isinstance(problem[0, 1].y.cost, cost[1]) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("cost", [("sq_euclidean", SqEuclidean), ("euclidean", Euclidean), ("cosine", Cosine)]) def test_prepare_cost_with_callback(self, adata_time: AnnData, cost: Tuple[str, Any]): problem = Problem(adata=adata_time) @@ -196,7 +196,7 @@ def test_prepare_cost_with_callback(self, adata_time: AnnData, cost: Tuple[str, assert isinstance(problem[0, 1].x.cost, cost[1]) assert isinstance(problem[0, 1].y.cost, cost[1]) - @pytest.mark.fast() + @pytest.mark.fast def test_prepare_different_costs(self, adata_time: AnnData): problem = Problem(adata=adata_time) problem = problem.prepare( diff --git a/tests/problems/base/test_general_problem.py b/tests/problems/base/test_general_problem.py index 431a87d93..5e17b6dec 100644 --- a/tests/problems/base/test_general_problem.py +++ b/tests/problems/base/test_general_problem.py @@ -29,7 +29,7 @@ def test_simple_run(self, adata_x: AnnData, adata_y: AnnData): assert isinstance(prob.solution, BaseDiscreteSolverOutput) - @pytest.mark.fast() + @pytest.mark.fast def test_output(self, adata_x: AnnData, x: Geom_t): problem = OTProblem(adata_x) problem._solution = MockSolverOutput(x * x.T) diff --git a/tests/problems/conftest.py b/tests/problems/conftest.py index 99ae64984..9ee32e693 100644 --- a/tests/problems/conftest.py +++ b/tests/problems/conftest.py @@ -10,7 +10,7 @@ from tests._utils import Geom_t -@pytest.fixture() +@pytest.fixture def adata_with_cost_matrix(adata_x: Geom_t, adata_y: Geom_t) -> AnnData: adata = ad.concat([adata_x, adata_y], label="batch", index_unique="-") C = pairwise_distances(adata_x.obsm["X_pca"], adata_y.obsm["X_pca"]) ** 2 @@ -19,7 +19,7 @@ def adata_with_cost_matrix(adata_x: Geom_t, adata_y: Geom_t) -> AnnData: return adata -@pytest.fixture() +@pytest.fixture def adata_time_with_tmap(adata_time: AnnData) -> AnnData: adata = adata_time[adata_time.obs["time"].isin([0, 1])].copy() rng = np.random.RandomState(42) diff --git a/tests/problems/cross_modality/test_mixins.py b/tests/problems/cross_modality/test_mixins.py index 5085819ab..8bf7c3565 100644 --- a/tests/problems/cross_modality/test_mixins.py +++ b/tests/problems/cross_modality/test_mixins.py @@ -65,7 +65,7 @@ def test_translate_alternative( trans_backward = tp.translate(source=src, target=tgt, forward=False, alternative_attr=alternative_attr) assert trans_backward.shape == adata_src[adata_src.obs["batch"] == "1"].obsm["X_pca"].shape - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("forward", [True, False]) @pytest.mark.parametrize("normalize", [True, False]) def test_cell_transition_pipeline( @@ -107,7 +107,7 @@ def test_cell_transition_pipeline( with pytest.raises(AssertionError): pd.testing.assert_frame_equal(result1, result2) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("forward", [True, False]) @pytest.mark.parametrize("mapping_mode", ["max", "sum"]) @pytest.mark.parametrize("batch_size", [3, 7, None]) diff --git a/tests/problems/cross_modality/test_translation_problem.py b/tests/problems/cross_modality/test_translation_problem.py index b083ee745..b048fa9cf 100644 --- a/tests/problems/cross_modality/test_translation_problem.py +++ b/tests/problems/cross_modality/test_translation_problem.py @@ -25,7 +25,7 @@ class TestTranslationProblem: - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("src_attr", ["emb_src", {"attr": "obsm", "key": "emb_src"}]) @pytest.mark.parametrize("tgt_attr", ["emb_tgt", {"attr": "obsm", "key": "emb_tgt"}]) @pytest.mark.parametrize("joint_attr", [None, "X_pca", {"attr": "obsm", "key": "X_pca"}]) @@ -50,7 +50,7 @@ def test_prepare_dummy_policy( assert tp[prob_key].shape == (2 * n_obs, n_obs) np.testing.assert_array_equal(tp._policy._cat, prob_key) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("src_attr", ["emb_src", {"attr": "obsm", "key": "emb_src"}]) @pytest.mark.parametrize("tgt_attr", ["emb_tgt", {"attr": "obsm", "key": "emb_tgt"}]) @pytest.mark.parametrize("joint_attr", [None, "X_pca", {"attr": "obsm", "key": "X_pca"}]) diff --git a/tests/problems/generic/conftest.py b/tests/problems/generic/conftest.py index db43f57b7..9be929fb1 100644 --- a/tests/problems/generic/conftest.py +++ b/tests/problems/generic/conftest.py @@ -6,7 +6,7 @@ from anndata import AnnData -@pytest.fixture() +@pytest.fixture def adata_time_with_tmap(adata_time: AnnData) -> AnnData: adata = adata_time[adata_time.obs["time"].isin([0, 1])].copy() rng = np.random.RandomState(42) diff --git a/tests/problems/generic/test_conditional_neural_problem.py b/tests/problems/generic/test_conditional_neural_problem.py index 15dba8146..5a7297de0 100644 --- a/tests/problems/generic/test_conditional_neural_problem.py +++ b/tests/problems/generic/test_conditional_neural_problem.py @@ -15,7 +15,7 @@ class TestGENOTLinProblem: - @pytest.mark.fast() + @pytest.mark.fast def test_prepare(self, adata_time: ad.AnnData): problem = GENOTLinProblem(adata=adata_time) problem = problem.prepare(key="time", joint_attr="X_pca", conditional_attr={"attr": "obs", "key": "time"}) diff --git a/tests/problems/generic/test_fgw_problem.py b/tests/problems/generic/test_fgw_problem.py index 35a5efca2..3ee7b4f30 100644 --- a/tests/problems/generic/test_fgw_problem.py +++ b/tests/problems/generic/test_fgw_problem.py @@ -30,7 +30,7 @@ class TestFGWProblem: - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("policy", ["sequential", "star"]) def test_prepare(self, adata_space_rotate: AnnData, policy): expected_keys = { @@ -59,7 +59,7 @@ def test_prepare(self, adata_space_rotate: AnnData, policy): assert key in expected_keys[policy] assert isinstance(problem[key], OTProblem) - @pytest.mark.fast() + @pytest.mark.fast def test_prepare_marginals(self, adata_time: AnnData, marginal_keys): problem = FGWProblem(adata=adata_time) problem = problem.prepare( @@ -173,7 +173,7 @@ def test_set_xy(self, adata_time: AnnData, tag: Literal["cost_matrix", "kernel"] assert isinstance(problem[0, 1].xy.data_src, np.ndarray) assert problem[0, 1].xy.data_tgt is None - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize( ("cost_str", "cost_inst", "cost_kwargs"), [ @@ -212,7 +212,7 @@ def test_prepare_costs(self, adata_time: AnnData, cost_str: str, cost_inst: Any, problem = problem.solve(max_iterations=2) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize( ("cost_str", "cost_inst", "cost_kwargs"), [ @@ -305,7 +305,7 @@ def test_set_y(self, adata_time: AnnData, tag: Literal["cost_matrix", "kernel"]) assert isinstance(problem[0, 1].y.data_src, np.ndarray) assert problem[0, 1].y.data_tgt is None - @pytest.mark.fast() + @pytest.mark.fast def test_prepare_different_costs(self, adata_time: AnnData): problem = FGWProblem(adata=adata_time) problem = problem.prepare( diff --git a/tests/problems/generic/test_gw_problem.py b/tests/problems/generic/test_gw_problem.py index ccee4323f..7ae0cb7e5 100644 --- a/tests/problems/generic/test_gw_problem.py +++ b/tests/problems/generic/test_gw_problem.py @@ -28,7 +28,7 @@ class TestGWProblem: - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize( "policy", ["sequential", "star"], @@ -147,7 +147,7 @@ def test_pass_arguments(self, adata_space_rotate: AnnData, args_to_check: Mappin assert getattr(geom, val) == args_to_check[arg], arg assert el == args_to_check[arg] - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize( ("cost_str", "cost_inst", "cost_kwargs"), [ @@ -176,7 +176,7 @@ def test_prepare_costs(self, adata_time: AnnData, cost_str: str, cost_inst: Any, problem = problem.solve(max_iterations=2) - @pytest.mark.fast() + @pytest.mark.fast def test_prepare_marginals(self, adata_time: AnnData, marginal_keys): problem = GWProblem(adata=adata_time) problem = problem.prepare( @@ -185,7 +185,7 @@ def test_prepare_marginals(self, adata_time: AnnData, marginal_keys): for key in problem: _assert_marginals_set(adata_time, problem, key, marginal_keys) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize( ("cost_str", "cost_inst", "cost_kwargs"), [ @@ -273,7 +273,7 @@ def test_set_y(self, adata_time: AnnData, tag: Literal["cost_matrix", "kernel"]) assert isinstance(problem[0, 1].y.data_src, np.ndarray) assert problem[0, 1].y.data_tgt is None - @pytest.mark.fast() + @pytest.mark.fast def test_prepare_different_costs(self, adata_time: AnnData): problem = GWProblem(adata=adata_time) problem = problem.prepare( diff --git a/tests/problems/generic/test_sinkhorn_problem.py b/tests/problems/generic/test_sinkhorn_problem.py index d75d37f2d..1badbf49b 100644 --- a/tests/problems/generic/test_sinkhorn_problem.py +++ b/tests/problems/generic/test_sinkhorn_problem.py @@ -27,7 +27,7 @@ class TestSinkhornProblem: - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("policy", ["sequential", "star"]) def test_prepare(self, adata_time: AnnData, policy, marginal_keys): expected_keys = {"sequential": [(0, 1), (1, 2)], "star": [(1, 0), (2, 0)]} @@ -61,7 +61,7 @@ def test_solve_balanced(self, adata_time: AnnData, marginal_keys): assert np.allclose(subsol.a, problem[key].a, atol=1e-5) assert np.allclose(subsol.b, problem[key].b, atol=1e-5) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize( ("cost_str", "cost_inst", "cost_kwargs"), [ @@ -83,7 +83,7 @@ def test_prepare_costs(self, adata_time: AnnData, cost_str: str, cost_inst: Any, problem = problem.solve(max_iterations=2) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize( ("cost_str", "cost_inst", "cost_kwargs"), [ diff --git a/tests/problems/space/test_alignment_problem.py b/tests/problems/space/test_alignment_problem.py index 0ef586bc0..0d1b21a16 100644 --- a/tests/problems/space/test_alignment_problem.py +++ b/tests/problems/space/test_alignment_problem.py @@ -31,7 +31,7 @@ class TestAlignmentProblem: - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("joint_attr", [{"attr": "X"}]) @pytest.mark.parametrize("normalize_spatial", [True, False]) def test_prepare_sequential( @@ -62,7 +62,7 @@ def test_prepare_sequential( assert ap[prob_key].x.data_src.shape == ap[prob_key].y.data_src.shape == (n_obs, 2) assert ap[prob_key].xy.data_src.shape == ap[prob_key].xy.data_tgt.shape == (n_obs, n_var) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("reference", ["0", "1", "2"]) def test_prepare_star(self, adata_space_rotate: AnnData, reference: str): ap = AlignmentProblem(adata=adata_space_rotate) diff --git a/tests/problems/space/test_mapping_problem.py b/tests/problems/space/test_mapping_problem.py index 485ea52ff..a51bf4ed9 100644 --- a/tests/problems/space/test_mapping_problem.py +++ b/tests/problems/space/test_mapping_problem.py @@ -35,7 +35,7 @@ class TestMappingProblem: - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("sc_attr", [{"attr": "X"}, {"attr": "obsm", "key": "X_pca"}]) @pytest.mark.parametrize("joint_attr", [None, "X_pca", {"attr": "obsm", "key": "X_pca"}]) @pytest.mark.parametrize("normalize_spatial", [True, False]) @@ -79,7 +79,7 @@ def test_prepare( assert mp[prob_key].shape == (2 * n_obs, n_obs) np.testing.assert_array_equal(mp._policy._cat, prob_key) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("var_names", ["0", [], [str(i) for i in range(20)]]) def test_prepare_varnames(self, adata_mapping: AnnData, var_names: Optional[List[str]]): adataref, adatasp = _adata_spatial_split(adata_mapping) diff --git a/tests/problems/space/test_mixins.py b/tests/problems/space/test_mixins.py index b9c2051c1..a4f0145ea 100644 --- a/tests/problems/space/test_mixins.py +++ b/tests/problems/space/test_mixins.py @@ -65,7 +65,7 @@ def test_regression_testing(self, adata_space_rotate: AnnData): np.array(sol[k].transport_matrix), np.array(ap.solutions[k].transport_matrix), decimal=3 ) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("forward", [True, False]) @pytest.mark.parametrize("normalize", [True, False]) def test_cell_transition_pipeline(self, adata_space_rotate: AnnData, forward: bool, normalize: bool): @@ -93,7 +93,7 @@ def test_cell_transition_pipeline(self, adata_space_rotate: AnnData, forward: bo assert isinstance(result, pd.DataFrame) assert result.shape == (3, 3) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("forward", [True, False]) @pytest.mark.parametrize("mapping_mode", ["max", "sum"]) @pytest.mark.parametrize("batch_size", [3, 7, None]) @@ -187,7 +187,7 @@ def test_regression_testing(self, adata_mapping: AnnData): np.array(sol[k].transport_matrix), np.array(mp.solutions[k].transport_matrix), decimal=3 ) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("forward", [True, False]) @pytest.mark.parametrize("normalize", [True, False]) def test_cell_transition_pipeline(self, adata_mapping: AnnData, forward: bool, normalize: bool): @@ -215,7 +215,7 @@ def test_cell_transition_pipeline(self, adata_mapping: AnnData, forward: bool, n assert isinstance(result, pd.DataFrame) assert result.shape == (3, 4) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("forward", [True, False]) @pytest.mark.parametrize("mapping_mode", ["max", "sum"]) @pytest.mark.parametrize("batch_size", [3, 7, None]) diff --git a/tests/problems/spatio_temporal/conftest.py b/tests/problems/spatio_temporal/conftest.py index bc19bcd8a..e29c381a1 100644 --- a/tests/problems/spatio_temporal/conftest.py +++ b/tests/problems/spatio_temporal/conftest.py @@ -7,7 +7,7 @@ from tests._utils import _make_grid -@pytest.fixture() +@pytest.fixture def adata_spatio_temporal(adata_time: AnnData) -> AnnData: _, t_unique_counts = np.unique(adata_time.obs["time"], return_counts=True) grids = [] diff --git a/tests/problems/spatio_temporal/test_spatio_temporal_problem.py b/tests/problems/spatio_temporal/test_spatio_temporal_problem.py index e7d35c82c..3b68561ba 100644 --- a/tests/problems/spatio_temporal/test_spatio_temporal_problem.py +++ b/tests/problems/spatio_temporal/test_spatio_temporal_problem.py @@ -27,7 +27,7 @@ class TestSpatioTemporalProblem: - @pytest.mark.fast() + @pytest.mark.fast def test_prepare(self, adata_spatio_temporal: AnnData): expected_keys = [(0, 1), (1, 2)] problem = SpatioTemporalProblem(adata=adata_spatio_temporal) @@ -88,7 +88,7 @@ def test_solve_unbalanced(self, adata_spatio_temporal: AnnData): div2 = np.linalg.norm(problem1[0, 1].b - problem1[0, 1].solution.b) assert div1 < div2 - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize( "gene_set_list", [ @@ -120,7 +120,7 @@ def test_score_genes(self, adata_spatio_temporal: AnnData, gene_set_list: List[L else: assert problem.apoptosis_key is None - @pytest.mark.fast() + @pytest.mark.fast def test_proliferation_key_pipeline(self, adata_spatio_temporal: AnnData): problem = SpatioTemporalProblem(adata_spatio_temporal) assert problem.proliferation_key is None @@ -132,7 +132,7 @@ def test_proliferation_key_pipeline(self, adata_spatio_temporal: AnnData): problem.proliferation_key = "new_proliferation" assert problem.proliferation_key == "new_proliferation" - @pytest.mark.fast() + @pytest.mark.fast def test_apoptosis_key_pipeline(self, adata_spatio_temporal: AnnData): problem = SpatioTemporalProblem(adata_spatio_temporal) assert problem.apoptosis_key is None @@ -144,7 +144,7 @@ def test_apoptosis_key_pipeline(self, adata_spatio_temporal: AnnData): problem.apoptosis_key = "new_apoptosis" assert problem.apoptosis_key == "new_apoptosis" - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("scaling", [0.1, 1, 4]) def test_proliferation_key_c_pipeline(self, adata_spatio_temporal: AnnData, scaling: float): key0, key1, *_ = np.sort(np.unique(adata_spatio_temporal.obs["time"].values)) diff --git a/tests/problems/time/conftest.py b/tests/problems/time/conftest.py index 8975411ac..4b69cd4c7 100644 --- a/tests/problems/time/conftest.py +++ b/tests/problems/time/conftest.py @@ -8,7 +8,7 @@ from moscot.datasets import _get_random_trees -@pytest.fixture() +@pytest.fixture def adata_time_trees(adata_time: AnnData) -> AnnData: trees = _get_random_trees( n_leaves=96, n_trees=3, leaf_names=[list(adata_time[adata_time.obs.time == i].obs.index) for i in range(3)] @@ -17,7 +17,7 @@ def adata_time_trees(adata_time: AnnData) -> AnnData: return adata_time -@pytest.fixture() +@pytest.fixture def adata_time_custom_cost_xy(adata_time: AnnData) -> AnnData: rng = np.random.RandomState(42) cost_m1 = np.abs(rng.randn(96, 96)) @@ -27,14 +27,14 @@ def adata_time_custom_cost_xy(adata_time: AnnData) -> AnnData: return adata_time -@pytest.fixture() +@pytest.fixture def adata_time_barcodes(adata_time: AnnData) -> AnnData: rng = np.random.RandomState(42) adata_time.obsm["barcodes"] = rng.randn(len(adata_time), 30) return adata_time -@pytest.fixture() +@pytest.fixture def adata_time_marginal_estimations(adata_time: AnnData) -> AnnData: rng = np.random.RandomState(42) adata_time.obs["proliferation"] = rng.randn(len(adata_time)) diff --git a/tests/problems/time/test_lineage_problem.py b/tests/problems/time/test_lineage_problem.py index fa79fbb74..5375c621e 100644 --- a/tests/problems/time/test_lineage_problem.py +++ b/tests/problems/time/test_lineage_problem.py @@ -26,7 +26,7 @@ class TestLineageProblem: - @pytest.mark.fast() + @pytest.mark.fast def test_prepare(self, adata_time_barcodes: AnnData): expected_keys = [(0, 1), (1, 2)] problem = LineageProblem(adata=adata_time_barcodes) @@ -94,7 +94,7 @@ def test_solve_unbalanced(self, adata_time_barcodes: AnnData): div2 = np.linalg.norm(problem1[0, 1].b - problem1[0, 1].solution.b) assert div1 < div2 - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize( "gene_set_list", [ @@ -126,7 +126,7 @@ def test_score_genes(self, adata_time_barcodes: AnnData, gene_set_list: List[Lis else: assert problem.apoptosis_key is None - @pytest.mark.fast() + @pytest.mark.fast def test_proliferation_key_pipeline(self, adata_time_barcodes: AnnData): problem = LineageProblem(adata_time_barcodes) assert problem.proliferation_key is None @@ -138,7 +138,7 @@ def test_proliferation_key_pipeline(self, adata_time_barcodes: AnnData): problem.proliferation_key = "new_proliferation" assert problem.proliferation_key == "new_proliferation" - @pytest.mark.fast() + @pytest.mark.fast def test_apoptosis_key_pipeline(self, adata_time_barcodes: AnnData): problem = LineageProblem(adata_time_barcodes) assert problem.apoptosis_key is None @@ -150,7 +150,7 @@ def test_apoptosis_key_pipeline(self, adata_time_barcodes: AnnData): problem.apoptosis_key = "new_apoptosis" assert problem.apoptosis_key == "new_apoptosis" - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("scaling", [0.1, 1, 4]) def test_proliferation_key_c_pipeline(self, adata_time_barcodes: AnnData, scaling: float): key0, key1, *_ = np.sort(np.unique(adata_time_barcodes.obs["time"].values)) @@ -173,7 +173,7 @@ def test_proliferation_key_c_pipeline(self, adata_time_barcodes: AnnData, scalin expected_marginals = np.exp((prolif - apopt) * delta / scaling) np.testing.assert_allclose(problem[key0, key1]._prior_growth, expected_marginals, rtol=RTOL, atol=ATOL) - @pytest.mark.fast() + @pytest.mark.fast def test_barcodes_pipeline(self, adata_time_barcodes: AnnData): expected_keys = [(0, 1), (1, 2)] problem = LineageProblem(adata=adata_time_barcodes) diff --git a/tests/problems/time/test_mixins.py b/tests/problems/time/test_mixins.py index ebb7f950f..bc116a704 100644 --- a/tests/problems/time/test_mixins.py +++ b/tests/problems/time/test_mixins.py @@ -13,7 +13,7 @@ class TestTemporalMixin: - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("forward", [True, False]) def test_cell_transition_full_pipeline(self, gt_temporal_adata: AnnData, forward: bool): config = gt_temporal_adata.uns @@ -51,7 +51,7 @@ def test_cell_transition_full_pipeline(self, gt_temporal_adata: AnnData, forward present_cell_type_marginal = marginal[marginal > 0] np.testing.assert_allclose(present_cell_type_marginal, 1.0) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("forward", [True, False]) @pytest.mark.parametrize("mapping_mode", ["max", "sum"]) @pytest.mark.parametrize("batch_size", [3, 7, None]) @@ -81,7 +81,7 @@ def test_annotation_mapping(self, adata_anno: AnnData, forward: bool, mapping_mo ) assert (result[annotation_label] == expected_result).all() - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("forward", [True, False]) def test_cell_transition_different_groups(self, gt_temporal_adata: AnnData, forward: bool): config = gt_temporal_adata.uns @@ -111,7 +111,7 @@ def test_cell_transition_different_groups(self, gt_temporal_adata: AnnData, forw assert set(result.index) == cell_types assert set(result.columns) == batches - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("forward", [True, False]) def test_cell_transition_subset_pipeline(self, gt_temporal_adata: AnnData, forward: bool): config = gt_temporal_adata.uns @@ -339,7 +339,7 @@ def test_compute_random_distance_regression(self, gt_temporal_adata: AnnData): np.testing.assert_allclose(result, gt_temporal_adata.uns["random_distance_10_105_11"], rtol=1e-6, atol=1e-6) # TODO(MUCDK): split into 2 tests - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("only_start", [True, False]) def test_get_data_pipeline(self, adata_time: AnnData, only_start: bool): problem = TemporalProblem(adata_time) @@ -379,7 +379,7 @@ def test_get_interp_param_pipeline(self, adata_time: AnnData, time_points: Tuple inter_param = problem._get_interp_param(start, intermediate, end, interpolation_parameter) assert inter_param == 0.5 - @pytest.mark.fast() + @pytest.mark.fast def test_cell_transition_regression_notparam( self, adata_time_with_tmap: AnnData, @@ -399,7 +399,7 @@ def test_cell_transition_regression_notparam( # TODO(MUCDK): use pandas.testing np.testing.assert_allclose(res.values, df_expected.values, rtol=1e-6, atol=1e-6) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("temporal_key", ["celltype", "time", "missing"]) def test_temporal_key_numeric(self, adata_time: AnnData, temporal_key: str): problem = TemporalProblem(adata_time) diff --git a/tests/problems/time/test_temporal_base_problem.py b/tests/problems/time/test_temporal_base_problem.py index 880fbb7dd..abdfe0f90 100644 --- a/tests/problems/time/test_temporal_base_problem.py +++ b/tests/problems/time/test_temporal_base_problem.py @@ -11,7 +11,7 @@ # TODO(@MUCDK) put file in different folder according to moscot.problems structure class TestBirthDeathProblem: - @pytest.mark.fast() + @pytest.mark.fast def test_initialization_pipeline(self, adata_time_marginal_estimations: AnnData): t1, t2 = 0, 1 adata_x = adata_time_marginal_estimations[adata_time_marginal_estimations.obs["time"] == t1] @@ -35,7 +35,7 @@ def test_initialization_pipeline(self, adata_time_marginal_estimations: AnnData) assert isinstance(prob.b, np.ndarray) # TODO(MUCDK): break this test - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize( "adata_obs_keys", [ @@ -77,7 +77,7 @@ def test_estimate_marginals_pipeline( if not source: assert len(np.unique(a_estimated)) == 1 - @pytest.mark.fast() + @pytest.mark.fast def test_prior_growth_rates(self, adata_time_marginal_estimations: AnnData): t1, t2 = 0, 1 adata_x = adata_time_marginal_estimations[adata_time_marginal_estimations.obs["time"] == t1] @@ -117,7 +117,7 @@ def test_posterior_growth_rates(self, adata_time_marginal_estimations: AnnData): gr = prob.posterior_growth_rates assert isinstance(gr, np.ndarray) - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize( "marginal_kwargs", [{}, {"delta_width": 0.9}, {"delta_center": 0.9}, {"beta_width": 0.9}, {"beta_center": 0.9}] ) diff --git a/tests/problems/time/test_temporal_problem.py b/tests/problems/time/test_temporal_problem.py index 5a4f92df7..f53a745c9 100644 --- a/tests/problems/time/test_temporal_problem.py +++ b/tests/problems/time/test_temporal_problem.py @@ -31,7 +31,7 @@ class TestTemporalProblem: - @pytest.mark.fast() + @pytest.mark.fast def test_prepare(self, adata_time: AnnData): expected_keys = [(0, 1), (1, 2)] problem = TemporalProblem(adata=adata_time) @@ -90,7 +90,7 @@ def test_solve_unbalanced(self, adata_time: AnnData): div2 = np.linalg.norm(problem1[0, 1].b - problem1[0, 1].solution.b) assert div1 < div2 - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize( "gene_set_list", [ @@ -122,7 +122,7 @@ def test_score_genes(self, adata_time: AnnData, gene_set_list: List[List[str]]): else: assert problem.apoptosis_key is None - @pytest.mark.fast() + @pytest.mark.fast def test_proliferation_key_pipeline(self, adata_time: AnnData): problem = TemporalProblem(adata_time) assert problem.proliferation_key is None @@ -134,7 +134,7 @@ def test_proliferation_key_pipeline(self, adata_time: AnnData): problem.proliferation_key = "new_proliferation" assert problem.proliferation_key == "new_proliferation" - @pytest.mark.fast() + @pytest.mark.fast def test_apoptosis_key_pipeline(self, adata_time: AnnData): problem = TemporalProblem(adata_time) assert problem.apoptosis_key is None @@ -146,7 +146,7 @@ def test_apoptosis_key_pipeline(self, adata_time: AnnData): problem.apoptosis_key = "new_apoptosis" assert problem.apoptosis_key == "new_apoptosis" - @pytest.mark.fast() + @pytest.mark.fast @pytest.mark.parametrize("scaling", [0.1, 1, 4]) def test_proliferation_key_c_pipeline(self, adata_time: AnnData, scaling: float): key0, key1, *_ = np.sort(np.unique(adata_time.obs["time"].values))