[Numpy-discussion] [ANN] Summer School Advanced Scientific Programming in Python in Kiel, Germany

2012-01-31 Thread Tiziano Zito
Advanced Scientific Programming in Python = a Summer School by the G-Node and the Institute of Experimental and Applied Physics, Christian-Albrechts-Universität zu Kiel Scientists spend more and more time writing, maintaining, and debugging software. While

[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?

Re: [Numpy-discussion] histogram help

2012-01-31 Thread Nadav Horesh
Do you want a histogramm of z for each (x,y) ? Nadav From: numpy-discussion-boun...@scipy.org [numpy-discussion-boun...@scipy.org] On Behalf Of Ruby Stevenson [ruby...@gmail.com] Sent: 30 January 2012 21:27 To: Discussion of Numerical Python Subject:

[Numpy-discussion] Unexpected reorganization of internal data

2012-01-31 Thread Mads Ipsen
Hi, I am confused. Here's the reason: The following structure is a representation of N points in 3D space: U = numpy.array([[x1,y1,z1], [x1,y1,z1],...,[xn,yn,zn]]) So the array U has shape (N,3). This order makes sense to me since U[i] will give you the i'th point in the set. Now, I want to

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

2012-01-31 Thread Robert Kern
On Tue, Jan 31, 2012 at 13:26, Neal Becker ndbeck...@gmail.com 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

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 Beckerndbeck...@gmail.com wrote: I was just bitten by this unexpected behavior: In [24]: all ([i0 for i in xrange (10)]) Out[24]: False In [25]: all (i0 for i in xrange (10)) Out[25]: True Turns out:

Re: [Numpy-discussion] Unexpected reorganization of internal data

2012-01-31 Thread Malcolm Reynolds
Not exactly an answer to your question, but I can highly recommend using Boost.python, PyUblas and Ublas for your C++ vectors and matrices. It gives you a really good interface on the C++ side to numpy arrays and matrices, which can be passed in both directions over the language threshold with no

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 Beckerndbeck...@gmail.com wrote: I was just bitten by this unexpected behavior: In [24]: all ([i0 for i in xrange (10)]) Out[24]: False In [25]: all (i0 for i in xrange

Re: [Numpy-discussion] Unexpected reorganization of internal data

2012-01-31 Thread Matthew Brett
Hi, On Tue, Jan 31, 2012 at 8:29 AM, Mads Ipsen madsip...@gmail.com wrote: Hi, I am confused. Here's the reason: The following structure is a representation of N points in 3D space: U = numpy.array([[x1,y1,z1], [x1,y1,z1],...,[xn,yn,zn]]) So the array U has shape (N,3). This order makes

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 for i in xrange

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

2012-01-31 Thread Benjamin Root
On Tuesday, January 31, 2012, Alan G Isaac alan.is...@gmail.com 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: In

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

2012-01-31 Thread Robert Kern
On Tue, Jan 31, 2012 at 15:13, Benjamin Root ben.r...@ou.edu 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(i5 for i in range(10)) array(generator

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 alan.is...@gmail.com mailto:alan.is...@gmail.com 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)])

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 robert.k...@gmail.com wrote: On Tue, Jan 31, 2012 at 15:13, Benjamin Root ben.r...@ou.edu 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

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 robert.k...@gmail.com mailto:robert.k...@gmail.com wrote: On Tue, Jan 31, 2012 at 15:13, Benjamin Root ben.r...@ou.edu mailto:ben.r...@ou.edu wrote: Is np.all() using np.array() or

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

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

2012-01-31 Thread Robert Kern
On Tue, Jan 31, 2012 at 15:35, Benjamin Root ben.r...@ou.edu wrote: On Tue, Jan 31, 2012 at 9:18 AM, Robert Kern robert.k...@gmail.com wrote: On Tue, Jan 31, 2012 at 15:13, Benjamin Root ben.r...@ou.edu wrote: Is np.all() using np.array() or np.asanyarray()?  If the latter, I would

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

2012-01-31 Thread Olivier Delalleau
Le 31 janvier 2012 10:50, Robert Kern robert.k...@gmail.com a écrit : On Tue, Jan 31, 2012 at 15:35, Benjamin Root ben.r...@ou.edu wrote: On Tue, Jan 31, 2012 at 9:18 AM, Robert Kern robert.k...@gmail.com wrote: On Tue, Jan 31, 2012 at 15:13, Benjamin Root ben.r...@ou.edu wrote:

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

2012-01-31 Thread Robert Kern
On Tue, Jan 31, 2012 at 15:35, Benjamin Root ben.r...@ou.edu 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 Benjamin Root
On Tue, Jan 31, 2012 at 10:05 AM, Olivier Delalleau sh...@keba.be wrote: Le 31 janvier 2012 10:50, Robert Kern robert.k...@gmail.com a écrit : On Tue, Jan 31, 2012 at 15:35, Benjamin Root ben.r...@ou.edu wrote: On Tue, Jan 31, 2012 at 9:18 AM, Robert Kern robert.k...@gmail.com wrote:

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 ndbeck...@gmail.com 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

Re: [Numpy-discussion] Unexpected reorganization of internal data

2012-01-31 Thread Chris Barker
On Tue, Jan 31, 2012 at 6:14 AM, Malcolm Reynolds malcolm.reyno...@gmail.com wrote: Not exactly an answer to your question, but I can highly recommend using Boost.python, PyUblas and Ublas for your C++ vectors and matrices. It gives you a really good interface on the C++ side to numpy arrays

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,

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

2012-01-31 Thread Robert Kern
On Tue, Jan 31, 2012 at 22:17, Travis Oliphant tra...@continuum.io 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

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 robert.k...@gmail.com wrote: On Tue, Jan 31, 2012 at 22:17, Travis Oliphant tra...@continuum.io 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

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

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 tra...@continuum.io 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