Segfault when indexing on second or higher dimension with list or tuple
Hello all, The following segfault bug was discovered in NumPy 0.9.7.2348 by someone at our Python workshop: import numpy as N F = N.zeros((1,1)) F[:,[0]] = 0 The following also segfaults: F[:,(0,)] = 0 Something seems to go wrong when one uses a tuple or a list to index into a NumPy array on the second or higher dimension, since the following code works: F = N.zeros((1,)) F[[0]] = 0 The Trac ticket is here: http://projects.scipy.org/scipy/numpy/ticket/59 If someone gets around to fixing this, please include some test cases. Thanks! Regards, Albert
Hello all I've attached a test case that reproduces the bug to the ticket: http://projects.scipy.org/scipy/numpy/attachment/ticket/59/test_list_tuple_i... I've also created a test case for the recent vectorize bug: http://projects.scipy.org/scipy/numpy/attachment/ticket/52/test_vectorize.di... Regards, Albert On Thu, 13 Apr 2006, Albert Strasheim wrote:
Hello all,
The following segfault bug was discovered in NumPy 0.9.7.2348 by someone at our Python workshop:
import numpy as N F = N.zeros((1,1)) F[:,[0]] = 0
The following also segfaults:
F[:,(0,)] = 0
Something seems to go wrong when one uses a tuple or a list to index into a NumPy array on the second or higher dimension, since the following code works:
F = N.zeros((1,)) F[[0]] = 0
The Trac ticket is here:
http://projects.scipy.org/scipy/numpy/ticket/59
If someone gets around to fixing this, please include some test cases.
Thanks!
Regards,
Albert
------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Albert Strasheim wrote:
Hello all,
The following segfault bug was discovered in NumPy 0.9.7.2348 by someone at our Python workshop:
import numpy as N F = N.zeros((1,1)) F[:,[0]] = 0
The following also segfaults:
F[:,(0,)] = 0
Something seems to go wrong when one uses a tuple or a list to index into a NumPy array on the second or higher dimension, since the following code works:
The segfault was due to an error condition not being caught. This is now fixed, so now you get (a rather cryptic error). Now, to figure out why this code doesn't work.... -Travis
Travis Oliphant wrote:
Albert Strasheim wrote:
Hello all,
The following segfault bug was discovered in NumPy 0.9.7.2348 by someone at our Python workshop:
import numpy as N F = N.zeros((1,1)) F[:,[0]] = 0
The following also segfaults:
F[:,(0,)] = 0
Something seems to go wrong when one uses a tuple or a list to index into a NumPy array on the second or higher dimension, since the following code works:
The segfault was due to an error condition not being caught. This is now fixed, so now you get (a rather cryptic error). Now, to figure out why this code doesn't work....
The problem is that the code is not handling arbitrary shapes on the RHS of the equal sign. I'll enter a ticket and fix this before 0.9.8. Basically, right now, the RHS needs to have the same shape as the LHS so F[:,[0]] = [[0]] should work already. -Travis
participants (2)
-
Albert Strasheim
-
Travis Oliphant