Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 3150 by [email protected]: Problems with MatrixSymbol and simplifying functions
http://code.google.com/p/sympy/issues/detail?id=3150

MatrixSymbol do not work with cancel, combsimp, factor, posify, separatevars, sqrtdenest.

$ ipython
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
Type "copyright", "credits" or "license" for more information.

IPython 0.10.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: from sympy import *

In [2]: A=MatrixSymbol('A', 3, 3)

In [3]: B=MatrixSymbol('B', 3, 3)

In [4]: p=A*B-B*A

In [5]: cancel(p)
---------------------------------------------------------------------------
PolynomialError                           Traceback (most recent call last)

/home/jrioux/git/sympy/<ipython console> in <module>()

/home/jrioux/git/sympy/sympy/polys/polytools.pyc in cancel(f, *gens, **args)
   5491
   5492     try:
-> 5493         (F, G), opt = parallel_poly_from_expr((p, q), *gens, **args)
   5494     except PolificationFailed:
   5495         if not isinstance(f, (tuple, Tuple)):

/home/jrioux/git/sympy/sympy/polys/polytools.pyc in parallel_poly_from_expr(exprs, *gens, **args)
   3787     """Construct polynomials from expressions. """
   3788     opt = options.build_options(gens, args)
-> 3789     return _parallel_poly_from_expr(exprs, opt)
   3790
   3791 def _parallel_poly_from_expr(exprs, opt):

/home/jrioux/git/sympy/sympy/polys/polytools.pyc in _parallel_poly_from_expr(exprs, opt)
   3838
   3839     try:
-> 3840         reps, opt = _parallel_dict_from_expr(exprs, opt)
   3841     except GeneratorsNeeded:
   3842         raise PolificationFailed(opt, origs, exprs, True)

/home/jrioux/git/sympy/sympy/polys/polyutils.pyc in _parallel_dict_from_expr(exprs, opt)
    277
    278     if any(expr.is_commutative is False for expr in exprs):
--> 279 raise PolynomialError('non-commutative expressions are not supported')
    280
    281     if opt.gens:

PolynomialError: non-commutative expressions are not supported

In [6]: combsimp(p)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/jrioux/git/sympy/<ipython console> in <module>()

/home/jrioux/git/sympy/sympy/simplify/simplify.pyc in combsimp(expr)
   2305
   2306     expr = expr.replace(binomial,
-> 2307 lambda n, k: rf((n-k+1).expand(), k.expand())/rf(1, k.expand()))
   2308     expr = expr.replace(factorial,
   2309         lambda n: rf(1, n.expand()))

/home/jrioux/git/sympy/sympy/core/basic.pyc in replace(self, query, value, map)
   1118                     return None
   1119
-> 1120         result = rec_replace(self)
   1121
   1122         if result is None:

/home/jrioux/git/sympy/sympy/core/basic.pyc in rec_replace(expr)
   1094
   1095             for arg in expr.args:
-> 1096                 result = rec_replace(arg)
   1097
   1098                 if result is not None:

/home/jrioux/git/sympy/sympy/core/basic.pyc in rec_replace(expr)
   1094
   1095             for arg in expr.args:
-> 1096                 result = rec_replace(arg)
   1097
   1098                 if result is not None:

/home/jrioux/git/sympy/sympy/core/basic.pyc in rec_replace(expr)
   1094
   1095             for arg in expr.args:
-> 1096                 result = rec_replace(arg)
   1097
   1098                 if result is not None:

/home/jrioux/git/sympy/sympy/core/basic.pyc in rec_replace(expr)
   1093             args, construct = [], False
   1094
-> 1095             for arg in expr.args:
   1096                 result = rec_replace(arg)
   1097

AttributeError: 'str' object has no attribute 'args'

In [7]: factor(p)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/jrioux/git/sympy/<ipython console> in <module>()

/home/jrioux/git/sympy/sympy/polys/polytools.pyc in factor(f, *gens, **args)
   5254         if not f.is_commutative:
   5255             from sympy.core.exprtools import factor_nc
-> 5256             return factor_nc(f)
   5257         else:
   5258             raise PolynomialError(msg)

/home/jrioux/git/sympy/sympy/core/exprtools.pyc in factor_nc(expr)
    603         return expr.func(*[factor_nc(a) for a in expr.args])
    604
--> 605     expr, rep, nc_symbols = _mask_nc(expr)
    606     if rep:
    607         return factor(expr).subs(rep)

/home/jrioux/git/sympy/sympy/core/exprtools.pyc in _mask_nc(eq)
    569                 pass
    570             elif (
--> 571                 not a.is_commutative and
572 not (a.is_Symbol or a.is_Add or a.is_Mul or a.is_Pow)
    573                 ):

AttributeError: 'str' object has no attribute 'is_commutative'

