[SciPy-user] extracting elements of a matrix using arrays as indices
Michael Hearne
mhearne@usgs....
Tue May 20 15:43:28 CDT 2008
Neilen - Thanks. Unfortunately, I've either discovered a bug or have
failed to understand how to use this function. The below code snippet:
from pylab import *
import numpy
print numpy.__version__, numpy.__file__
data = rand(648,690)
i,j = (data < 0.14).nonzero()
data[ix_(i,j)] = data[ix_(i,j)]*0
print 'No crash.'
returns:
1.1.0.dev5077 /Library/Python/2.5/site-packages/numpy-1.1.0.dev5077-
py2.5-macosx-10.3-i386.egg/numpy/__init__.pyc
Segmentation fault
I'm using the numpy that came with the SciPy SuperPack, created on or
before April 30, on Mac OS X 10.5.2.
If this is my fault, can someone point out the flaw in my code?
If this is a bug, I'll be happy to submit a bug in some sort of
tracking system, and provide whatever information is desired by a
developer.
Thanks,
Mike
On May 20, 2008, at 9:06 AM, Neilen Marais wrote:
> Hi Mike
>
> On Tue, 20 May 2008 08:03:36 -0600, Michael Hearne wrote:
>
>> In Python:
>> a = array([[ 11, 12, 13, 14 ],
>> [ 21, 22, 23, 24 ],
>> [ 31, 32, 33, 34 ]])
>>
>> a[[0,2],[0,3]]
>>
>> gives you:
>>
>> array([11, 34])
>
> I think you're looking for
>
> a[ix_([0,2], [0,3])]
>
> ix_ == numpy.ix_
>
> Regards
> Neilen
>
>
> _______________________________________________
> 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/20080520/8357f655/attachment.html
More information about the SciPy-user
mailing list