[Numpy-discussion] Segfault on wrong use of indexing
Charles R Harris
charlesr.harris@gmail....
Mon Sep 17 11:43:03 CDT 2007
Hi Arnar,
On 9/17/07, Arnar Flatberg <arnar.flatberg@gmail.com> wrote:
>
> Hi list
> A pretty common use (for me) is to create arrays at the beginning of
> my code and then fill in parts as I go along. Today, my code hit a
> segmentation fault. The error was that an index-vector ,that usually
> is a list with several members, now contained only one member and I
> tried to insert a 1-dim vector.
>
> Here is a short example of what went wrong:
>
> Python 2.5.1 (r251:54863, May 2 2007, 16:56:35)
> [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import numpy as n
> >>> n.__version__
> '1.0.1'
> >>> a = n.random.rand(4,2)
> >>> a
> array([[ 0.79561255, 0.4932522 ],
> [ 0.84008255, 0.88258233],
> [ 0.35143166, 0.82214487],
> [ 0.12490114, 0.15799074]])
>
> Let us insert [2,2] into the first row.
> Correct use:
> >>> a[0,:] = [2,2]
> >>> a
> array([[ 2. , 2. ],
> [ 0.84008255, 0.88258233],
> [ 0.35143166, 0.82214487],
> [ 0.12490114, 0.15799074]])
> or:
> a[[0],:] = [[2,2]]
>
> However, when I tried to to insert a 1-dim array with a 'two-dim'
> index things went wrong:
> >>> a[[0],:] = [2,2]
> Segmentation fault
I don't see that here. Can you try a more recent version of Numpy? 1.0.1 is
pretty old.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070917/ca37fde3/attachment.html
More information about the Numpy-discussion
mailing list