Re: [Numpy-discussion] numpy.distutils quirk

2011-10-18 Thread Ralf Gommers
On Tue, Oct 11, 2011 at 4:59 PM, Robert Cimrman wrote: > Hi, > > I have now spent several hours hunting down a major slowdown of my code > caused > (apparently) by using config.add_library() for a reusable part of C source > files instead of just config.add_extension(). > > The reason of the slow

Re: [Numpy-discussion] np.ma.mean is not working?

2011-10-18 Thread Chao YUE
I would say pandas is really cool. More people need to know it. and we should have better documentation. cheers, Chao 2011/10/18 Bruce Southey > ** > On 10/18/2011 09:12 AM, Chao YUE wrote: > > thanks. Olivier. I see. > > Chao > > 2011/10/18 Olivier Delalleau > >> As far as I can tell ma.mean

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-18 Thread Matthew Brett
Hi, 2011/10/18 Frédéric Bastien : > What about a parameter that allow to select the option the user want? > it would select between uint, upcasted_int, -MAX and +MAX. This way, > at least it will be documented and user who care will have the choose. > > Personally, when the option is available, I

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-18 Thread Frédéric Bastien
What about a parameter that allow to select the option the user want? it would select between uint, upcasted_int, -MAX and +MAX. This way, at least it will be documented and user who care will have the choose. Personally, when the option is available, I would prefer the safe version, uint, but I u

Re: [Numpy-discussion] np.ma.mean is not working?

2011-10-18 Thread Chao YUE
Thanks Bruce. 2011/10/18 Bruce Southey > ** > On 10/18/2011 09:12 AM, Chao YUE wrote: > > thanks. Olivier. I see. > > Chao > > 2011/10/18 Olivier Delalleau > >> As far as I can tell ma.mean() is working as expected here: it computes >> the mean only over non-masked values. >> If you want to get

Re: [Numpy-discussion] anyway to check a ndarray is a mased array or not?

2011-10-18 Thread Eric Firing
On 10/18/2011 03:13 AM, Olivier Delalleau wrote: > if hasattr(a, 'mask'): # or if isinstance(a, numpy.ma.core.MaskedArray.) or if numpy.ma.isMA(a): or if numpy.ma.isMaskedArray(a): Eric > code 1 > else > code 2 > > -=- Olivier > > 2011/10/18 Chao YUE mailto:chaoyue...@gmail.com>>

Re: [Numpy-discussion] np.ma.mean is not working?

2011-10-18 Thread Bruce Southey
On 10/18/2011 09:12 AM, Chao YUE wrote: thanks. Olivier. I see. Chao 2011/10/18 Olivier Delalleau mailto:sh...@keba.be>> As far as I can tell ma.mean() is working as expected here: it computes the mean only over non-masked values. If you want to get rid of any mean that was compute

Re: [Numpy-discussion] index the last several members of a ndarray

2011-10-18 Thread Chao YUE
thanks Scott. very good explanation. cheers, Chao 2011/10/18 Scott Sinclair > On 18 October 2011 13:56, Chao YUE wrote: > > but it's strange that if you use b[...,-1], > > you get: > > In [402]: b[...,-1] > > Out[402]: array([ 9, 19]) > > > > if use b[...,-4:-1], > > you get: > > Out[403]: >

Re: [Numpy-discussion] np.ma.mean is not working?

