[SciPy-user] numarray equality testing

Tim Hochberg tim.hochberg at ieee.org
Mon Dec 9 11:06:43 EST 2002


> This is a Numeric/numarray compatibility question.
>
> Numeric currently allows the equals ufunc to compare
> arrays of unequal sizes and returns a scalar 0 in such
> cases. When arrays have consistent shapes, an array of
> ints is returned. We argue that this is inconsistent with
> normal ufunc behavior and that it should generate an
> exception as do all non-equality ufuncs. (numarray currently
> does not allow comparison of shape-inconsistent arrays
> including for equality).
>
> Instead we propose a function whose purpose is to determine
> if two arrays are shape consistent (i.e., can be broadcast
> against each other) and have all values equal to each other.
>
> >>> array_equal(arange(2), arange(4))
> 0
> >>> array_equal(array([1,2,3]), array([1,2,0]))
> 0
> >>> array_equal( arange(2), None )
> 0
> >>> array_equal( arange(2), not_an_ndarray_instance)
> 0
> >>> array_equal(array([[1,2,3],[1,2,3]]), array([1,2,3]))
> 1
>
> Comments?

This seems like a good plan. I'm not enthralled by the name though:
array_equal seems equally likely to describethe  behaviour of the unfunc
equal as it does the behaviour above. Maybe array_identical or array_same or
equal_arrays or some such (although none of those are great).

-tim



> Perry Greenfield
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
>





More information about the SciPy-User mailing list