Skip to content

Commit

Permalink
Fix kmeans test instability
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgayoso authored Aug 21, 2024
1 parent 0071da9 commit e742000
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/test_metrics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import anndata
import igraph
import jax
import jax.numpy as jnp
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -135,9 +136,11 @@ def test_isolated_labels():
def test_kmeans():
centers = [[1, 1], [-1, -1], [1, -1]]
len(centers)
X, labels_true = make_blobs(n_samples=3000, centers=centers, cluster_std=0.7)
kmeans = scib_metrics.utils.KMeans(n_clusters=3)
kmeans.fit(X)
X, labels_true = make_blobs(n_samples=3000, centers=centers, cluster_std=0.7, random_state=42)

with jax.experimental.enable_x64():
kmeans = scib_metrics.utils.KMeans(n_clusters=3)
kmeans.fit(X)
assert kmeans.labels_.shape == (X.shape[0],)

skmeans = SKMeans(n_clusters=3)
Expand Down

0 comments on commit e742000

Please sign in to comment.