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:
Juan Nunez-Iglesias
2014-11-06 10:27:43 +11:00
parent 18cb5cd699
commit f52f2c1779
+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