mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-10 19:45:33 +08:00
removed array cast, added not equals test
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user