Added label vs. intensity shape checking to regionprops

This commit is contained in:
stevendbrown
2015-11-09 10:50:20 -08:00
parent d187840f19
commit 157fef3963
2 changed files with 10 additions and 0 deletions
+5
View File
@@ -108,6 +108,11 @@ class _RegionProperties(object):
def __init__(self, slice, label, label_image, intensity_image,
cache_active):
if not intensity_image is None:
if not intensity_image.shape == label_image.shape:
raise ValueError('Label and intensity image must be the same shape.')
self.label = label
self._slice = slice
self._label_image = label_image
@@ -362,6 +362,11 @@ def test_invalid():
assert_raises(AttributeError, get_intensity_image)
def test_invalid_size():
wrong_intensity_sample = np.array([[1], [1]])
assert_raises(ValueError, regionprops, SAMPLE, wrong_intensity_sample)
def test_equals():
arr = np.zeros((100, 100), dtype=np.int)
arr[0:25, 0:25] = 1