[Numpy-discussion] unexpected behavior with allclose( scalar, empty array)
Fri Jan 4 13:27:34 CST 2008
I have added a page to the wiki describing this issue:
I'll link it into the main documentation pages over the next few days,
but I ask for a review the following text for correctness and clarity:
(You can simply edit the wiki page or post your reply here and I'll do it.)
Like most of numpy, allclose() uses the broadcasting rules when
performing its operation. This leads to the following behavior:
Upon closer inspection, we can see that the broadcasting rules cause a
to become a zero-dimensional array like b. The default truth value of a
zero-dimensional array is True, so the following holds and illustrates
how the above result is consistent with numpy's rules.
Andrew Straw wrote:
> Apologies if I've missed the discussion of this, but I was recently
> surprised by the following behavior (in svn trunk 4673). The following
> code runs without triggering the assertion.
> import numpy as np
> print np.__version__
> assert np.allclose(a,b)
> Is this expected behavior of numpy or is this a bug I should report?
> Numpy-discussion mailing list
More information about the Numpy-discussion