Re: [Numpy-discussion] at my wits end over an error message...

2008-08-30 Thread Alan Jackson
Thanks. I'm still struggling with learning the idiom. Too much perl to unlearn. 8-) On Sat, 30 Aug 2008 23:10:10 -0400 Zachary Pincus <[EMAIL PROTECTED]> wrote: > Hi Alan, > > > Traceback (most recent call last): > > File "/usr/local/lib/python2.5/site-packages/enthought.traits-2.0.4- > > py2.

Re: [Numpy-discussion] at my wits end over an error message...

2008-08-30 Thread Zachary Pincus
Hi Alan, > Traceback (most recent call last): > File "/usr/local/lib/python2.5/site-packages/enthought.traits-2.0.4- > py2.5-linux-i686.egg/enthought/traits/trait_notifiers.py", line 325, > in call_1 >self.handler( object ) > File "TrimMapl_1.py", line 98, in _Run_fired >outdata = np.

Re: [Numpy-discussion] huge array calculation speed

2008-08-30 Thread Fernando Perez
[ Sorry I never sent this, I just found it in my drafts folder. Just in case it's useful to the OP, here it is. ] On Thu, Jul 10, 2008 at 9:38 AM, Dan Lussier <[EMAIL PROTECTED]> wrote: > r2 = numpy.power(r2,2).sum(axis=1) > > r2 = numpy.extract(r2

[Numpy-discussion] at my wits end over an error message...

2008-08-30 Thread Alan Jackson
I been beating myself up over this bit of code for far too long now - I know I must be missing something really simple, but what is it? TYPICALLY_UINT_COLUMNS = ['Track', 'Bin', 'code', 'horizon'] .. dtypes = [ ] for i in range(0, len(self.var_list)) : if TYPICALLY_

Re: [Numpy-discussion] How do I do this?

2008-08-30 Thread Christopher Barker
Stéfan van der Walt wrote: > Maybe > > (np.sign(a) | 1) * np.maximum(np.abs(a), min_value) > > is a little bit easier on the eye. nice! that does it. somehow I never think of using or. Alan G Isaac wrote: > idx = np.abs(a) a[idx] = min_value*(np.sign(a[idx]) + (a[idx]==0)) that's do it too,

[Numpy-discussion] default index inconsistency?

2008-08-30 Thread Alan G Isaac
I think the question of the timing of removing the remaining default index inconsistencies in NumPy was raised by not answered? Anyway, what is the answer? I just ran into this again, this time with ``argsort``, which still has ``axis=-1`` as the default. But maybe it is intentional to keep this

Re: [Numpy-discussion] How do I do this?

2008-08-30 Thread Keith Goodman
On Sat, Aug 30, 2008 at 7:29 AM, Keith Goodman <[EMAIL PROTECTED]> wrote: > On Sat, Aug 30, 2008 at 6:24 AM, Alan G Isaac <[EMAIL PROTECTED]> wrote: >> Stéfan van der Walt wrote: >>> (np.sign(a) | 1) ... >> >> Ah, that's nice. How about >> idx = np.abs(a)> a[idx] = min_value*(np.sign(a[idx]) | 1) >

Re: [Numpy-discussion] How do I do this?

2008-08-30 Thread Keith Goodman
On Sat, Aug 30, 2008 at 6:24 AM, Alan G Isaac <[EMAIL PROTECTED]> wrote: > Stéfan van der Walt wrote: >> (np.sign(a) | 1) ... > > Ah, that's nice. How about > idx = np.abs(a) a[idx] = min_value*(np.sign(a[idx]) | 1) Or, since he asked to do it in one line, >> min_value = 2 >> x array([ 1, 2,

Re: [Numpy-discussion] How do I do this?

2008-08-30 Thread Alan G Isaac
Stéfan van der Walt wrote: > (np.sign(a) | 1) ... Ah, that's nice. How about idx = np.abs(a)http://projects.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] How do I do this?

2008-08-30 Thread Alan G Isaac
Christopher Barker wrote: > 0 should go to 2 --it's not, because sign(0) == 0, so the 2 gets turned > to zero, my original problem. Odd asymmetry. Then you can use Keith's version. Or a[idx] = min_value*(np.sign(a[idx]) + (a[idx]==0)) Alan ___ Nump