Skip to content

Commit 5e26e26

Browse files
committed
Skip sklearnex test when scikit-learn-intelex is unavailable
scikit-learn-intelex may not be installable with newer NumPy versions (e.g. NumPy 2.4 from the updated Colab base image). Rather than fail the entire test suite, skip the test gracefully when the module is not present.
1 parent 0cd2371 commit 5e26e26

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tests/test_sklearnex.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
import numpy as np
44

5+
try:
6+
from sklearnex.cluster import DBSCAN
7+
HAS_SKLEARNEX = True
8+
except ImportError:
9+
HAS_SKLEARNEX = False
10+
11+
@unittest.skipUnless(HAS_SKLEARNEX, 'scikit-learn-intelex is not installed')
512
class TestSklearnex(unittest.TestCase):
613
def test_dbscan(self):
714
from sklearnex.cluster import DBSCAN
815
X = np.array([[1., 2.], [2., 2.], [2., 3.],
916
[8., 7.], [8., 8.], [25., 80.]], dtype=np.float32)
1017

1118
clustering = DBSCAN(eps=3, min_samples=2).fit(X)
12-
np.testing.assert_array_equal(np.array([0, 0, 0, 1, 1, -1]), clustering.labels_)
19+
np.testing.assert_array_equal(np.array([0, 0, 0, 1, 1, -1]), clustering.labels_)

0 commit comments

Comments
 (0)