[Numpy-discussion] equality of empty arrays

Benjamin Root ben.root@ou....
Mon Oct 11 20:06:18 CDT 2010


On Mon, Oct 11, 2010 at 7:58 PM, Vincent Davis <vincent@vincentdavis.net>wrote:

> 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
>
>
Maybe you are looking for numpy.allclose()?

>>> n = np.array([])
>>> m = np.array([])
>>> np.allclose(n, m)
True


Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20101011/21e7791f/attachment.html 


More information about the NumPy-Discussion mailing list