From 3f0c6e460e69b9235344dfc9ed9d300b1e8e6591 Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Wed, 3 Jul 2024 17:56:14 +0200 Subject: [PATCH 1/3] skip tests --- tests/problems/time/test_mixins.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/problems/time/test_mixins.py b/tests/problems/time/test_mixins.py index e5c9e36f8..702a476ad 100644 --- a/tests/problems/time/test_mixins.py +++ b/tests/problems/time/test_mixins.py @@ -1,3 +1,4 @@ +import sys from typing import Tuple import pytest @@ -235,6 +236,7 @@ def test_compute_interpolated_distance_pipeline(self, gt_temporal_adata: AnnData assert isinstance(interpolation_result, float) assert interpolation_result > 0 + @pytest.mark.skipif(sys.version_info < (3, 9), reason="requires python3.9 or higher") def test_compute_interpolated_distance_regression(self, gt_temporal_adata: AnnData): config = gt_temporal_adata.uns key = config["key"] @@ -263,6 +265,7 @@ def test_compute_interpolated_distance_regression(self, gt_temporal_adata: AnnDa interpolation_result, gt_temporal_adata.uns["interpolated_distance_10_105_11"], rtol=1e-6, atol=1e-6 ) + @pytest.mark.skipif(sys.version_info < (3, 9), reason="requires python3.9 or higher") def test_compute_time_point_distances_regression(self, gt_temporal_adata: AnnData): config = gt_temporal_adata.uns key = config["key"] @@ -316,6 +319,7 @@ def test_compute_batch_distances_regression(self, gt_temporal_adata: AnnData): assert isinstance(result, float) np.testing.assert_allclose(result, gt_temporal_adata.uns["batch_distances_10"], rtol=1e-5) + @pytest.mark.skipif(sys.version_info < (3, 9), reason="requires python3.9 or higher") def test_compute_random_distance_regression(self, gt_temporal_adata: AnnData): config = gt_temporal_adata.uns key = config["key"] From 9ee27a5ae5c52598fe386f6a56d20ac0b996e4d7 Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Wed, 3 Jul 2024 19:47:32 +0200 Subject: [PATCH 2/3] remove elastic cost --- src/moscot/_types.py | 4 ---- src/moscot/backends/ott/__init__.py | 4 ---- tests/backends/ott/test_backend.py | 2 +- tests/costs/test_utils.py | 4 ---- tests/problems/generic/test_fgw_problem.py | 9 --------- tests/problems/generic/test_gw_problem.py | 9 --------- tests/problems/generic/test_sinkhorn_problem.py | 9 --------- tests/utils/test_tagged_array.py | 4 ---- 8 files changed, 1 insertion(+), 44 deletions(-) diff --git a/src/moscot/_types.py b/src/moscot/_types.py index 024471886..1c60884a2 100644 --- a/src/moscot/_types.py +++ b/src/moscot/_types.py @@ -36,10 +36,6 @@ "pnorm_p", "sq_pnorm", "cosine", - "elastic_l1", - "elastic_l2", - "elastic_stvs", - "elastic_sqk_overlap", "geodesic", ] OttCostFnMap_t = Union[OttCostFn_t, Mapping[Literal["xy", "x", "y"], OttCostFn_t]] diff --git a/src/moscot/backends/ott/__init__.py b/src/moscot/backends/ott/__init__.py index 9b7737bfc..40f1cba6c 100644 --- a/src/moscot/backends/ott/__init__.py +++ b/src/moscot/backends/ott/__init__.py @@ -12,7 +12,3 @@ register_cost("cosine", backend="ott")(costs.Cosine) register_cost("pnorm_p", backend="ott")(costs.PNormP) register_cost("sq_pnorm", backend="ott")(costs.SqPNorm) -register_cost("elastic_l1", backend="ott")(costs.ElasticL1) -register_cost("elastic_l2", backend="ott")(costs.ElasticL2) -register_cost("elastic_stvs", backend="ott")(costs.ElasticSTVS) -register_cost("elastic_sqk_overlap", backend="ott")(costs.ElasticSqKOverlap) diff --git a/tests/backends/ott/test_backend.py b/tests/backends/ott/test_backend.py index f599a2a1f..f982bf148 100644 --- a/tests/backends/ott/test_backend.py +++ b/tests/backends/ott/test_backend.py @@ -69,7 +69,7 @@ def test_solver_rank(self, y: Geom_t, rank: Optional[int], initializer: str): np.testing.assert_allclose(gt.matrix, pred.transport_matrix, rtol=RTOL, atol=ATOL) @pytest.mark.parametrize( - ("rank", "cost_fn"), [(2, costs.Euclidean()), (3, costs.SqPNorm(p=1.5)), (5, costs.ElasticL1(0.1))] + ("rank", "cost_fn"), [(2, costs.Euclidean()), (3, costs.SqPNorm(p=1.5))] ) def test_geometry_rank(self, x: Geom_t, rank: int, cost_fn: costs.CostFn): eps = 0.05 diff --git a/tests/costs/test_utils.py b/tests/costs/test_utils.py index 6ec834fb3..f3ef09816 100644 --- a/tests/costs/test_utils.py +++ b/tests/costs/test_utils.py @@ -16,10 +16,6 @@ class TestCostUtils: "cosine", "pnorm_p", "sq_pnorm", - "elastic_l1", - "elastic_l2", - "elastic_stvs", - "elastic_sqk_overlap", ), } diff --git a/tests/problems/generic/test_fgw_problem.py b/tests/problems/generic/test_fgw_problem.py index 52d040d51..c866c9587 100644 --- a/tests/problems/generic/test_fgw_problem.py +++ b/tests/problems/generic/test_fgw_problem.py @@ -7,9 +7,6 @@ from ott.geometry import epsilon_scheduler from ott.geometry.costs import ( Cosine, - ElasticL1, - ElasticL2, - ElasticSTVS, Euclidean, PNormP, SqEuclidean, @@ -191,9 +188,6 @@ def test_set_xy(self, adata_time: AnnData, tag: Literal["cost_matrix", "kernel"] ("cosine", Cosine, {}), ("pnorm_p", PNormP, {"p": 3}), ("sq_pnorm", SqPNorm, {"xy": {"p": 5}, "x": {"p": 3}, "y": {"p": 4}}), - ("elastic_l1", ElasticL1, {"scaling_reg": 1.1}), - ("elastic_l2", ElasticL2, {"scaling_reg": 1.1}), - ("elastic_stvs", ElasticSTVS, {"scaling_reg": 1.2}), ], ) def test_prepare_costs(self, adata_time: AnnData, cost_str: str, cost_inst: Any, cost_kwargs: CostKwargs_t): @@ -234,9 +228,6 @@ def test_prepare_costs(self, adata_time: AnnData, cost_str: str, cost_inst: Any, ("cosine", Cosine, {}), ("pnorm_p", PNormP, {"p": 3}), ("sq_pnorm", SqPNorm, {"xy": {"p": 5}, "x": {"p": 3}, "y": {"p": 4}}), - ("elastic_l1", ElasticL1, {"scaling_reg": 1.1}), - ("elastic_l2", ElasticL2, {"scaling_reg": 1.1}), - ("elastic_stvs", ElasticSTVS, {"scaling_reg": 1.2}), ], ) def test_prepare_costs_with_callback( diff --git a/tests/problems/generic/test_gw_problem.py b/tests/problems/generic/test_gw_problem.py index 5b13c8f2f..d72893304 100644 --- a/tests/problems/generic/test_gw_problem.py +++ b/tests/problems/generic/test_gw_problem.py @@ -7,9 +7,6 @@ from ott.geometry import epsilon_scheduler from ott.geometry.costs import ( Cosine, - ElasticL1, - ElasticL2, - ElasticSTVS, Euclidean, PNormP, SqEuclidean, @@ -165,9 +162,6 @@ def test_pass_arguments(self, adata_space_rotate: AnnData, args_to_check: Mappin ("cosine", Cosine, {}), ("pnorm_p", PNormP, {"p": 3}), ("sq_pnorm", SqPNorm, {"x": {"p": 3}, "y": {"p": 4}}), - ("elastic_l1", ElasticL1, {"x": {"scaling_reg": 3}, "y": {"scaling_reg": 4}}), - ("elastic_l2", ElasticL2, {"x": {"scaling_reg": 3}, "y": {"scaling_reg": 4}}), - ("elastic_stvs", ElasticSTVS, {"x": {"scaling_reg": 3}, "y": {"scaling_reg": 4}}), ], ) def test_prepare_costs(self, adata_time: AnnData, cost_str: str, cost_inst: Any, cost_kwargs: CostKwargs_t): @@ -206,9 +200,6 @@ def test_prepare_marginals(self, adata_time: AnnData, marginal_keys): ("cosine", Cosine, {}), ("pnorm_p", PNormP, {"p": 3}), ("sq_pnorm", SqPNorm, {"x": {"p": 3}, "y": {"p": 4}}), - ("elastic_l1", ElasticL1, {"x": {"scaling_reg": 3}, "y": {"scaling_reg": 4}}), - ("elastic_l2", ElasticL2, {"x": {"scaling_reg": 3}, "y": {"scaling_reg": 4}}), - ("elastic_stvs", ElasticSTVS, {"x": {"scaling_reg": 3}, "y": {"scaling_reg": 4}}), ], ) def test_prepare_costs_with_callback( diff --git a/tests/problems/generic/test_sinkhorn_problem.py b/tests/problems/generic/test_sinkhorn_problem.py index cc8b8af76..03acf0962 100644 --- a/tests/problems/generic/test_sinkhorn_problem.py +++ b/tests/problems/generic/test_sinkhorn_problem.py @@ -7,9 +7,6 @@ from ott.geometry import epsilon_scheduler from ott.geometry.costs import ( Cosine, - ElasticL1, - ElasticL2, - ElasticSTVS, Euclidean, PNormP, SqEuclidean, @@ -79,9 +76,6 @@ def test_solve_balanced(self, adata_time: AnnData, marginal_keys): ("cosine", Cosine, {}), ("pnorm_p", PNormP, {"p": 3}), ("sq_pnorm", SqPNorm, {"p": 3}), - ("elastic_l1", ElasticL1, {"scaling_reg": 1.1}), - ("elastic_l2", ElasticL2, {"scaling_reg": 1.1}), - ("elastic_stvs", ElasticSTVS, {"scaling_reg": 1.2}), ], ) def test_prepare_costs(self, adata_time: AnnData, cost_str: str, cost_inst: Any, cost_kwargs: Mapping[str, int]): @@ -104,9 +98,6 @@ def test_prepare_costs(self, adata_time: AnnData, cost_str: str, cost_inst: Any, ("cosine", Cosine, {}), ("pnorm_p", PNormP, {"p": 3}), ("sq_pnorm", SqPNorm, {"p": 3}), - ("elastic_l1", ElasticL1, {"scaling_reg": 1.1}), - ("elastic_l2", ElasticL2, {"scaling_reg": 1.1}), - ("elastic_stvs", ElasticSTVS, {"scaling_reg": 1.2}), ], ) def test_prepare_costs_with_callback( diff --git a/tests/utils/test_tagged_array.py b/tests/utils/test_tagged_array.py index 9959c44a0..12b62e87b 100644 --- a/tests/utils/test_tagged_array.py +++ b/tests/utils/test_tagged_array.py @@ -16,10 +16,6 @@ class TestTaggedArray: ("cosine", {}), ("pnorm_p", {"p": 3}), ("sq_pnorm", {"p": 2}), - ("elastic_l1", {"scaling_reg": 1.3}), - ("elastic_l2", {}), - ("elastic_stvs", {}), - ("elastic_sqk_overlap", {"k": 1}), ], ) def test_from_adata_ott_cost_from_pointcloud(self, adata_time, cost: str, cost_kwargs: Mapping[str, Any]): From bd6f39bedde047e936e051e05ce02269bf666f6c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2024 17:47:53 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/backends/ott/test_backend.py | 4 +--- tests/problems/generic/test_fgw_problem.py | 8 +------- tests/problems/generic/test_gw_problem.py | 8 +------- tests/problems/generic/test_sinkhorn_problem.py | 8 +------- 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/tests/backends/ott/test_backend.py b/tests/backends/ott/test_backend.py index f982bf148..51c996946 100644 --- a/tests/backends/ott/test_backend.py +++ b/tests/backends/ott/test_backend.py @@ -68,9 +68,7 @@ def test_solver_rank(self, y: Geom_t, rank: Optional[int], initializer: str): np.testing.assert_allclose(solver._problem.geom.cost_matrix, problem.geom.cost_matrix, rtol=RTOL, atol=ATOL) np.testing.assert_allclose(gt.matrix, pred.transport_matrix, rtol=RTOL, atol=ATOL) - @pytest.mark.parametrize( - ("rank", "cost_fn"), [(2, costs.Euclidean()), (3, costs.SqPNorm(p=1.5))] - ) + @pytest.mark.parametrize(("rank", "cost_fn"), [(2, costs.Euclidean()), (3, costs.SqPNorm(p=1.5))]) def test_geometry_rank(self, x: Geom_t, rank: int, cost_fn: costs.CostFn): eps = 0.05 geom = PointCloud(x, epsilon=eps, cost_fn=cost_fn).to_LRCGeometry(rank=rank) diff --git a/tests/problems/generic/test_fgw_problem.py b/tests/problems/generic/test_fgw_problem.py index c866c9587..143caab76 100644 --- a/tests/problems/generic/test_fgw_problem.py +++ b/tests/problems/generic/test_fgw_problem.py @@ -5,13 +5,7 @@ import numpy as np import pandas as pd from ott.geometry import epsilon_scheduler -from ott.geometry.costs import ( - Cosine, - Euclidean, - PNormP, - SqEuclidean, - SqPNorm, -) +from ott.geometry.costs import Cosine, Euclidean, PNormP, SqEuclidean, SqPNorm from ott.solvers.linear import acceleration from anndata import AnnData diff --git a/tests/problems/generic/test_gw_problem.py b/tests/problems/generic/test_gw_problem.py index d72893304..2fab94b5c 100644 --- a/tests/problems/generic/test_gw_problem.py +++ b/tests/problems/generic/test_gw_problem.py @@ -5,13 +5,7 @@ import numpy as np import pandas as pd from ott.geometry import epsilon_scheduler -from ott.geometry.costs import ( - Cosine, - Euclidean, - PNormP, - SqEuclidean, - SqPNorm, -) +from ott.geometry.costs import Cosine, Euclidean, PNormP, SqEuclidean, SqPNorm from ott.solvers.linear import acceleration from anndata import AnnData diff --git a/tests/problems/generic/test_sinkhorn_problem.py b/tests/problems/generic/test_sinkhorn_problem.py index 03acf0962..64a9bf249 100644 --- a/tests/problems/generic/test_sinkhorn_problem.py +++ b/tests/problems/generic/test_sinkhorn_problem.py @@ -5,13 +5,7 @@ import numpy as np import pandas as pd from ott.geometry import epsilon_scheduler -from ott.geometry.costs import ( - Cosine, - Euclidean, - PNormP, - SqEuclidean, - SqPNorm, -) +from ott.geometry.costs import Cosine, Euclidean, PNormP, SqEuclidean, SqPNorm from ott.solvers.linear import acceleration from anndata import AnnData