I don't know what changed, but this issue is now causing a lot of my code in pydy to not be able to use .subs() on a bunch of expressions.
http://code.google.com/p/sympy/issues/detail?id=1616 I did a git blame and it looks like it was done by Bill Flynn on 2009-08-22. I think this was during the sprint on Saturday at the Scipy conference. Can Bill or Ondrej look into this when you get a chance? It looks like sympy/core/mul.py:811 is the culprit, it looks like your logic in the for loop might not be checking things correctly before trying to removing elements from the list. This is a show stopper for PyDy. I'll be on IRC all day tomorrow and can help debug the problem so we can resolve it ASAP. Here is a test case that causes the error: In [1]: a, b, c, d, e, f, g, h, i, j, k, l = symbols('a b c d e f g h i j k l') In [2]: test = a*b*c**2 + d*b*e**2*f**2 + c*h*i*e**2 In [3]: test.subs({e**2:1-g**2, c**2:1-g**2}) 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', (22, 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', (96, 0)) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /home/luke/lib/python/pydy/examples/<ipython console> in <module>() /home/luke/lib/python/sympy/sympy/core/basic.pyc in subs(self, *args) 1021 sequence = args[0] 1022 if isinstance(sequence, dict): -> 1023 return self._subs_dict(sequence) 1024 elif isinstance(sequence, (list, tuple)): 1025 return self._subs_list(sequence) /home/luke/lib/python/sympy/sympy/core/basic.pyc in _subs_dict(self, sequence) 1111 subst.append(pattern) 1112 subst.reverse() -> 1113 return self._subs_list(subst) 1114 1115 def _seq_subs(self, old, new): /home/luke/lib/python/sympy/sympy/core/basic.pyc in _subs_list(self, sequence) 1064 for old, new in sequence: 1065 if hasattr(result, 'subs'): -> 1066 result = result.subs(old, new) 1067 return result 1068 /home/luke/lib/python/sympy/sympy/core/basic.pyc in subs(self, *args) 1028 elif len(args) == 2: 1029 old, new = args -> 1030 return self._subs_old_new(old, new) 1031 else: 1032 raise TypeError("subs accepts either 1 or 2 arguments") /home/luke/lib/python/sympy/sympy/core/cache.pyc in wrapper(*args, **kw_args) 83 except KeyError: 84 pass ---> 85 func_cache_it_cache[k] = r = func(*args, **kw_args) 86 return r 87 /home/luke/lib/python/sympy/sympy/core/basic.pyc in _subs_old_new(self, old, new) 1037 old = sympify(old) 1038 new = sympify(new) -> 1039 return self._eval_subs(old, new) 1040 1041 def _eval_subs(self, old, new): /home/luke/lib/python/sympy/sympy/core/add.pyc in _eval_subs(self, old, new) 310 ret_set = self_set - old_set 311 return Add(new, coeff_self, -coeff_old, *[s._eval_subs(old, new) for s in ret_set]) --> 312 return self.__class__(*[s._eval_subs(old, new) for s in self.args]) 313 314 @cacheit /home/luke/lib/python/sympy/sympy/core/mul.pyc in _eval_subs(self, old, new) 809 # collect commutative terms 810 else: --> 811 comms_final.remove(ele) 812 813 # continue only if all commutative terms in old are present ValueError: list.remove(x): x not in list In [4]: --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---