
Has anyone yet noted this? The following code works in python1.5.2 (Numeric.__version__ == '11'). However, in python2.0 (with Numeric.__version__ == '17.1.1') and python2.1 (with Numeric.__version__ == '20.0.0'), it doesn't work correctly. coords[3][3] is mis-assigned. It happens at least on SGI and Sun. I've not seen anything in the change lists for 20.1 or 20.2 about such a bug. # # bug.py # import Numeric coords = Numeric.resize(Numeric.array(range(17*4)), (17,4)) print "before coords[3]: ", coords[3] list = [3, 15] takecoords = Numeric.take(coords, list) print "takecoords:" print takecoords print "coords.iscontiguous: ", coords.iscontiguous() Numeric.put(coords, list, takecoords) print "after coords[3]: ", coords[3] ********************************** William M. Lindstrom, Jr., Ph.D. Molecular Graphics Laboratory Department of Molecular Biology, MB-5 The Scripps Research Institute 10550 North Torrey Pines Road La Jolla, CA 92037-1000 USA Tel: (858) 784-2055 Fax: (858) 784-2860 E-mail: lindy@scripps.edu

On Friday 05 October 2001 11:10 am, you wrote:
I'm not sure why this worked in Numeric version 11, but it appears you are using the put function incorrectly. The documentation might need to be fixed to emphasize that the index list is interpreted as a one-dimensional index into a flattened representation of the array. The put function does the equivalent of the operation: a.flat[n] = v.flat[n] In other words, if a is a 2-d array, then the index list does NOT represent indices into the rows of the array. It represents indicies into the flattened array. In your example, the function is working correctly. It is placing a 12 into the 3 position in the array (i.e. row 0 column 3) and placing a 13 into the 15th position in the array (i.e. row 3 column 3). Like I said, I'm not sure why this worked in Numeric 11 --- it shouldn't have. -Travis

On Friday 05 October 2001 11:10 am, you wrote:
I'm not sure why this worked in Numeric version 11, but it appears you are using the put function incorrectly. The documentation might need to be fixed to emphasize that the index list is interpreted as a one-dimensional index into a flattened representation of the array. The put function does the equivalent of the operation: a.flat[n] = v.flat[n] In other words, if a is a 2-d array, then the index list does NOT represent indices into the rows of the array. It represents indicies into the flattened array. In your example, the function is working correctly. It is placing a 12 into the 3 position in the array (i.e. row 0 column 3) and placing a 13 into the 15th position in the array (i.e. row 3 column 3). Like I said, I'm not sure why this worked in Numeric 11 --- it shouldn't have. -Travis
participants (2)
-
Lindy Lindstrom
-
Travis Oliphant