Skip to content

Commit 301f0b7

Browse files
test distance correlation
Former-commit-id: 8e26833
1 parent 5e13d50 commit 301f0b7

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

test/test_task_dimensionality_reduction.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Specific tests for the dimensionality_reduction task"""
22
import openproblems
3+
import parameterized
34
import utils.docker
45
import utils.git
56

@@ -54,6 +55,26 @@ def test_density_preservation_matches_densmap():
5455
np.testing.assert_allclose(expected, actual, rtol=1e-3)
5556

5657

58+
@parameterized.parameterized.expand(
59+
[(200,), (1000,)],
60+
name_func=utils.name.name_test,
61+
)
62+
def test_distance_correlation_with_svd(n_svd):
63+
import numpy as np
64+
65+
task = openproblems.tasks.dimensionality_reduction
66+
metric = openproblems.tasks.dimensionality_reduction.metrics.distance_correlation
67+
68+
adata = task.api.sample_dataset()
69+
adata = task.api.sample_method(adata)
70+
adata.obsm["X_emb"] = adata.X.toarray()
71+
72+
expected = 1
73+
actual = metric(adata, n_svd=n_svd)
74+
75+
np.testing.assert_allclose(expected, actual, rtol=1e-3)
76+
77+
5778
def test_density_preservation_perfect():
5879
import numpy as np
5980

0 commit comments

Comments
 (0)