2011-10-18 Thread Chao YUE
thanks. Olivier. I see. Chao 2011/10/18 Olivier Delalleau > As far as I can tell ma.mean() is working as expected here: it computes the > mean only over non-masked values. > If you want to get rid of any mean that was computed over a series > containing masked value you can do: > > b = a.mean(0

Re: [Numpy-discussion] index the last several members of a ndarray

2011-10-18 Thread Scott Sinclair
On 18 October 2011 13:56, Chao YUE wrote: > but it's strange that if you use b[...,-1], > you get: > In [402]: b[...,-1] > Out[402]: array([ 9, 19]) > > if use b[...,-4:-1], > you get: > Out[403]: > array([[ 6,  7,  8], >    [16, 17, 18]]) That's because you're mixing two different indexing c

Re: [Numpy-discussion] anyway to check a ndarray is a mased array or not?

2011-10-18 Thread Chao YUE
really cool, thanks. Chao 2011/10/18 Olivier Delalleau > if hasattr(a, 'mask'): # or if isinstance(a, numpy.ma.core.MaskedArray.) > > code 1 > else > code 2 > > -=- Olivier > > > 2011/10/18 Chao YUE > >> Thanks Olivier. but I don't know how can I check it in the code (not in an >> i

Re: [Numpy-discussion] anyway to check a ndarray is a mased array or not?

2011-10-18 Thread Olivier Delalleau
if hasattr(a, 'mask'): # or if isinstance(a, numpy.ma.core.MaskedArray.) code 1 else code 2 -=- Olivier 2011/10/18 Chao YUE > Thanks Olivier. but I don't know how can I check it in the code (not in an > interactive mode)? > I would like: > > if ndarray a is a mased array: > cod

Re: [Numpy-discussion] np.ma.mean is not working?

2011-10-18 Thread Olivier Delalleau
As far as I can tell ma.mean() is working as expected here: it computes the mean only over non-masked values. If you want to get rid of any mean that was computed over a series containing masked value you can do: b = a.mean(0) b.mask[a.mask.any(0)] = True Then b will be: masked_array(data = [5.0

Re: [Numpy-discussion] anyway to check a ndarray is a mased array or not?

2011-10-18 Thread Chao YUE
Thanks Olivier. but I don't know how can I check it in the code (not in an interactive mode)? I would like: if ndarray a is a mased array: code 1 else code 2 thanks again, Chao 2011/10/18 Olivier Delalleau > You could simply check if it has a 'mask' attribute. You can also check if

Re: [Numpy-discussion] anyway to check a ndarray is a mased array or not?

2011-10-18 Thread Olivier Delalleau
You could simply check if it has a 'mask' attribute. You can also check if it is an instance of numpy.ma.core.MaskedArray. -=- Olivier Le 18 octobre 2011 08:49, Chao YUE a écrit : > Just one more question, how can I check a ndarray is a masked array or not? > > Chao > -- > > ***

[Numpy-discussion] anyway to check a ndarray is a mased array or not?

2011-10-18 Thread Chao YUE
Just one more question, how can I check a ndarray is a masked array or not? Chao -- *** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191

[Numpy-discussion] np.ma.mean is not working?

2011-10-18 Thread Chao YUE
Dear all, previoulsy I think np.ma.mean() will automatically filter the masked (missing) value but it's not? In [489]: a=np.arange(20.).reshape(2,10) In [490]: a=np.ma.masked_array(a,(a==2)|(a==5)|(a==11)|(a==18),fill_value=np.nan) In [491]: a Out[491]: masked_array(data = [[0.0 1.0 -- 3.0 4.0

Re: [Numpy-discussion] index the last several members of a ndarray

2011-10-18 Thread Chao YUE
you are right Eric, In [405]: b[...,-4:] Out[405]: array([[ 6, 7, 8, 9], [16, 17, 18, 19]]) cheers, Chao 2011/10/18 Chao YUE > Thanks Jean > I just want the last several numbers by indexing from the end. > > In [400]: b=np.arange(20).reshape(2,10) > > In [401]: b > Out[401]: > array

Re: [Numpy-discussion] index the last several members of a ndarray

2011-10-18 Thread Chao YUE
Thanks Jean I just want the last several numbers by indexing from the end. In [400]: b=np.arange(20).reshape(2,10) In [401]: b Out[401]: array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) I want something like b[...,...(index from the end by using

Re: [Numpy-discussion] index the last several members of a ndarray

2011-10-18 Thread Éric Depagne
Le mardi 18 octobre 2011 13:44:00, Chao YUE a écrit : > Dear all, > > if I have > > In [395]: a > Out[395]: > array([[0, 1, 2, 3, 4], >[5, 6, 7, 8, 9]]) > > In [396]: a[...,-1] > Out[396]: array([4, 9]) > > In [397]: a[...,-4:-1] > Out[397]: > array([[1, 2, 3], >[6, 7, 8]]) > >

Re: [Numpy-discussion] index the last several members of a ndarray

2011-10-18 Thread Jean-Luc Menut
> how can I pick up something like: > array([[1, 2, 3, 4], > [6, 7, 8, 9]]) I'm not sure to understand, should not a[:,1:] be sufficient ? Did I miss something in your message ? ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http:

[Numpy-discussion] index the last several members of a ndarray

2011-10-18 Thread Chao YUE
Dear all, if I have In [395]: a Out[395]: array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]) In [396]: a[...,-1] Out[396]: array([4, 9]) In [397]: a[...,-4:-1] Out[397]: array([[1, 2, 3], [6, 7, 8]]) In [398]: a[...,-4:0] Out[398]: array([], shape=(2, 0), dtype=int64) how can I pick up s

Re: [Numpy-discussion] Example Usage of Neighborhood Iterator in Cython

2011-10-18 Thread Nadav Horesh
Just in time! I was just working on a cythonic replacement to ndimage.generic_filter (well, I took a a short two years break in the middle). thank you very much, Nadav. From: numpy-discussion-boun...@scipy.org [numpy-discussion-boun...@scipy.org] On