mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-04 13:14:23 +08:00
Turn dask into an optional dependency
Dask is not yet packaged on all platforms, so make it optional for now.
This commit is contained in:
@@ -4,6 +4,13 @@ from multiprocessing import cpu_count
|
||||
__all__ = ['apply_parallel']
|
||||
|
||||
|
||||
try:
|
||||
import dask.array as da
|
||||
dask_available = True
|
||||
except ImportError:
|
||||
dask_available = False
|
||||
|
||||
|
||||
def _get_chunks(shape, ncpu):
|
||||
"""Split the array into equal sized chunks based on the number of
|
||||
available processors. The last chunk in each dimension absorbs the
|
||||
@@ -82,7 +89,9 @@ def apply_parallel(function, array, chunks=None, depth=0, mode=None,
|
||||
equivalent `dask` boundary modes 'reflect', 'periodic' and 'nearest',
|
||||
respectively.
|
||||
"""
|
||||
import dask.array as da
|
||||
if not dask_available:
|
||||
raise RuntimeError("Could not import 'dask'. Please install "
|
||||
"using 'pip install dask'")
|
||||
|
||||
if chunks is None:
|
||||
shape = array.shape
|
||||
|
||||
Reference in New Issue
Block a user