[SciPy-user] extracting elements of a matrix using arrays as indices (SEGFAULT!)
Michael Hearne
mhearne@usgs....
Wed May 21 09:35:47 CDT 2008
Thanks for the help - the method below works just fine in my real
application (which has nothing to do with setting elements of an array
to zero - that was just a simple example of something to _do_ with the
data being indexed).
However, I am still concerned about the larger problem of getting a
segfault using ANY method of indexing an array. If it is user error
that is causing the problem, then shouldn't I get an exception that
tells me my syntax is somehow incorrect?
I've added SEGFAULT to the subject line in hopes that someone
responsible for the core NumPy code (Travis O., perhaps?) will take
notice and address the issue. If that happens, once again, I'm happy
to help test on my version of NumPy wherever needed.
Thanks for all the suggestions,
Mike
On May 21, 2008, at 8:10 AM, Alan McIntyre wrote:
> 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
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
------------------------------------------------------
Michael Hearne
mhearne@usgs.gov
(303) 273-8620
USGS National Earthquake Information Center
1711 Illinois St. Golden CO 80401
Senior Software Engineer
Synergetics, Inc.
------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20080521/9708f352/attachment.html
More information about the SciPy-user
mailing list