It is an advertised difference between MA and Numeric that index operations
return copies, not references.
-----Original Message-----
From: num...@li...
[mailto:num...@li...]On Behalf Of Joe
Van Andel
Sent: Thursday, June 28, 2001 3:42 PM
To: numpy-discussion
Subject: [Numpy-discussion] MA : assignment to slices doesn't work like
Numeric.
I retrieved the latest MA from CVS. I've noticed that assigning to a
slice doesn't work the same as Numeric.
Here's a simple test program:
--------------------------------
from MA import *
#from Numeric import *
numBeams,numGates = (5,4)
result = ones((numBeams, numGates),'f') * -327.68
print 'result = ', result
t1 = ones((numGates,),'f')
t2 = 2* ones((numGates,),'f')
result[0] = t1
result[1][:] = t2
print 'result = ', result
-----------------------------------------
Output using 'MA':
result = [[-327.68,-327.68,-327.68,-327.68,]
[-327.68,-327.68,-327.68,-327.68,]
[-327.68,-327.68,-327.68,-327.68,]
[-327.68,-327.68,-327.68,-327.68,]
[-327.68,-327.68,-327.68,-327.68,]]
result = [[ 1. , 1. , 1. , 1. ,]
[-327.68,-327.68,-327.68,-327.68,]
[-327.68,-327.68,-327.68,-327.68,]
[-327.68,-327.68,-327.68,-327.68,]
[-327.68,-327.68,-327.68,-327.68,]]
However, if I use Numeric, rather than MA, I get:
result = [[-327.68 -327.68 -327.68 -327.68]
[-327.68 -327.68 -327.68 -327.68]
[-327.68 -327.68 -327.68 -327.68]
[-327.68 -327.68 -327.68 -327.68]
[-327.68 -327.68 -327.68 -327.68]]
result = [[ 1. 1. 1. 1. ]
[ 2. 2. 2. 2. ]
[-327.68 -327.68 -327.68 -327.68]
[-327.68 -327.68 -327.68 -327.68]
[-327.68 -327.68 -327.68 -327.68]]
So,
a[x][:] = my_array
doesn't seem to work using 'MA'.
--
Joe VanAndel
National Center for Atmospheric Research
http://www.atd.ucar.edu/~vanandel/
Internet: van...@uc...
_______________________________________________
Numpy-discussion mailing list
Num...@li...
http://lists.sourceforge.net/lists/listinfo/numpy-discussion
|