Should array_equal work with non-numeric types?
a array(['a', 'b', 'c', 'd', 'e', 'f', 'g'], dtype='|S1') b = a.copy() a == b array([True, True, True, True, True, True, True], dtype=bool) numpy.array_equal(a,b) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/numpy/core/numeric.py",
Hi all, Should array_equal work with non-numeric types? line 652, in array_equal return logical_and.reduce(equal(a1,a2).ravel()) AttributeError: 'NotImplementedType' object has no attribute 'ravel' I can use:
numpy.all(a==b) True
But I was wondering if array_equal should work. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov
On Friday 02 March 2007 16:10:53 Christopher Barker wrote:
Hi all,
Should array_equal work with non-numeric types?
I'm all for that. I was regularly running into that problem when comparing object arrays or chararrays, that's why I modified assert_equal in the "maskedarray" version of testutils (scipy SVN).
from maskedarray.testutils import assert_equal a = N.array(['a','b','c']) assert_equal(a,a.copy()) assert_equal(a,a[::-1]) AssertionError: Items are not equal: item=0
ACTUAL: 'a' DESIRED: 'c'
participants (2)
-
Christopher Barker -
Pierre GM