In [8]: posify(p)
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (10, 0))

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (10, 0))

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/jrioux/git/sympy/<ipython console> in <module>()

/home/jrioux/git/sympy/sympy/simplify/simplify.pyc in posify(eq)
   1341         for i, e in enumerate(eq):
   1342             eq[i] = e.subs(reps)
-> 1343         return f(eq), dict([(r, s) for s, r in reps.iteritems()])
   1344
   1345     reps = dict([(s, Dummy(s.name, positive=True))

/home/jrioux/git/sympy/sympy/matrices/expressions/matadd.pyc in __new__(cls, *args)
     21         args = [arg for arg in args if arg!=0]
     22
---> 23         if not all(arg.is_Matrix for arg in args):
     24             raise ValueError("Mix of Matrix and Scalar symbols")
     25

/home/jrioux/git/sympy/sympy/matrices/expressions/matadd.pyc in <genexpr>((arg,))
     21         args = [arg for arg in args if arg!=0]
     22
---> 23         if not all(arg.is_Matrix for arg in args):
     24             raise ValueError("Mix of Matrix and Scalar symbols")
     25

AttributeError: 'list' object has no attribute 'is_Matrix'

In [9]: separatevars(p)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/jrioux/git/sympy/<ipython console> in <module>()

/home/jrioux/git/sympy/sympy/simplify/simplify.pyc in separatevars(expr, symbols, dict, force) 648 return _separatevars_dict(_separatevars(expr, force), symbols)
    649     else:
--> 650         return _separatevars(expr, force)
    651
    652 def _separatevars(expr, force):

/home/jrioux/git/sympy/sympy/simplify/simplify.pyc in _separatevars(expr, force)
    698         _expr = nonsepar
    699         _expr, reps = posify(_expr) if force else (_expr, {})
--> 700         _expr = (factor(_expr)).subs(reps)
    701
    702         if not _expr.is_Add:

/home/jrioux/git/sympy/sympy/polys/polytools.pyc in factor(f, *gens, **args)
   5254         if not f.is_commutative:
   5255             from sympy.core.exprtools import factor_nc
-> 5256             return factor_nc(f)
   5257         else:
   5258             raise PolynomialError(msg)

/home/jrioux/git/sympy/sympy/core/exprtools.pyc in factor_nc(expr)
    603         return expr.func(*[factor_nc(a) for a in expr.args])
    604
--> 605     expr, rep, nc_symbols = _mask_nc(expr)
    606     if rep:
    607         return factor(expr).subs(rep)

/home/jrioux/git/sympy/sympy/core/exprtools.pyc in _mask_nc(eq)
    569                 pass
    570             elif (
--> 571                 not a.is_commutative and
572 not (a.is_Symbol or a.is_Add or a.is_Mul or a.is_Pow)
    573                 ):

AttributeError: 'str' object has no attribute 'is_commutative'

In [10]: sqrtdenest(p)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/jrioux/git/sympy/<ipython console> in <module>()

/home/jrioux/git/sympy/sympy/simplify/sqrtdenest.pyc in sqrtdenest(expr, max_iter)
    128     expr = expand_mul(sympify(expr))
    129     for i in range(max_iter):
--> 130         z = _sqrtdenest0(expr)
    131         if expr == z:
    132             return expr

/home/jrioux/git/sympy/sympy/simplify/sqrtdenest.pyc in _sqrtdenest0(expr)
    208         args = expr.args
    209         if args:
--> 210             return expr.func(*[_sqrtdenest0(a) for a in args])
    211     return expr
    212

/home/jrioux/git/sympy/sympy/simplify/sqrtdenest.pyc in _sqrtdenest0(expr)
    208         args = expr.args
    209         if args:
--> 210             return expr.func(*[_sqrtdenest0(a) for a in args])
    211     return expr
    212

/home/jrioux/git/sympy/sympy/simplify/sqrtdenest.pyc in _sqrtdenest0(expr)
    208         args = expr.args
    209         if args:
--> 210             return expr.func(*[_sqrtdenest0(a) for a in args])
    211     return expr
    212

/home/jrioux/git/sympy/sympy/simplify/sqrtdenest.pyc in _sqrtdenest0(expr)
    190     """Returns expr after denesting its arguments."""
    191
--> 192     if is_sqrt(expr):
    193         n, d = expr.as_numer_denom()
    194         if d is S.One: # n is a square root

/home/jrioux/git/sympy/sympy/simplify/sqrtdenest.pyc in is_sqrt(expr)
     13     """Return True if expr is a sqrt, otherwise False."""
     14
---> 15 return expr.is_Pow and expr.exp.is_Rational and abs(expr.exp) is S.Half
     16
     17

AttributeError: 'str' object has no attribute 'is_Pow'

In [11]: import sympy

In [12]: sympy.__version__
Out[12]: '0.7.1-git'


--
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