Re: [Numpy-discussion] FYI: experimental waf support for numpy

2011-02-09 Thread Sebastien Binet
David, On Thu, 10 Feb 2011 14:30:37 +0900, David wrote: > Hi there, > > Following recent release of waf 1.6 and its adoption by the samba > project, as well as my own work on integrating waf and bento, I have > spent some time to build numpy with it. Although this is experimental, > it should

Re: [Numpy-discussion] 2d*3d matrix dot product

2011-02-09 Thread Davide Lasagna
> Ben's suggestion is identical to: > > A = numpy.tensordot(P, C, axes=(1, 0)) Yes, that does the trick! Thank, very good idea. Since i've build atlas with threading support, in the computation of the dot product all four cpus go to 100%, which makes it quite fast. I'm starting to love numpy ar

[Numpy-discussion] Rationale for simple_capsule_dtor to be static but non-inline ?

2011-02-09 Thread David
Hi, in npy3_compat.h, one function simple_capsule_dtor is defined as static but non-inline. AFAIK, there is no reason not to put inline (if supported by the compiler of course) for a static function defined in a header. Unless I hear someone justify it, I will change it, cheers, David ___

[Numpy-discussion] FYI: experimental waf support for numpy

2011-02-09 Thread David
Hi there, Following recent release of waf 1.6 and its adoption by the samba project, as well as my own work on integrating waf and bento, I have spent some time to build numpy with it. Although this is experimental, it should be possible for people to play with it: https://github.com/cournape/

Re: [Numpy-discussion] int is a subtype of bool?

2011-02-09 Thread Pauli Virtanen
On Wed, 09 Feb 2011 15:07:01 -0800, Nathaniel Smith wrote: > This can't possibly be right, can it? Or am I missing something? (It > certainly doesn't seem to match any documentation that I can find) > np.issubdtype(int, bool) > True np.__version__ > '1.5.1' Thanks. It's a bug in issubdt

Re: [Numpy-discussion] Indexing a 2-d array with a 1-d mask

2011-02-09 Thread Alok Singhal
On Wed, Feb 9, 2011 at 1:24 AM, Friedrich Romstedt wrote: > 2011/2/8 Alok Singhal : >> In [6]: data2 = numpy.zeros((0, 5), 'd') >> In [7]: mask2 = numpy.zeros(0, 'bool') >> In [8]: data2[mask2] >> >> Traceback (most recent call last): >>

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Neal Becker
Mark Bakker wrote: > I recently needed a find_first function and searched the list. > It has been discussed a few times before. > And I haven't seen an elegant solution yet. > Maybe we should file a feature request, as it would be awfully nice to have? > Mark > >> >> > Still, I wonder if numpy wo

[Numpy-discussion] int is a subtype of bool?

2011-02-09 Thread Nathaniel Smith
This can't possibly be right, can it? Or am I missing something? (It certainly doesn't seem to match any documentation that I can find) >>> np.issubdtype(int, bool) True >>> np.__version__ '1.5.1' -- Nathaniel ___ NumPy-Discussion mailing list NumPy-Dis

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Mark Bakker
I recently needed a find_first function and searched the list. It has been discussed a few times before. And I haven't seen an elegant solution yet. Maybe we should file a feature request, as it would be awfully nice to have? Mark > > > Still, I wonder if numpy would benefit from a 'find_first' fu

Re: [Numpy-discussion] 2d*3d matrix dot product

2011-02-09 Thread Friedrich Romstedt
2011/2/9 Davide Lasagna : > Hi, > > I want to compute the following dot product: > > P = np.array( [[ p11, p12 ], [p21, p22]] ) > C = np.array( [c1, c2] ) > > a1 = p11*c1 + p12*c2 > a2 = p21*c1 + p22*c2 > > P.shape = (n, n) > C.shape = (n, m, l) > > and with a result as: > > A.shape = (n, m, l) In

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread josef . pktd
On Wed, Feb 9, 2011 at 1:18 PM, Zachary Pincus wrote: >> In a 1-d array, find the first point where all subsequent points have values less than a threshold. >> >> This doesn't imply monotonicity. >> Suppose with have a sin curve, and I want to find the last trough. Or >> a business

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Zachary Pincus
> >>> In a 1-d array, find the first point where all subsequent points >>> have values >>> less than a threshold. > > This doesn't imply monotonicity. > Suppose with have a sin curve, and I want to find the last trough. Or > a business cycle and I want to find the last recession. > > Unless my en

Re: [Numpy-discussion] Permission to close ticket for Mark Wiebe

