Skip to content

Commit

Permalink
Test gaussian alias (#287)
Browse files Browse the repository at this point in the history
* Test `gaussian` alias

Currently the `gaussian` function shows up as not covered by testing.
This provides some test coverage of it.

* Test `gaussian` with CuPy

Include a CuPy test of `gaussian` as well.

* Include `gaussian` in `ndfilters`' `import`s
  • Loading branch information
jakirkham authored Mar 14, 2023
1 parent a4b3652 commit 4871929
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
6 changes: 4 additions & 2 deletions dask_image/ndfilters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"laplace",
"prewitt",
"sobel",
"gaussian",
"gaussian_filter",
"gaussian_gradient_magnitude",
"gaussian_laplace",
Expand All @@ -22,8 +23,8 @@
from ._conv import convolve, correlate
from ._diff import laplace
from ._edge import prewitt, sobel
from ._gaussian import (gaussian_filter, gaussian_gradient_magnitude,
gaussian_laplace)
from ._gaussian import (gaussian, gaussian_filter,
gaussian_gradient_magnitude, gaussian_laplace)
from ._generic import generic_filter
from ._order import (maximum_filter, median_filter, minimum_filter,
percentile_filter, rank_filter)
Expand All @@ -38,6 +39,7 @@
prewitt.__module__ = __name__
sobel.__module__ = __name__

gaussian.__module__ = __name__
gaussian_filter.__module__ = __name__
gaussian_gradient_magnitude.__module__ = __name__
gaussian_laplace.__module__ = __name__
Expand Down
14 changes: 12 additions & 2 deletions tests/test_dask_image/test_ndfilters/test__gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@pytest.mark.parametrize(
"da_func",
[
dask_image.ndfilters.gaussian,
dask_image.ndfilters.gaussian_filter,
dask_image.ndfilters.gaussian_gradient_magnitude,
dask_image.ndfilters.gaussian_laplace,
Expand Down Expand Up @@ -48,7 +49,10 @@ def test_gaussian_filters_params(da_func, err_type, sigma, truncate):
)
@pytest.mark.parametrize(
"sp_func, da_func",
[(scipy.ndimage.gaussian_filter, dask_image.ndfilters.gaussian_filter)]
[
(scipy.ndimage.gaussian_filter, dask_image.ndfilters.gaussian),
(scipy.ndimage.gaussian_filter, dask_image.ndfilters.gaussian_filter),
]
)
def test_gaussian_filters_identity(sp_func, da_func, order, sigma, truncate):
a = np.arange(140.0).reshape(10, 14)
Expand All @@ -74,6 +78,7 @@ def test_gaussian_filters_identity(sp_func, da_func, order, sigma, truncate):
@pytest.mark.parametrize(
"da_func",
[
dask_image.ndfilters.gaussian,
dask_image.ndfilters.gaussian_filter,
dask_image.ndfilters.gaussian_gradient_magnitude,
dask_image.ndfilters.gaussian_laplace,
Expand All @@ -96,6 +101,7 @@ def test_gaussian_filter_shape_type(da_func):
@pytest.mark.parametrize(
"da_func",
[
dask_image.ndfilters.gaussian,
dask_image.ndfilters.gaussian_filter,
dask_image.ndfilters.gaussian_gradient_magnitude,
dask_image.ndfilters.gaussian_laplace,
Expand Down Expand Up @@ -129,6 +135,7 @@ def test_gaussian_filter_comprehensions(da_func):
@pytest.mark.parametrize(
"sp_func, da_func",
[
(scipy.ndimage.gaussian_filter, dask_image.ndfilters.gaussian),
(scipy.ndimage.gaussian_filter, dask_image.ndfilters.gaussian_filter),
(scipy.ndimage.gaussian_gradient_magnitude,
dask_image.ndfilters.gaussian_gradient_magnitude),
Expand Down Expand Up @@ -172,7 +179,10 @@ def test_gaussian_filters_compare(sp_func, da_func, sigma, truncate):
)
@pytest.mark.parametrize(
"sp_func, da_func",
[(scipy.ndimage.gaussian_filter, dask_image.ndfilters.gaussian_filter)]
[
(scipy.ndimage.gaussian_filter, dask_image.ndfilters.gaussian),
(scipy.ndimage.gaussian_filter, dask_image.ndfilters.gaussian_filter),
]
)
def test_gaussian_derivative_filters_compare(sp_func, da_func,
order, sigma, truncate):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_cupy_edge(array, func):

@pytest.mark.cupy
@pytest.mark.parametrize("func", [
dask_image.ndfilters.gaussian,
dask_image.ndfilters.gaussian_filter,
dask_image.ndfilters.gaussian_gradient_magnitude,
dask_image.ndfilters.gaussian_laplace,
Expand Down

0 comments on commit 4871929

Please sign in to comment.