From: Perry G. <pe...@st...> - 2002-12-09 15:39:52
|
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? Perry Greenfield |