assigning to matrix elements in NumPy

Blair Hall b.hall at irl.cri.nz
Tue Mar 11 21:52:08 EST 2003


I have just upgraded from NumPy 21 to NumPy 23 and was
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?






More information about the Python-list mailing list