[Numpy-discussion] Matrix element assignment
Blair Hall
b.hall at irl.cri.nz
Sun Mar 16 15:26:16 EST 2003
I have upgraded from NumPy 21 to NumPy 23 and am
surprised to find that my matrix assignment doesn't work like it used to.
For example:
>>> from Matrix import *
>>> m = Matrix( [[1,2],[3,4]])
>>> m[1,1]
4
>>> m[1,1] = 2
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\PYTHON22\lib\site-packages\Numeric\Matrix.py", line 183, in
__setitem__
value = value[0,0]
IndexError: invalid index
>>>
Apparently, I should have written
>>> m[1,1] = Matrix( 2 )
Is this really indended, or am I confused?
The change appears to have been introduced
to NumPy in release 21.3
I note that similar code using an array does work:
>>> from Numeric import *
>>> m = array( [[1,2],[3,4]])
>>> m[1,1]
4
>>> m[1,1] = 3
>>> m[1,1]
3
More information about the NumPy-Discussion
mailing list