Skip to content

Commit

Permalink
Update NaN block size tests for threshold_local function (#289)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
GenevieveBuckley committed Mar 14, 2023
1 parent 39e13fe commit 69989c7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion dask_image/ndfilters/_threshold.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 69989c7

Please sign in to comment.