Skip to content
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.

Commit

Permalink
Merge d15932f into 16c5b75
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham committed May 5, 2017
2 parents 16c5b75 + d15932f commit 2af14e0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
28 changes: 28 additions & 0 deletions dask_ndfilters/_conv.py
Expand Up @@ -6,6 +6,34 @@
import dask_ndfilters._utils as _utils


@_utils._update_wrapper(scipy.ndimage.filters.convolve1d)
def convolve1d(input,
weights,
axis=-1,
mode='reflect',
cval=0.0,
origin=0):
_utils._validate_axis(input.ndim, axis)
origin = _utils._get_origin(weights.shape, origin)
depth = _utils._get_depth(weights.shape, origin)
print(depth)
depth, boundary = _utils._get_depth_boundary(input.ndim, depth, "none")

result = input.map_overlap(
scipy.ndimage.filters.convolve1d,
depth=depth[0],
boundary=boundary[0],
dtype=input.dtype,
name=scipy.ndimage.filters.convolve1d.__name__,
weights=weights,
mode=mode,
cval=cval,
origin=origin[0]
)

return result


@_utils._update_wrapper(scipy.ndimage.filters.convolve)
def convolve(input,
weights,
Expand Down
12 changes: 12 additions & 0 deletions dask_ndfilters/_utils.py
Expand Up @@ -65,6 +65,18 @@ def _updater(wrapper):
return _updater


def _validate_axis(ndim, axis):
if not isinstance(ndim, numbers.Integral):
raise TypeError("Expected integer value for `ndim`.")
if ndim <= 0:
raise ValueError("Expected positive value for `ndim`.")

if not isinstance(axis, numbers.Integral):
raise TypeError("Expected integer value for `axis`.")
if -ndim > axis or axis >= ndim:
raise ValueError("Need `axis` to be in range of `ndim`.")


def _get_depth_boundary(ndim, depth, boundary=None):
if not isinstance(ndim, numbers.Integral):
raise TypeError("Expected integer value for `ndim`.")
Expand Down

0 comments on commit 2af14e0

Please sign in to comment.