Re: [Numpy-discussion] C-API: PyTypeObject* for NumPy scalar types

2011-07-29 Thread Johan Råde
On 2011-07-28 07:50, Johan Råde wrote: How do I get the PyTypeObject* for a NumPy scalar type such as np.uint8? (The reason I'm asking is the following: I'm writing a C++ extension module. The Python interface to the module has a function f that takes a NumPy scalar type as an argument, for

[Numpy-discussion] c-api return two arrays

2011-07-29 Thread Yoshi Rokuko
hey, i have an algorithm that computes two matrices like that: A(i,k) = (x(i,k) + y(i,k))/norm B(i,k) = (x(i,k) - y(i,k))/norm it would be convenient to have the method like that: A, B = mod.meth(C, prob=.95) is ith possible to return two arrays? best regards

Re: [Numpy-discussion] Rationale for returning type-wrapped min() / max() scalars? (was: Problem with ufunc of a numpy.ndarray derived class)

2011-07-29 Thread Hans Meine
Am Donnerstag, 28. Juli 2011, 17:42:38 schrieb Matthew Brett: If I understand you correctly, the problem is that, for 1.5.1: class Test(np.ndarray): pass type(np.min(Test((1, type 'numpy.float64' and for 1.6.0 (and current trunk): class Test(np.ndarray): pass

Re: [Numpy-discussion] c-api return two arrays

2011-07-29 Thread Peter
On Fri, Jul 29, 2011 at 9:52 AM, Yoshi Rokuko yo...@rokuko.net wrote: hey, i have an algorithm that computes two matrices like that: A(i,k) = (x(i,k) + y(i,k))/norm B(i,k) = (x(i,k) - y(i,k))/norm it would be convenient to have the method like that: A, B = mod.meth(C, prob=.95) is ith

Re: [Numpy-discussion] Rationale for returning type-wrapped min() / max() scalars? (was: Problem with ufunc of a numpy.ndarray derived class)

2011-07-29 Thread Hans Meine
Am Freitag, 29. Juli 2011, 11:31:24 schrieb Hans Meine: Am Donnerstag, 28. Juli 2011, 17:42:38 schrieb Matthew Brett: Was there a particular case you ran into where this was a problem? [...] Basically, the problem arose because our ndarray subclass does not support zero-rank-instances fully.

Re: [Numpy-discussion] c-api return two arrays

2011-07-29 Thread Yoshi Rokuko
+ Peter ---+ On Fri, Jul 29, 2011 at 9:52 AM, Yoshi Rokuko yo...@rokuko.net wrote: hey, i have an algorithm that computes two matrices like that: A(i,k) = (x(i,k) + y(i,k))/norm B(i,k) = (x(i,k) - y(i,k))/norm it would be

Re: [Numpy-discussion] c-api return two arrays

2011-07-29 Thread Pauli Virtanen
Fri, 29 Jul 2011 10:52:12 +0200, Yoshi Rokuko wrote: [clip] A, B = mod.meth(C, prob=.95) is ith possible to return two arrays? The way to do this in Python is to build a tuple with Py_BuildValue(OO, A, B) and return that. ___ NumPy-Discussion

Re: [Numpy-discussion] Rationale for returning type-wrapped min() / max() scalars? (was: Problem with ufunc of a numpy.ndarray derived class)

2011-07-29 Thread Charles R Harris
On Fri, Jul 29, 2011 at 4:12 AM, Hans Meine me...@informatik.uni-hamburg.de wrote: Am Freitag, 29. Juli 2011, 11:31:24 schrieb Hans Meine: Am Donnerstag, 28. Juli 2011, 17:42:38 schrieb Matthew Brett: Was there a particular case you ran into where this was a problem? [...] Basically,

Re: [Numpy-discussion] dtype repr change?

2011-07-29 Thread Mark Wiebe
On Thu, Jul 28, 2011 at 3:09 PM, Nathaniel Smith n...@pobox.com wrote: I have a different question about this than the rest of the thread. I'm confused at why there isn't a programmatic way to create a datetime dtype, other than by going through this special string-based mini-language. I guess

[Numpy-discussion] Numpy Help

2011-07-29 Thread DIPO ELEGBEDE
Hi All, I am fresh on this list and would be looking forward to as much help as I can get. I am hoping to develop ino helping others too after a short while. Kindly help me with this task. I would appreciate if you can point me to an example or brief explanation. I have a 4 by 4 matrix filled

[Numpy-discussion] boolean array indexing and broadcasting rules

2011-07-29 Thread Mark Wiebe
As part of supporting the NA mask, I've rewritten boolean indexing. Here's a timing comparison of my version versus a previous version: In [2]: np.__version__ Out[2]: '1.4.1' In [3]: a = np.zeros((1000,1000)) In [4]: mask = np.random.rand(1000,1000) 0.5 In [5]: timeit a[mask] = 1.5 10 loops,

Re: [Numpy-discussion] dtype repr change?

2011-07-29 Thread Mark Wiebe
I've merged a pull request from Alok Singhal which implements Robert Kern's idea for this. Thanks, Mark On Wed, Jul 27, 2011 at 12:50 PM, Matthew Brett matthew.br...@gmail.comwrote: Hi, I see that (current trunk): In [9]: np.ones((1,), dtype=bool) Out[9]: array([ True], dtype='bool') -

Re: [Numpy-discussion] Numpy Help

2011-07-29 Thread Martin Ling
On Fri, Jul 29, 2011 at 02:55:15PM +0100, DIPO ELEGBEDE wrote: I have a 4 by 4 matrix filled with 0s, 1s and 2s. I want to loop through the whole matrix to get the fields with 1s and 2s only and then count how many ones and how many twos. Try this: m =

Re: [Numpy-discussion] boolean array indexing and broadcasting rules

2011-07-29 Thread Pierre GM
On Jul 29, 2011, at 4:07 PM, Mark Wiebe wrote: As part of supporting the NA mask, I've rewritten boolean indexing. Here's a timing comparison of my version versus a previous version: In [2]: np.__version__ Out[2]: '1.4.1' In [3]: a = np.zeros((1000,1000)) In [4]: mask =

Re: [Numpy-discussion] Numpy Help

2011-07-29 Thread DIPO ELEGBEDE
Thanks Martins, that did the magic. Thanks so much. I'm on the tutorials now. Regards. On 29 Jul 2011 15:24, Martin Ling martin-nu...@earth.li wrote: On Fri, Jul 29, 2011 at 02:55:15PM +0100, DIPO ELEGBEDE wrote: I have a 4 by 4 matrix filled with 0s, 1s and 2s. I want to loop through the

Re: [Numpy-discussion] Quaternion dtype for NumPy - initial implementation available

2011-07-29 Thread Martin Ling
On Thu, Jul 28, 2011 at 09:48:29PM -0500, Robert Love wrote: Quaternions have a handedness or a sign convention. The recently departed Space Shuttle used a Left versor convention while most things, including Space Station, use the right versor convention, in their flight software. Made for

Re: [Numpy-discussion] Rationale for returning type-wrapped min() / max() scalars? (was: Problem with ufunc of a numpy.ndarray derived class)

2011-07-29 Thread Mark Wiebe
On Thu, Jul 28, 2011 at 9:58 AM, Hans Meine me...@informatik.uni-hamburg.de wrote: Hi again! Am Donnerstag, 21. Juli 2011, 16:56:21 schrieb Hans Meine: import numpy class Test(numpy.ndarray): pass a1 = numpy.ndarray((1,)) a2 = Test((1,)) assert type(a1.min()) ==

Re: [Numpy-discussion] Quaternion dtype for NumPy - initial implementation available

2011-07-29 Thread Charles R Harris
On Fri, Jul 29, 2011 at 9:03 AM, Martin Ling martin-nu...@earth.li wrote: On Thu, Jul 28, 2011 at 09:48:29PM -0500, Robert Love wrote: Quaternions have a handedness or a sign convention. The recently departed Space Shuttle used a Left versor convention while most things, including Space

Re: [Numpy-discussion] dtype repr change?

2011-07-29 Thread Jason Grout
On 7/28/11 4:21 PM, Matthew Brett wrote: Hi, Do you know if doctests supports any sort of manual intervention, like a plugin system? Actually, I was going to ask you that question :) But yes, there's the NumpyDoctest nose plugin, for example. Using it does mean you have to customize nose

Re: [Numpy-discussion] Rationale for returning type-wrapped min() / max() scalars? (was: Problem with ufunc of a numpy.ndarray derived class)

2011-07-29 Thread Benjamin Root
On Fri, Jul 29, 2011 at 10:07 AM, Mark Wiebe mwwi...@gmail.com wrote: On Thu, Jul 28, 2011 at 9:58 AM, Hans Meine me...@informatik.uni-hamburg.de wrote: Hi again! Am Donnerstag, 21. Juli 2011, 16:56:21 schrieb Hans Meine: import numpy class Test(numpy.ndarray): pass a1 =

Re: [Numpy-discussion] Quaternion dtype for NumPy - initial implementation available

2011-07-29 Thread Martin Ling
On Fri, Jul 29, 2011 at 09:14:00AM -0600, Charles R Harris wrote: Well, if the shuttle used a different definition then it was out there somewhere. The history of quaternions is rather involved and mixed up with vectors, so it may be the case that there were different conventions.

Re: [Numpy-discussion] Rationale for returning type-wrapped min() / max() scalars? (was: Problem with ufunc of a numpy.ndarray derived class)

2011-07-29 Thread Nathaniel Smith
On Jul 28, 2011 8:43 AM, Matthew Brett matthew.br...@gmail.com wrote: So, 1.6.0 is returning a zero-dimensional scalar of the given type, and 1.5.1 returns a python scalar. Zero dimensional scalars are designed to behave in a similar way to python scalars, so the change should be all but

Re: [Numpy-discussion] c-api return two arrays

2011-07-29 Thread Yoshi Rokuko
+-- Pauli Virtanen ---+ Fri, 29 Jul 2011 10:52:12 +0200, Yoshi Rokuko wrote: [clip] A, B = mod.meth(C, prob=.95) is it possible to return two arrays? The way to do this in Python is to build a tuple with Py_BuildValue(OO, A, B) and return that. that

Re: [Numpy-discussion] Quaternion dtype for NumPy - initial implementation available

2011-07-29 Thread Charles R Harris
On Fri, Jul 29, 2011 at 11:07 AM, Martin Ling martin-nu...@earth.li wrote: On Fri, Jul 29, 2011 at 09:14:00AM -0600, Charles R Harris wrote: Well, if the shuttle used a different definition then it was out there somewhere. The history of quaternions is rather involved and mixed up

Re: [Numpy-discussion] Quaternion dtype for NumPy - initial implementation available

2011-07-29 Thread Benjamin Root
On Fri, Jul 29, 2011 at 2:52 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Fri, Jul 29, 2011 at 11:07 AM, Martin Ling martin-nu...@earth.liwrote: On Fri, Jul 29, 2011 at 09:14:00AM -0600, Charles R Harris wrote: Well, if the shuttle used a different definition then it was

Re: [Numpy-discussion] Quaternion dtype for NumPy - initial implementation available

2011-07-29 Thread Charles R Harris
On Fri, Jul 29, 2011 at 1:57 PM, Benjamin Root ben.r...@ou.edu wrote: On Fri, Jul 29, 2011 at 2:52 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Fri, Jul 29, 2011 at 11:07 AM, Martin Ling martin-nu...@earth.liwrote: On Fri, Jul 29, 2011 at 09:14:00AM -0600, Charles R Harris

Re: [Numpy-discussion] Quaternion dtype for NumPy - initial implementation available

2011-07-29 Thread Mark Wiebe
On Fri, Jul 29, 2011 at 2:57 PM, Benjamin Root ben.r...@ou.edu wrote: On Fri, Jul 29, 2011 at 2:52 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Fri, Jul 29, 2011 at 11:07 AM, Martin Ling martin-nu...@earth.liwrote: On Fri, Jul 29, 2011 at 09:14:00AM -0600, Charles R Harris

[Numpy-discussion] numpy.interp running time

2011-07-29 Thread Timo Kluck
Dear numpy developers, The current implementation of numpy.interp(x,xp,fp) comes down to: first calculating all the slopes of the linear interpolant (these are len(xp)-1), then use a binary search to find where x is in xp (running time log(len(xp)). So we obtain a running time of O( len(xp) +

Re: [Numpy-discussion] Array vectorization in numpy

2011-07-29 Thread Carlos Becker
Hi. That is really amazing. I checked out that numexpr branch and saw some strange results when evaluating expressions on a multi-core i7 processor. Running the numexpr.test() yields a few 'F', which I suppose are failing tests. I tried to let the tests finish but it takes more than 20 min, is