# [Numpy-discussion] MA : assignment to slices doesn't work like Numeric.

Joe Van Andel vanandel at atd.ucar.edu
Thu Jun 28 18:41:33 EDT 2001

```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: vanandel at ucar.edu

```