removed array cast, added not equals test

This commit is contained in:
Vighnesh Birodkar
2014-03-28 00:12:18 +05:30
parent 3f5b3892ed
commit 764c59693c
2 changed files with 16 additions and 7 deletions
+3 -5
View File
@@ -333,13 +333,11 @@ class _RegionProperties(MutableMapping):
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])
for x, y in zip(attr1, attr2):
for key in PROP_VALS:
try:
#so that NaNs are equal
np.testing.assert_equal(x, y)
np.testing.assert_equal(
getattr(self, key, None), getattr(other, key, None))
except AssertionError:
return False
+13 -2
View File
@@ -372,9 +372,20 @@ def test_invalid():
def test_equals():
r1 = regionprops(SAMPLE)[0]
r2 = regionprops(SAMPLE)[0]
arr = np.zeros((100, 100), dtype=np.int)
arr[0:25, 0:25] = 1
arr[50:99, 50:99] = 2
regions = regionprops(arr)
r1 = regions[0]
regions = regionprops(arr)
r2 = regions[0]
r3 = regions[1]
assert r1 == r2
assert r1 != r3
if __name__ == "__main__":
from numpy.testing import run_module_suite