added nan case

This commit is contained in:
Vighnesh Birodkar
2014-03-26 03:50:24 +05:30
parent 77b91e633b
commit ace11b852e
+12 -1
View File
@@ -329,9 +329,20 @@ class _RegionProperties(MutableMapping):
return getattr(self, PROPS[key])
def __eq__(self, other):
if not isinstance(other,_RegionProperties):
return False
attr1 = np.array([getattr(self, k, None)for k in PROP_VALS])
attr2 = np.array([getattr(other, k, None)for k in PROP_VALS])
return np.all(attr1 == attr2)
for x,y in zip(attr1, attr2):
try:
#so that NaNs are equal
np.testing.assert_equal(x,y)
except AssertionError :
return False
return True
def regionprops(label_image, properties=None,