[Numpy-discussion] equality of empty arrays

Ian Goodfellow goodfellow.ian@gmail....
Mon Oct 11 19:06:08 CDT 2010


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
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion



More information about the NumPy-Discussion mailing list