[Numpy-discussion] Masked arrays to Compressed arrays

2010-10-01 Thread Jesper Larsen
not subclassed MA but that might be an alternative solution: Compressed array. A compressed array is an alternative to numpy masked arrays designed to reduce memory consumption. Jesper Larsen, 2010 # External imports import numpy as np def _compress(arr): Compresses array. mask

[Numpy-discussion] np.where and broadcasting

2011-10-10 Thread Jesper Larsen
Hi numpy-users I have a 2d array of shape (ny, nx). I want to broadcast (copy) this array to a target array of shape (nt, nz, ny, nz) or (nt, ny, nx) so that the 2d array is repeated for each t and z index (corresponding to nt and nz). I am not sure how to do this (generic solution, for different

Re: [Numpy-discussion] corrcoef of masked array

2007-05-30 Thread Jesper Larsen
On Friday 25 May 2007 19:18, Robert Kern wrote: Jesper Larsen wrote: Hi numpy users, I have a masked array of dimension (nvariables, nobservations) that contain missing values at arbitrary points. Is it safe to rely on numpy.corrcoeff to calculate the correlation coefficients

[Numpy-discussion] Setting element to masked in a masked array previously containing no masked values

2007-06-25 Thread Jesper Larsen
Hi numpy users, I have a masked array. I am looping over the elements of this array and sometimes want to set a value to missing. Normally this can be done by: myarray.mask[i] = True However the mask attribute is not indexable when there are no existing missing values in the array (it is

Re: [Numpy-discussion] Setting element to masked in a masked array previously containing no masked values

2007-06-25 Thread Jesper Larsen
Hi Pierre and others, On Monday 25 June 2007 15:37, Pierre GM wrote: On Monday 25 June 2007 05:12:01 Jesper Larsen wrote: myarray.mask[i] = True Mmh. Experience shows that directly accessing the mask can lead to bad surprises. To mask a series of values in an array, the easiest

[Numpy-discussion] multiprocessing shared arrays and numpy

2010-03-03 Thread Jesper Larsen
Hi people, I was wondering about the status of using the standard library multiprocessing module with numpy. I found a cookbook example last updated one year ago which states that: This page was obsolete as multiprocessing's internals have changed. More information will come shortly; a link to

[Numpy-discussion] Creating array containing empty lists

2009-03-25 Thread Jesper Larsen
Hi numpy people, I have a problem with array broadcasting for object arrays and list. I would like to create a numpy array containing empty lists (initially - I will append to them later): import numpy as npy a = npy.empty((2), dtype=npy.object_) # Works fine: for i in range(len(a)): a[i] =