Status: Valid
Owner: ----
Labels: Type-Defect Priority-Medium Matrices EasyToFix
New issue 3894 by [email protected]: diag does not work with int
http://code.google.com/p/sympy/issues/detail?id=3894
In [131]: diag(Matrix([[5, 1], [5, 0]]) -2, 3)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-131-8ccfb47c6917> in <module>()
----> 1 diag(Matrix([[5, 1], [5, 0]]) -2, 3)
/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/decorators.pyc
in binary_op_wrapper(self, other)
113 else:
114 return f(self)
--> 115 return func(self, other)
116 return binary_op_wrapper
117 return priority_decorator
/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/matrices/dense.pyc in
__sub__(self, other)
540 @call_highest_priority('__rsub__')
541 def __sub__(self, other):
--> 542 return super(DenseMatrix,
self).__sub__(_force_mutable(other))
543
544 @call_highest_priority('__sub__')
/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/matrices/matrices.pyc
in __sub__(self, a)
407
408 def __sub__(self, a):
--> 409 return self + (-a)
410
411 def __rsub__(self, a):
/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/decorators.pyc
in binary_op_wrapper(self, other)
113 else:
114 return f(self)
--> 115 return func(self, other)
116 return binary_op_wrapper
117 return priority_decorator
/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/matrices/dense.pyc in
__add__(self, other)
532 @call_highest_priority('__radd__')
533 def __add__(self, other):
--> 534 return super(DenseMatrix,
self).__add__(_force_mutable(other))
535
536 @call_highest_priority('__add__')
/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/matrices/matrices.pyc
in __add__(self, other)
519 ret[i] = map(lambda j, k: j + k, alst[i], blst[i])
520 return classof(A, B)._new(ret)
--> 521 raise TypeError('cannot add matrix and %s' % type(other))
522
523 def __radd__(self, other):
TypeError: cannot add matrix and <type 'int'>
In [132]: diag(Matrix([[5, 1], [5, 0]]), S(-2), 3)
Out[132]:
⎡5 1 0 0⎤
⎢ ⎥
⎢5 0 0 0⎥
⎢ ⎥
⎢0 0 -2 0⎥
⎢ ⎥
⎣0 0 0 3⎦
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy-issues.
For more options, visit https://groups.google.com/groups/opt_out.