[Numpy-discussion] equality of empty arrays
Vincent Davis
vincent@vincentdavis....
Mon Oct 11 19:58:56 CDT 2010
On Mon, Oct 11, 2010 at 6:06 PM, Ian Goodfellow
<goodfellow.ian@gmail.com> wrote:
> 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).
>>> m.size==n.size
True
>>> m.shape==n.shape
True
Not sure about "be broadcasted to the same shape"
I would kind of expect == to return true, false or some error.
Thanks
Vincent
> 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
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
--
Thanks
Vincent Davis
720-301-3003
More information about the NumPy-Discussion
mailing list