The reasoning behind this is that == returns an array that specifies whether each element of the two arrays is equal. It's only defined if the arrays are the same shape (or maybe if they can be broadcasted to the same shape). The correct way to check if an array is empty is to inspect its .shape field.
On Oct 11, 2010, at 8:03 PM, Vincent Davis wrote: > I assume there is some reasoning behind this >>>> m = np.array([]) >>>> n = np.array([]) >>>> m==n > array([], dtype=bool) > > I was expecting somthing like. >>>> m = [] >>>> n = [] >>>> m==n > True > > What is the right way to test if an array is empty? > > -- > Thanks > Vincent Davis > 720-301-3003 > _______________________________________________ > NumPy-Discussion mailing list > [email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