2011-02-09 Thread Mark Wiebe
On Tue, Feb 8, 2011 at 10:49 AM, Pauli Virtanen wrote: > Tue, 08 Feb 2011 11:35:12 -0700, Charles R Harris wrote: > > Permission to close ticket for Mark Wiebe > > > > I don't know who handles these permissions, I didn't see a way to do it > > myself. > > Granted. (You'd need a shell account to d

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread josef . pktd
On Wed, Feb 9, 2011 at 11:25 AM, Zachary Pincus wrote: >>> This assumes monotonicity. Is that allowed? >> >> The twice-stated problem was: > > [Note to avert email-miscommunications] BTW, I wasn't trying to snipe > at you with that comment, Josef... > > I just meant to say that this solution solve

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Robert Kern
On Wed, Feb 9, 2011 at 10:48, Neal Becker wrote: > Still, I wonder if numpy would benefit from a 'find_first' function. I certainly could have used one many times. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad

Re: [Numpy-discussion] 2d*3d matrix dot product

2011-02-09 Thread Benjamin Root
On Wed, Feb 9, 2011 at 9:53 AM, Davide Lasagna wrote: > Hi, > > I want to compute the following dot product: > > P = np.array( [[ p11, p12 ], [p21, p22]] ) > C = np.array( [c1, c2] ) > > where c1 and c2 are m*m matrices, so that > > C.shape = (2,m,m) > > I want to compute: > > A = np.array([a1, a2

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Alan G Isaac
On 2/9/2011 11:39 AM, Bruce Southey wrote: > np.argmax(x>5) # doesn't appear to be correct It was an answer to the particular question of how to do find_first, which it does (at the cost of a boolean array): it finds the first element greater than 5. >>> x array([5, 4, 3, 6, 7, 3, 2, 1

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Neal Becker
Zachary Pincus wrote: > > On Feb 9, 2011, at 10:58 AM, Neal Becker wrote: > >> Zachary Pincus wrote: >> >> In a 1-d array, find the first point where all subsequent points >> have values >> less than a threshold, T. > > Maybe something like: > > last_greater = numpy.a

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Bruce Southey
On 02/09/2011 10:17 AM, Zachary Pincus wrote: >>> As before, the line below does what you said you need, though not >>> maximally efficiently. (Try it in an interpreter...) There may be >>> another way in numpy that doesn't rely on constructing the index >>> array, but this is the first thing that

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Zachary Pincus
>> This assumes monotonicity. Is that allowed? > > The twice-stated problem was: [Note to avert email-miscommunications] BTW, I wasn't trying to snipe at you with that comment, Josef... I just meant to say that this solution solves the problem as Neal posed it, though that might not be the ex

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Zachary Pincus
>> As before, the line below does what you said you need, though not >> maximally efficiently. (Try it in an interpreter...) There may be >> another way in numpy that doesn't rely on constructing the index >> array, but this is the first thing that came to mind. >> >> last_greater = numpy.arange(ar

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread josef . pktd
On Wed, Feb 9, 2011 at 11:04 AM, Zachary Pincus wrote: > > On Feb 9, 2011, at 10:58 AM, Neal Becker wrote: > >> Zachary Pincus wrote: >> >> In a 1-d array, find the first point where all subsequent points >> have values >> less than a threshold, T. > > Maybe something like: >>>

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Alan G Isaac
On 2/9/2011 10:58 AM, Neal Becker wrote: > But where is numpy's 'find_first' function? np.argmax(array>T) (Of course that constructs a boolean array...) Alan Isaac ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mail

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Zachary Pincus
On Feb 9, 2011, at 10:58 AM, Neal Becker wrote: > Zachary Pincus wrote: > > In a 1-d array, find the first point where all subsequent points > have values > less than a threshold, T. Maybe something like: last_greater = numpy.arange(arr.shape)[arr >= T][-1] fi

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Neal Becker
Zachary Pincus wrote: In a 1-d array, find the first point where all subsequent points have values less than a threshold, T. >>> >>> Maybe something like: >>> >>> last_greater = numpy.arange(arr.shape)[arr >= T][-1] >>> first_lower = last_greater + 1 >>> >>> There's probably a bette

[Numpy-discussion] 2d*3d matrix dot product

2011-02-09 Thread Davide Lasagna
Hi, I want to compute the following dot product: P = np.array( [[ p11, p12 ], [p21, p22]] ) C = np.array( [c1, c2] ) where c1 and c2 are m*m matrices, so that C.shape = (2,m,m) I want to compute: A = np.array([a1, a2]) where a1 and a2 are two matrices m*m, from the dot product of P and C.

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Zachary Pincus
>>> In a 1-d array, find the first point where all subsequent points >>> have values >>> less than a threshold, T. >> >> Maybe something like: >> >> last_greater = numpy.arange(arr.shape)[arr >= T][-1] >> first_lower = last_greater + 1 >> >> There's probably a better way to do it, without the arang

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Neal Becker
Zachary Pincus wrote: >> In a 1-d array, find the first point where all subsequent points >> have values >> less than a threshold, T. > > Maybe something like: > > last_greater = numpy.arange(arr.shape)[arr >= T][-1] > first_lower = last_greater + 1 > > There's probably a better way to do it, w

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Zachary Pincus
> In a 1-d array, find the first point where all subsequent points > have values > less than a threshold, T. Maybe something like: last_greater = numpy.arange(arr.shape)[arr >= T][-1] first_lower = last_greater + 1 There's probably a better way to do it, without the arange, though... __

[Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Neal Becker
In a 1-d array, find the first point where all subsequent points have values less than a threshold, T. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] question on use of newaxis

2011-02-09 Thread Friedrich Romstedt
2011/2/9 Mark Bakker : > a = array([1,2,3]) > > I want to take the last two terms and make it a column vector: > > a[[1,2],newaxis] > a[[1,2]][:,newaxis] The former is advanced indexing, while the latter is basic slicing (after advanced indexing). See http://docs.scipy.org/doc/numpy/reference/arr

[Numpy-discussion] question on use of newaxis

2011-02-09 Thread Mark Bakker
Hello List, I have a simple array a = array([1,2,3]) I want to take the last two terms and make it a column vector: a[[1,2],newaxis] But I get a funny error: TypeError: long() argument must be a string or a number, not 'NoneType' It does work if I do a[[1,2]][:,newaxis] But I don't understa

Re: [Numpy-discussion] Indexing a 2-d array with a 1-d mask

2011-02-09 Thread Friedrich Romstedt
Hi, 2011/2/8 Alok Singhal : > Hi, > > I have an NxM array, which I am indexing with a 1-d, length N boolean > array.  For example, with a 3x5 array: > > In [1]: import numpy > In [2]: data = numpy.arange(15) > In [3]: data.shape = 3, 5 > > Now, I want to select rows 0 and 2, so I can do: > > In [4