Skip to content

Commit fb3d6a4

Browse files
committed
avoid import dask explicitely
1 parent f781be0 commit fb3d6a4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
def pytest_runtest_setup(item):
2121
fname = item.fspath.strpath
22+
print(item)
2223
if (fname.endswith(os.path.join('keras', '_generator.py')) or
2324
fname.endswith('miscellaneous.rst')):
2425
try:
@@ -31,7 +32,8 @@ def pytest_runtest_setup(item):
3132
import tensorflow # noqa
3233
except ImportError:
3334
pytest.skip('The tensorflow package is not installed.')
34-
elif "dask" in fname:
35+
elif (fname.endswith(os.path.join("dask", "utils.py")) or
36+
fname.endswith(os.path.join("dask", "_support.py"))):
3537
try:
3638
import dask # noqa
3739
except ImportError:

imblearn/dask/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import warnings
22

3-
from dask import array
3+
import numpy as np
44
from sklearn.exceptions import DataConversionWarning
55
from sklearn.utils.multiclass import _is_integral_float
66

@@ -9,7 +9,7 @@ def is_multilabel(y):
99
if not (y.ndim == 2 and y.shape[1] > 1):
1010
return False
1111

12-
labels = array.unique(y).compute()
12+
labels = np.unique(y).compute()
1313

1414
return len(labels) < 3 and (
1515
y.dtype.kind in 'biu' or _is_integral_float(labels)
@@ -34,12 +34,12 @@ def type_of_target(y):
3434
suffix = ""
3535

3636
# check float and contains non-integer float values
37-
if y.dtype.kind == 'f' and array.any(y != y.astype(int)):
37+
if y.dtype.kind == 'f' and np.any(y != y.astype(int)):
3838
# [.1, .2, 3] or [[.1, .2, 3]] or [[1., .2]] and not [1., 2., 3.]
3939
# NOTE: we don't check for infinite values
4040
return 'continuous' + suffix
4141

42-
labels = array.unique(y).compute()
42+
labels = np.unique(y).compute()
4343
if (len((labels)) > 2) or (y.ndim >= 2 and len(y[0]) > 1):
4444
# [1, 2, 3] or [[1., 2., 3]] or [[1, 2]]
4545
return 'multiclass' + suffix

0 commit comments

Comments
 (0)