Skip to content

Commit

Permalink
Add test for test_distances.py
Browse files Browse the repository at this point in the history
Catches error as reported in Issue #385.
  • Loading branch information
stefanpeidli committed Sep 28, 2023
1 parent e78e235 commit 54f34d1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/tools/_distances/test_distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,18 @@ def test_distance_axioms(self, adata, distance):
triplet = np.random.choice(df.index, size=3, replace=False)
assert df.loc[triplet[0], triplet[1]] + df.loc[triplet[1], triplet[2]] >= df.loc[triplet[0], triplet[2]]

@mark.parametrize("distance", actual_distances + pseudo_distances)
def test_distance_output_type(self, distance):
# Test if distances are outputting floats
Distance = pt.tl.Distance(distance, "X_pca")
X = np.random.normal(size=(100, 10))
Y = np.random.normal(size=(100, 10))
d = Distance(X, Y)
assert isinstance(d, float)

@mark.parametrize("distance", actual_distances + pseudo_distances)
def test_distance_pairwise(self, adata, distance):
# Test consistency of pairwise distance results
Distance = pt.tl.Distance(distance, "X_pca")
df = Distance.pairwise(adata, groupby="perturbation", show_progressbar=True)
assert isinstance(df, DataFrame)
Expand All @@ -39,6 +49,7 @@ def test_distance_pairwise(self, adata, distance):

@mark.parametrize("distance", actual_distances + pseudo_distances)
def test_distance_onesided(self, adata, distance):
# Test consistency of one-sided distance results
Distance = pt.tl.Distance(distance, "X_pca")
selected_group = adata.obs.perturbation.unique()[0]
df = Distance.onesided_distances(
Expand Down

0 comments on commit 54f34d1

Please sign in to comment.