mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-16 11:21:25 +08:00
Raise meaningful error in reconstruct w bad method
If a method other than 'erosion' or 'dilation' was passed, an `UnboundLocalVariable` error for `pad_value` was raised, which made it difficult to determine the source of the error. Now, an eloquent `ValueError` is raised instead. See #1218.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user