Re: [Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-04 Thread Andrew Straw
Thanks, I updated the page. Charles R Harris wrote: > > > On Jan 4, 2008 12:27 PM, Andrew Straw <[EMAIL PROTECTED] > > wrote: > > I have added a page to the wiki describing this issue: > > http://scipy.org/numpy_warts_and_gotchas > > I'll link it into the main

Re: [Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-04 Thread Charles R Harris
On Jan 4, 2008 12:27 PM, Andrew Straw <[EMAIL PROTECTED]> wrote: > I have added a page to the wiki describing this issue: > > http://scipy.org/numpy_warts_and_gotchas > > I'll link it into the main documentation pages over the next few days, > but I ask for a review the following text for correctn

Re: [Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-04 Thread Andrew Straw
I have added a page to the wiki describing this issue: http://scipy.org/numpy_warts_and_gotchas 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

Re: [Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-03 Thread Andrew Straw
Matthew Brett wrote: >>> So, currently we have all and allclose giving the same answer: >>> >>> In [19]: a = array([]) >>> >>> In [20]: b = array([1]) >>> >>> In [21]: all(a == b) >>> Out[21]: True >>> >>> In [22]: allclose(a, b) >>> Out[22]: True >>> >>> Would we want the answers to be different?

Re: [Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-03 Thread Matthew Brett
> > So, currently we have all and allclose giving the same answer: > > > > In [19]: a = array([]) > > > > In [20]: b = array([1]) > > > > In [21]: all(a == b) > > Out[21]: True > > > > In [22]: allclose(a, b) > > Out[22]: True > > > > Would we want the answers to be different? > > No. I wasn't thin

Re: [Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-03 Thread Robert Kern
Matthew Brett wrote: > So, currently we have all and allclose giving the same answer: > > In [19]: a = array([]) > > In [20]: b = array([1]) > > In [21]: all(a == b) > Out[21]: True > > In [22]: allclose(a, b) > Out[22]: True > > Would we want the answers to be different? No. I wasn't thinkin

Re: [Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-03 Thread Matthew Brett
So, currently we have all and allclose giving the same answer: In [19]: a = array([]) In [20]: b = array([1]) In [21]: all(a == b) Out[21]: True In [22]: allclose(a, b) Out[22]: True Would we want the answers to be different? ___ Numpy-discussion mai

Re: [Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-03 Thread Charles R Harris
On Jan 3, 2008 2:37 PM, Matthew Brett <[EMAIL PROTECTED]> wrote: > Just to ask - is there a reason why this: > > > In [39]: all([]) > > Out[39]: True > > is the case? Because it's True. Anything is true about the elements of an empty set, because there aren't any. In this case, all asks if all e

Re: [Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-03 Thread Matthew Brett
Just to ask - is there a reason why this: > In [39]: all([]) > Out[39]: True is the case? ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-03 Thread Alan G Isaac
> On Thu, 3 Jan 2008, Charles R Harris apparently wrote: >> Isn't it trivially true that all elements of an empty >> array are close to any number? On Thu, 3 Jan 2008, Alan G Isaac apparently wrote: > Sure, but might not one expect a ValueError due to > shape mismatch? (Doesn't allclose usuall

Re: [Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-03 Thread Matthew Brett
Hi, > > > import numpy as np > > > print np.__version__ > > > a=np.int32(42) > > > b=np.array([],dtype=np.int32) > > > assert np.allclose(a,b) > > > > > > Is this expected behavior of numpy or is this a bug I should report? > > > > Bug, I think. I think this bug - which may be mine - follows from

Re: [Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-03 Thread Alan G Isaac
On Thu, 3 Jan 2008, Charles R Harris apparently wrote: > Isn't it trivially true that all elements of an empty > array are close to any number? Sure, but might not one expect a ValueError due to shape mismatch? (Doesn't allclose usually use normal broadcasting rules?) Cheers, Alan Isaac ___

Re: [Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-03 Thread Charles R Harris
On Jan 3, 2008 1:06 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > 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 num

Re: [Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-03 Thread Robert Kern
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__ > a=np.int32(42) > b=np.array([],dtype=np.i

[Numpy-discussion] unexpected behavior with allclose( scalar, empty array)

2008-01-03 Thread Andrew Straw
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__ a=np.int32(42) b=np.array([],dtype=np.int32) assert np.allclose(a,b) Is th