[SciPy-user] extracting elements of a matrix using arrays as indices
Alan McIntyre
alan.mcintyre@gmail....
Wed May 21 09:10:19 CDT 2008
On Wed, May 21, 2008 at 9:51 AM, Michael Hearne <mhearne@usgs.gov> wrote:
> If I try that on a larger example, similar to the second one I made
> yesterday:
> nrows = 648
> ncols = 690
> data = rand(nrows,ncols)
> i,j = (data < 0.14).nonzero()
> data[i,:][:,j] = data[i,:][:,j]*0
> I get another segmentation fault.
This works for me (assuming you're trying to set elements in data that
are less than 0.14 to zero):
nrows = 648
ncols = 690
data = rand(nrows,ncols)
z = (data < 0.14).nonzero()
data[z] = 0
More information about the SciPy-user
mailing list