Status: Accepted
Owner: asmeurer
Labels: Type-Defect Priority-Medium
New issue 2368 by asmeurer: AttributeError: 'Tuple' object has no
attribute 'as_coeff_add' with .replace(Wild expression, Wild expression)
http://code.google.com/p/sympy/issues/detail?id=2368
In [29]: a = Integral(f(x), x)/2 + g(x) + C
In [30]: w = Wild('w')
In [31]: t = Wild('t', exclude=[x])
In [32]: a.replace(w + t, w + 2*t)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/Users/aaronmeurer/Documents/python/sympy/sympy/<ipython console> in
<module>()
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/core/basic.py in
replace(self, query, value, map)
1075 return None
1076
-> 1077 result = rec_replace(self)
1078
1079 if result is None:
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/core/basic.py in
rec_replace(expr)
1049
1050 for arg in expr.args:
-> 1051 result = rec_replace(arg)
1052
1053 if result is not None:
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/core/basic.py in
rec_replace(expr)
1049
1050 for arg in expr.args:
-> 1051 result = rec_replace(arg)
1052
1053 if result is not None:
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/core/basic.py in
rec_replace(expr)
1049
1050 for arg in expr.args:
-> 1051 result = rec_replace(arg)
1052
1053 if result is not None:
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/core/basic.py in
rec_replace(expr)
1061 expr = expr.__class__(*args)
1062
-> 1063 result = _query(expr)
1064
1065 if result:
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/core/basic.py in
<lambda>(expr)
1025 raise TypeError("given a type, replace() expects
another type or a callable")
1026 elif isinstance(query, Basic):
-> 1027 _query = lambda expr: expr.match(query)
1028
1029 if isinstance(value, Basic):
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/core/basic.py in
match(self, pattern)
1187 """
1188 pattern = sympify(pattern)
-> 1189 return pattern.matches(self)
1190
1191 def count_ops(self, visual=None):
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/core/operations.py in
_matches_commutative(self, expr, repl_dict, evaluate)
245 d1 = w.matches(last_op, repl_dict)
246 if d1 is not None:
--> 247 d2 = self.subs(d1.items()).matches(expr, d1)
248 if d2 is not None:
249 return d2
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/core/operations.py in
_matches_commutative(self, expr, repl_dict, evaluate)
216 return repl_dict
217
--> 218 d = self._matches_simple(expr, repl_dict)
219 if d is not None:
220 return d
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/core/add.py in
_matches_simple(self, expr, repl_dict)
222 def _matches_simple(self, expr, repl_dict):
223 # handle (w+3).matches('x+5') -> {w: x+2}
--> 224 coeff, terms = self.as_coeff_add()
225 if len(terms)==1:
226 return terms[0].matches(expr - coeff, repl_dict)
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/core/cache.py in
wrapper(*args, **kw_args)
99 except KeyError:
100 pass
--> 101 func_cache_it_cache[k] = r = func(*args, **kw_args)
102 return r
103
/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/core/add.py in
as_coeff_add(self, *deps)
201 l1.append(f)
202 return self._new_rawargs(*l1), tuple(l2)
--> 203 coeff, notrat = self.args[0].as_coeff_add()
204 if not coeff is S.Zero:
205 return coeff, notrat + self.args[1:]
AttributeError: 'Tuple' object has no attribute 'as_coeff_add'
--
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.