Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread josef . pktd
On Tue, Jan 31, 2012 at 5:35 PM, Travis Oliphant wrote: > Actually i believe the NumPy 'any' and 'all' names pre-date the Python usage > which first appeared in Python 2.5 > > I agree with Chris that namespaces are a great idea.  I don't agree with > deprecating 'any' and 'all' I completely agr

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Travis Oliphant
Actually i believe the NumPy 'any' and 'all' names pre-date the Python usage which first appeared in Python 2.5 I agree with Chris that namespaces are a great idea. I don't agree with deprecating 'any' and 'all' It also seems useful to revisit under what conditions 'array' could correctly int

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Warren Weckesser
On Tue, Jan 31, 2012 at 4:22 PM, Robert Kern wrote: > On Tue, Jan 31, 2012 at 22:17, Travis Oliphant > wrote: > > I also agree that an exception should be raised at the very least. > > > > It might also be possible to make the NumPy any, all, and sum functions > > behave like the builtins when g

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Robert Kern
On Tue, Jan 31, 2012 at 22:17, Travis Oliphant wrote: > I also agree that an exception should be raised at the very least. > > It might also be possible to make the NumPy any, all, and sum functions > behave like the builtins when given a generator.  It seems worth exploring > at least. I would r

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Travis Oliphant
I also agree that an exception should be raised at the very least. It might also be possible to make the NumPy any, all, and sum functions behave like the builtins when given a generator. It seems worth exploring at least. Travis -- Travis Oliphant (on a mobile) 512-826-7480 On Jan 31, 2012

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Chris Barker
On Tue, Jan 31, 2012 at 6:33 AM, Neal Becker wrote: > The reason it surprised me, is that python 'all' doesn't behave as numpy 'all' > in this respect - and using ipython, I didn't even notice that 'all' was > numpy.all rather than standard python all. "namespaces are one honking great idea" --

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Benjamin Root
On Tue, Jan 31, 2012 at 10:05 AM, Olivier Delalleau wrote: > Le 31 janvier 2012 10:50, Robert Kern a écrit : > >> On Tue, Jan 31, 2012 at 15:35, Benjamin Root wrote: >> > >> > >> > On Tue, Jan 31, 2012 at 9:18 AM, Robert Kern >> wrote: >> >> >> >> On Tue, Jan 31, 2012 at 15:13, Benjamin Root

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Robert Kern
On Tue, Jan 31, 2012 at 15:35, Benjamin Root wrote: > Furthermore, from the documentation: > > numpy.asanyarray = asanyarray(a, dtype=None, order=None, maskna=None, > ownmaskna=False) > Convert the input to an ndarray, but pass ndarray subclasses through. > > Parameters > -

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Olivier Delalleau
Le 31 janvier 2012 10:50, Robert Kern a écrit : > On Tue, Jan 31, 2012 at 15:35, Benjamin Root wrote: > > > > > > On Tue, Jan 31, 2012 at 9:18 AM, Robert Kern > wrote: > >> > >> On Tue, Jan 31, 2012 at 15:13, Benjamin Root wrote: > >> > >> > Is np.all() using np.array() or np.asanyarray()? If

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Robert Kern
On Tue, Jan 31, 2012 at 15:35, Benjamin Root wrote: > > > On Tue, Jan 31, 2012 at 9:18 AM, Robert Kern wrote: >> >> On Tue, Jan 31, 2012 at 15:13, Benjamin Root wrote: >> >> > Is np.all() using np.array() or np.asanyarray()?  If the latter, I would >> > expect it to return a numpy array from a g

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Alan G Isaac
On 1/31/2012 10:35 AM, Benjamin Root wrote: > A generator is an input that could be converted into an array. def mygen(): i = 0 while True: yield i i += 1 Alan Isaac ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://m

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Dag Sverre Seljebotn
On 01/31/2012 04:35 PM, Benjamin Root wrote: > > > On Tue, Jan 31, 2012 at 9:18 AM, Robert Kern > wrote: > > On Tue, Jan 31, 2012 at 15:13, Benjamin Root > wrote: > > > Is np.all() using np.array() or np.asanyarray()? If the latt

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Benjamin Root
On Tue, Jan 31, 2012 at 9:18 AM, Robert Kern wrote: > On Tue, Jan 31, 2012 at 15:13, Benjamin Root wrote: > > > Is np.all() using np.array() or np.asanyarray()? If the latter, I would > > expect it to return a numpy array from a generator. > > Why would you expect that? > > [~/scratch] > |37> n

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Dag Sverre Seljebotn
On 01/31/2012 04:13 PM, Benjamin Root wrote: > > > On Tuesday, January 31, 2012, Alan G Isaac > wrote: > > On 1/31/2012 8:26 AM, Neal Becker wrote: > >> I was just bitten by this unexpected behavior: > >> > >> In [24]: all ([i> 0 for i in xrange (10)]) > >> Out[

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Robert Kern
On Tue, Jan 31, 2012 at 15:13, Benjamin Root wrote: > Is np.all() using np.array() or np.asanyarray()?  If the latter, I would > expect it to return a numpy array from a generator. Why would you expect that? [~/scratch] |37> np.asanyarray(i>5 for i in range(10)) array( at 0xdc24a08>, dtype=obje

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Benjamin Root
On Tuesday, January 31, 2012, Alan G Isaac wrote: > On 1/31/2012 8:26 AM, Neal Becker wrote: >> I was just bitten by this unexpected behavior: >> >> In [24]: all ([i> 0 for i in xrange (10)]) >> Out[24]: False >> >> In [25]: all (i> 0 for i in xrange (10)) >> Out[25]: True >> >> Turns out: >>

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Alan G Isaac
On 1/31/2012 8:26 AM, Neal Becker wrote: > I was just bitten by this unexpected behavior: > > In [24]: all ([i> 0 for i in xrange (10)]) > Out[24]: False > > In [25]: all (i> 0 for i in xrange (10)) > Out[25]: True > > Turns out: > In [31]: all is numpy.all > Out[31]: True >>> np.array([i> 0

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Neal Becker
Dag Sverre Seljebotn wrote: > On 01/31/2012 03:07 PM, Robert Kern wrote: >> On Tue, Jan 31, 2012 at 13:26, Neal Becker wrote: >>> I was just bitten by this unexpected behavior: >>> >>> In [24]: all ([i>0 for i in xrange (10)]) >>> Out[24]: False >>> >>> In [25]: all (i>0 for i in xrange (

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Dag Sverre Seljebotn
On 01/31/2012 03:07 PM, Robert Kern wrote: > On Tue, Jan 31, 2012 at 13:26, Neal Becker wrote: >> I was just bitten by this unexpected behavior: >> >> In [24]: all ([i>0 for i in xrange (10)]) >> Out[24]: False >> >> In [25]: all (i>0 for i in xrange (10)) >> Out[25]: True >> >> Turns out:

Re: [Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Robert Kern
On Tue, Jan 31, 2012 at 13:26, Neal Becker wrote: > I was just bitten by this unexpected behavior: > > In [24]: all ([i>  0 for i in xrange (10)]) > Out[24]: False > > In [25]: all (i>  0 for i in xrange (10)) > Out[25]: True > > Turns out: > In [31]: all is numpy.all > Out[31]: True > > So numpy.

[Numpy-discussion] numpy all unexpected result (generator)

2012-01-31 Thread Neal Becker
I was just bitten by this unexpected behavior: In [24]: all ([i> 0 for i in xrange (10)]) Out[24]: False In [25]: all (i> 0 for i in xrange (10)) Out[25]: True Turns out: In [31]: all is numpy.all Out[31]: True So numpy.all doesn't seem to do what I would expect when given a generator. Bug?