Skip to content

matrix slicing broken #267

@archeryguru2000

Description

@archeryguru2000
When trying to manipulate matrices using mpmath, I'm confronted with an obstacle.  Using scipy/numpy/etc. one can call (and thus modify/alter/etc.) a "section" of a matrix, i.e., slicing the matrix.  However, with mpmath.matrix I'm unable to do so.  Is there an acceptable workaround to this. What steps will reproduce the problem? >>> from sympy import Matrix as sm_matrix
>>> from scipy import matrix as sp_matrix
>>> from mpmath import matrix as mp_matrix
>>> 
>>> my = sm_matrix([[1,2,3],[4,5,6],[7,8,9]])
>>> mc = sp_matrix([[1,2,3],[4,5,6],[7,8,9]])
>>> mp = mp_matrix([[1,2,3],[4,5,6],[7,8,9]])
>>> 
>>> my[0:2,0:2]
[1, 2]
[4, 5]
>>> mc[0:2,0:2]
matrix([[1, 2],
        [4, 5]])
>>> mp[0:2,0:2]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.7/mpmath/matrices/matrices.py", line 412, in __getitem__
    if key in self.__data:
TypeError: unhashable type What is the expected output? What do you see instead? I would have expected a similar response to the prior two commands... a submatrix consisting of the elements [[1,2],[4,5]].  Am I wrong in assuming? What version of the product are you using? On what operating system? mpmath.__version__ = 0.14 & 0.15 (two different machines)
Both operating Ubuntu Linux.

Thanks for any assistance you can give.

~~archery~~

Original issue for #267: http://code.google.com/p/mpmath/issues/detail?id=227
Original author: https://code.google.com/u/archeryguru2000/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions