[Numpy-discussion] Fancy indexing with masks

2011-09-19 Thread Stéfan van der Walt
Hi all, Matthew Brett showed me an interesting code snippet this evening: # Construct input data In [15]: x Out[15]: array([[ 0, 1, 2], [ 3, 4, 5], [ 6, 7, 8], [ 9, 10, 11]]) # Fancy indexing with 1D boolean array In [16]: x[np.array([True, False, True])] Out[16]: ar

Re: [Numpy-discussion] Upgrade to 1.6.x: frompyfunc() ufunc casting issue

2011-09-19 Thread Stéfan van der Walt
On Mon, Sep 19, 2011 at 4:18 PM, Aditya Sethi wrote: > But uadd.accumulate(..) or uadd.reduce(..) fail with error: >  ValueError: could not find a matching type for add (vectorized).accumulate > ( or (vectorized).reduce ) > Apologies, I should have been more clear before. In the development versi

Re: [Numpy-discussion] Upgrade to 1.6.x: frompyfunc() ufunc casting issue

2011-09-19 Thread Aditya Sethi
Hi Stefan, The problem arises when you try to use methods of the ufunc. So for the custom universal function previously defined, uadd: uadd([1,2,3],[1,2,3]) works fine. But uadd.accumulate(..) or uadd.reduce(..) fail with error: ValueError: could not find a matching type for add (vectorized).acc

Re: [Numpy-discussion] Upgrade to 1.6.x: frompyfunc() ufunc casting issue

2011-09-19 Thread Stéfan van der Walt
Hi, On Mon, Sep 19, 2011 at 2:38 PM, Aditya Sethi wrote: > I am facing an issue upgrading numpy from 1.5.1 to 1.6.1. > In numPy 1.6, the casting behaviour for ufunc has changed and has become > stricter. > Can someone advise how to implement the below simple example which worked in > 1.5.1 but fa

[Numpy-discussion] Upgrade to 1.6.x: frompyfunc() ufunc casting issue

2011-09-19 Thread Aditya Sethi
Hi all, I am facing an issue upgrading numpy from 1.5.1 to 1.6.1. In numPy 1.6, the casting behaviour for ufunc has changed and has become stricter. Can someone advise how to implement the below simple example which worked in 1.5.1 but fails in 1.6.1? >>> import numpy as np >>> def add(a,b): ...

Re: [Numpy-discussion] OS X Lion: llvm: numpy and scipy

2011-09-19 Thread Ralf Gommers
On Mon, Sep 19, 2011 at 3:03 PM, Samuel John wrote: > Ahoy numpy gurus :-) > > Would it be possible to adapt the setup.py and/or numpy/distutils to set > the right variables on Mac OS X 10.7? (see below). > I have looked a bit into the setup.py and the distutils package of numpy > but I am a bit

Re: [Numpy-discussion] Preventing an ndarray subclass from returning new subclass instances for std(), etc

2011-09-19 Thread Pierre GM
> > Anyway, back on topic - I'm having similar problems as Keith. It seems like > there isn't consistency on how different built-in functions treat > array_wrap/finalize/etc, or maybe I'm still confused. Actually, that depends on the np function you need. Functions like np.std… first call the

Re: [Numpy-discussion] Preventing an ndarray subclass from returning new subclass instances for std(), etc

2011-09-19 Thread Aronne Merrelli
On Sun, Sep 18, 2011 at 3:58 PM, Wes McKinney wrote: > > I thought maybe you can intercept 0-dim objects and return self.item() > in array_finalize, but not dice. This is really weird: > > import numpy as np > > class example(np.ndarray): > >def __new__(cls, arr): >return np.array(arr

[Numpy-discussion] OS X Lion: llvm: numpy and scipy

2011-09-19 Thread Samuel John
Ahoy numpy gurus :-) Would it be possible to adapt the setup.py and/or numpy/distutils to set the right variables on Mac OS X 10.7? (see below). I have looked a bit into the setup.py and the distutils package of numpy but I am a bit lost. Do you think it's possible to teach numpy to use differe

Re: [Numpy-discussion] Indexing by label in 3rd dimension

2011-09-19 Thread Benjamin Landenberger
Great! Thank you! On 16/09/2011 17:43, Warren Weckesser wrote: > > > On Fri, Sep 16, 2011 at 10:18 AM, Benjamin Landenberger > > wrote: > > Hello list! > > I have an array *mask* of shape (a, b) and another array *intensities* >