From 69989c7846a1081d78caa50a98e528631b13f9e0 Mon Sep 17 00:00:00 2001 From: Genevieve Buckley <30920819+GenevieveBuckley@users.noreply.github.com> Date: Tue, 14 Mar 2023 15:47:12 +1100 Subject: [PATCH] Update NaN block size tests for threshold_local function (#289) * Do not expect ValueError when gaussian block_size is Nan Improvements elsewhere mean the ValueError is no longer raised. * cupy.nan is float type, must explicitly specify like kwarg to match cupy array type --- dask_image/ndfilters/_threshold.py | 2 +- tests/test_dask_image/test_ndfilters/test_cupy_threshold.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dask_image/ndfilters/_threshold.py b/dask_image/ndfilters/_threshold.py index b43fb4af..c9133a80 100644 --- a/dask_image/ndfilters/_threshold.py +++ b/dask_image/ndfilters/_threshold.py @@ -80,7 +80,7 @@ def threshold_local(image, block_size, method='gaussian', offset=0, mode=mode, cval=cval) elif method == 'gaussian': if param is None: - sigma = (da.asarray(block_size) - 1) / 6.0 + sigma = (da.asarray(block_size, like=image._meta) - 1) / 6.0 else: sigma = param thresh_image = _gaussian.gaussian_filter(image, sigma, mode=mode, diff --git a/tests/test_dask_image/test_ndfilters/test_cupy_threshold.py b/tests/test_dask_image/test_ndfilters/test_cupy_threshold.py index 79b67504..4800413a 100644 --- a/tests/test_dask_image/test_ndfilters/test_cupy_threshold.py +++ b/tests/test_dask_image/test_ndfilters/test_cupy_threshold.py @@ -106,7 +106,6 @@ def setup(self): [4, 5, 1, 0, 0]], dtype=int), chunks=(5, 5)) @pytest.mark.parametrize("method, block_size, error_type", [ - ('gaussian', cupy.nan, ValueError), ('median', cupy.nan, TypeError), ]) def test_nan_blocksize(self, method, block_size, error_type):