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 ther

[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) + len

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 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 wrote: >> >>> On Fri, Jul 29, 2011 at 09:14:00AM -0600, Charles R Harris wrote: >>> > >>> >

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 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 wrote: >> >>> On Fri, Jul 29, 2011 at 09:14:00AM -0600, Charles R Harris wrote: >>> > >>> >

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 wrote: > > > On Fri, Jul 29, 2011 at 11:07 AM, Martin Ling 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

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 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 > with > >vec

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 retur

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" 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 invisible in practice

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 Benjamin Root
On Fri, Jul 29, 2011 at 10:07 AM, Mark Wiebe 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 >> > >

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 custo

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 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 Station, u

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 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()) == type(a2.min()), \ >

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. Ma

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" 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 whole matrix to

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 = np.random.

Re: [Numpy-discussion] Issues with adding new dtypes - customizing ndarray attributes

2011-07-29 Thread Mark Wiebe
On Thu, Jul 28, 2011 at 8:54 AM, Martin Ling wrote: > Hi, > > I'd like to kick off some discussion on general issues I've encountered > while developing the quaternion dtype (see other thread, and the code > at: https://github.com/martinling/numpy_quaternion) > > The basic issue is that the attri

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 = matrix('1,2,0,2;2,2,1,

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 wrote: > Hi, > > I see that (current trunk): > > In [9]: np.ones((1,), dtype=bool) > Out[9]: array([ True], dtype='bool') > > - whereas (1.5.1):

[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, bes

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

Re: [Numpy-discussion] dtype repr change?

2011-07-29 Thread Mark Wiebe
On Thu, Jul 28, 2011 at 3:09 PM, Nathaniel Smith 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 > I general

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 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, the problem arose becaus

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-Discussi

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

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 f

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

2011-07-29 Thread Peter
On Fri, Jul 29, 2011 at 9:52 AM, Yoshi Rokuko 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 poss

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, > > > > and for 1.6.0 (and current trunk): > >>> class Test(np.ndarray): pass > >>> type(np.min(Test((1

[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] 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, f