This commit is contained in:
Blake Griffith
2015-05-19 17:05:48 -05:00
parent 54e95cff9b
commit 4a47127871
2 changed files with 5 additions and 2 deletions
+3 -2
View File
@@ -27,7 +27,8 @@ def _get_chunks(shape, ncpu):
return tuple(chunks)
def process_chunks(function, array, args=(), kwargs={} chunks=None, depth=0, mode=None):
def process_chunks(function, array, args=(), kwargs={}, chunks=None, depth=0,
mode=None):
"""Map a function in parallel across an array.
Split an array into possibly overlapping chunks of a given depth and
@@ -56,7 +57,7 @@ def process_chunks(function, array, args=(), kwargs={} chunks=None, depth=0, mod
a chunk.
"""
if chunks == None:
if chunks is None:
shape = array.shape
ncpu = cpu_count()
chunks = _get_chunks(shape, ncpu)
+2
View File
@@ -4,6 +4,7 @@ from numpy.testing import assert_array_almost_equal
from skimage.filters import threshold_adaptive, gaussian_filter
from skimage.util import process_chunks
def test_process_chunks():
# data
a = np.arange(144).reshape(12, 12).astype(float)
@@ -31,6 +32,7 @@ def test_process_chunks():
def test_no_chunks():
a = np.ones(1 * 4 * 8 * 9).reshape(1, 4, 8, 9)
def add_42(arr):
return arr + 42