[Numpy-discussion] equality of empty arrays
josef.pktd@gmai...
josef.pktd@gmai...
Mon Oct 11 19:07:17 CDT 2010
On Mon, Oct 11, 2010 at 8: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).
> 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?
>>> np.array([]).size
0
Josef
>>
>> --
>> 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
>
More information about the NumPy-Discussion
mailing list