From a258fc7b3bea17223744a6f8b61f5af1e3334b19 Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Sat, 16 May 2015 19:36:59 -0500 Subject: [PATCH] Rename apply and apply_chunks to apply_parallel --- skimage/util/__init__.py | 4 ++-- skimage/util/{apply.py => apply_parallel.py} | 4 ++-- .../{test_apply.py => test_apply_parallel.py} | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) rename skimage/util/{apply.py => apply_parallel.py} (97%) rename skimage/util/tests/{test_apply.py => test_apply_parallel.py} (73%) diff --git a/skimage/util/__init__.py b/skimage/util/__init__.py index 40f17955..2500469b 100644 --- a/skimage/util/__init__.py +++ b/skimage/util/__init__.py @@ -2,7 +2,7 @@ from .dtype import (img_as_float, img_as_int, img_as_uint, img_as_ubyte, img_as_bool, dtype_limits) from .shape import view_as_blocks, view_as_windows from .noise import random_noise -from .apply import apply_chunks +from .apply_parallel import apply_parallel from .arraypad import pad, crop from ._regular_grid import regular_grid @@ -21,5 +21,5 @@ __all__ = ['img_as_float', 'crop', 'random_noise', 'regular_grid', - 'apply_chunks', + 'apply_parallel', 'unique_rows'] diff --git a/skimage/util/apply.py b/skimage/util/apply_parallel.py similarity index 97% rename from skimage/util/apply.py rename to skimage/util/apply_parallel.py index a63be1c1..d9142b91 100644 --- a/skimage/util/apply.py +++ b/skimage/util/apply_parallel.py @@ -3,7 +3,7 @@ from multiprocessing import cpu_count import dask.array as da -__all__ = ['apply_chunks'] +__all__ = ['apply_parallel'] def _get_chunks(shape, ncpu): @@ -44,7 +44,7 @@ def _get_chunks(shape, ncpu): return tuple(chunks) -def apply_chunks(function, array, chunks=None, depth=0, mode=None, +def apply_parallel(function, array, chunks=None, depth=0, mode=None, extra_arguments=(), extra_keywords={}): """Map a function in parallel across an array. diff --git a/skimage/util/tests/test_apply.py b/skimage/util/tests/test_apply_parallel.py similarity index 73% rename from skimage/util/tests/test_apply.py rename to skimage/util/tests/test_apply_parallel.py index 561f3c10..c0d3f44d 100644 --- a/skimage/util/tests/test_apply.py +++ b/skimage/util/tests/test_apply_parallel.py @@ -2,16 +2,16 @@ import numpy as np from numpy.testing import assert_array_almost_equal from skimage.filters import threshold_adaptive, gaussian_filter -from skimage.util import apply_chunks +from skimage.util import apply_parallel -def test_apply_chunks(): +def test_apply_parallel(): # data a = np.arange(144).reshape(12, 12).astype(float) # apply the filter expected1 = threshold_adaptive(a, 3) - result1 = apply_chunks(threshold_adaptive, a, chunks=(6, 6), depth=5, + result1 = apply_parallel(threshold_adaptive, a, chunks=(6, 6), depth=5, extra_arguments=(3,), extra_keywords={'mode': 'reflect'}) @@ -21,7 +21,7 @@ def test_apply_chunks(): return gaussian_filter(arr, 1, mode='reflect') expected2 = gaussian_filter(a, 1, mode='reflect') - result2 = apply_chunks(wrapped_gauss, a, chunks=(6, 6), depth=5) + result2 = apply_parallel(wrapped_gauss, a, chunks=(6, 6), depth=5) assert_array_almost_equal(result2, expected2) @@ -33,27 +33,27 @@ def test_no_chunks(): return arr + 42 expected = add_42(a) - result = apply_chunks(add_42, a) + result = apply_parallel(add_42, a) assert_array_almost_equal(result, expected) -def test_apply_chunks_wrap(): +def test_apply_parallel_wrap(): def wrapped(arr): return gaussian_filter(arr, 1, mode='wrap') a = np.arange(144).reshape(12, 12).astype(float) expected = gaussian_filter(a, 1, mode='wrap') - result = apply_chunks(wrapped, a, chunks=(6, 6), depth=5, mode='wrap') + result = apply_parallel(wrapped, a, chunks=(6, 6), depth=5, mode='wrap') assert_array_almost_equal(result, expected) -def test_apply_chunks_nearest(): +def test_apply_parallel_nearest(): def wrapped(arr): return gaussian_filter(arr, 1, mode='nearest') a = np.arange(144).reshape(12, 12).astype(float) expected = gaussian_filter(a, 1, mode='nearest') - result = apply_chunks(wrapped, a, chunks=(6, 6), depth={0: 5, 1: 5}, + result = apply_parallel(wrapped, a, chunks=(6, 6), depth={0: 5, 1: 5}, mode='nearest') assert_array_almost_equal(result, expected)