Merge pull request #1219 from jni/reconstruct-error

Raise meaningful error when wrong "method" passed to `reconstruct`
This commit is contained in:
Steven Silvester
2014-11-05 20:42:35 -06:00
2 changed files with 9 additions and 0 deletions
+3
View File
@@ -152,6 +152,9 @@ def reconstruction(seed, mask, method='dilation', selem=None, offset=None):
pad_value = np.min(seed)
elif method == 'erosion':
pad_value = np.max(seed)
else:
raise ValueError("Reconstruction method can be one of 'erosion' "
"or 'dilation'. Got '%s'." % method)
images = np.ones(dims) * pad_value
images[[0] + inside_slices] = seed
images[[1] + inside_slices] = mask
@@ -97,6 +97,12 @@ def test_invalid_selem():
reconstruction(seed, mask, selem=np.ones((3, 3)))
def test_invalid_method():
seed = np.array([0, 8, 8, 8, 8, 8, 8, 8, 8, 0])
mask = np.array([0, 3, 6, 2, 1, 1, 1, 4, 2, 0])
assert_raises(ValueError, reconstruction, seed, mask, method='foo')
if __name__ == '__main__':
from numpy import testing
testing.run_module_suite()