mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-28 14:49:08 +08:00
Merge pull request #1660 from jwiggins/issue-1586
Raise an error for negative sigma values in guassian_filter.
This commit is contained in:
@@ -93,6 +93,8 @@ def gaussian_filter(image, sigma, output=None, mode='nearest', cval=0,
|
||||
"3D image with last dimension of length 3.")
|
||||
warnings.warn(RuntimeWarning(msg))
|
||||
multichannel = True
|
||||
if np.any(np.asarray(sigma) < 0.0):
|
||||
raise ValueError("Sigma values less than zero are not valid")
|
||||
if multichannel:
|
||||
# do not filter across channels
|
||||
if not isinstance(sigma, coll.Iterable):
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
import numpy as np
|
||||
from numpy.testing import assert_raises
|
||||
from skimage.filters._gaussian import gaussian_filter
|
||||
from skimage._shared._warnings import expected_warnings
|
||||
|
||||
|
||||
def test_negative_sigma():
|
||||
a = np.zeros((3, 3))
|
||||
a[1, 1] = 1.
|
||||
assert_raises(ValueError, gaussian_filter, a, sigma=-1.0)
|
||||
assert_raises(ValueError, gaussian_filter, a, sigma=[-1.0, 1.0])
|
||||
assert_raises(ValueError, gaussian_filter, a,
|
||||
sigma=np.asarray([-1.0, 1.0]))
|
||||
|
||||
|
||||
def test_null_sigma():
|
||||
a = np.zeros((3, 3))
|
||||
a[1, 1] = 1.
|
||||
|
||||
Reference in New Issue
Block a user