Skip to content

Commit

Permalink
Fix meta type and dtype for ndmorph functions (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
GenevieveBuckley authored Apr 21, 2021
1 parent 6d58cb7 commit adcb217
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions dask_image/ndmorph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def binary_closing(image,
result = binary_erosion(
result, structure=structure, iterations=iterations, origin=origin
)
result._meta = image._meta.astype(bool)

return result

Expand All @@ -62,6 +63,7 @@ def binary_dilation(image,
brute_force=brute_force,
border_value=border_value
)
result._meta = image._meta.astype(bool)

return result

Expand All @@ -86,6 +88,7 @@ def binary_erosion(image,
brute_force=brute_force,
border_value=border_value
)
result._meta = image._meta.astype(bool)

return result

Expand All @@ -108,5 +111,6 @@ def binary_opening(image,
result = binary_dilation(
result, structure=structure, iterations=iterations, origin=origin
)
result._meta = image._meta.astype(bool)

return result
7 changes: 6 additions & 1 deletion tests/test_dask_image/test_ndmorph/test_cupy_ndmorph.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ def array():
def test_cupy_ndmorph(array, func):
"""Test convolve & correlate filters with cupy input arrays."""
result = func(array)
result.compute()
assert result.dtype == bool
assert result._meta.dtype == bool
assert isinstance(result._meta, cupy.ndarray)
computed = result.compute()
assert computed.dtype == bool
assert isinstance(computed, cupy.ndarray)

0 comments on commit adcb217

Please sign in to comment.