Status: Valid
Owner: ----
CC: [email protected]
Labels: Type-Defect Priority-Medium Matrices

New issue 3495 by [email protected]: Matrices .args and .shape should contain SymPy types
http://code.google.com/p/sympy/issues/detail?id=3495

Matrices .args and .shape should be tuples whose members are SymPy types. Currently, .args seem to obey this, but there is at least one case where .shape does not:

from sympy import *
A = ImmutableMatrix(2, 2, [0, 1, 1, 0])
AA = MatPow(A, 2)
ImmutableMatrix(AA)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sympy/matrices/immutable.py", line 40, in __new__
    return cls._new(*args, **kwargs)
  File "sympy/matrices/immutable.py", line 33, in _new
    *args, **kwargs)
  File "sympy/matrices/matrices.py", line 137, in _handle_creation_inputs
    return args[0].rows, args[0].cols, args[0].as_explicit()._mat
  File "sympy/matrices/expressions/matexpr.py", line 199, in as_explicit
    for i in range(self.rows)])
  File "sympy/matrices/expressions/matexpr.py", line 168, in __getitem__
    return self._entry(i, j)
  File "sympy/matrices/expressions/matpow.py", line 36, in _entry
    *[self.base for k in range(self.exp)])._entry(i, j)
  File "sympy/matrices/expressions/matmul.py", line 51, in _entry
    if X.shape[1].is_Number:
AttributeError: 'int' object has no attribute 'is_Number'
AA.shape
(2, 2)
map(type, AA.shape)
[<type 'int'>, <type 'int'>]

This came up in the Hadamard PR at https://github.com/sympy/sympy/pull/1608 where the same error occurred in calculating the Hadamard product of two actual matrices with ImmutableMatrix(HadamardProduct(A, B)).

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to