[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

[Numpy-discussion] Masked arrays to Compressed arrays

2010-10-01 Thread Jesper Larsen
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): &q

[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 t

[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] = []

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

[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 simpl

Re: [Numpy-discussion] corrcoef of masked array

2007-06-04 Thread Jesper Larsen
On Wednesday 30 May 2007 19:48, Robert Kern wrote: > I'm afraid this doesn't work, either. Correlation matrices are constrained > to be positive semidefinite; that is, all of their eigenvalues must be >= > 0. Calculating each of the correlation coefficients in a pairwise fashion > doesn't incorpora

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 calcu

[Numpy-discussion] corrcoef of masked array

2007-05-25 Thread Jesper Larsen
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 of a masked array (it seems to give reasonable results)? Cheers, Jesper __