@@ -5489,6 +5489,12 @@ cdef class Expression(CommutativeRingElement):
54895489 sage: f = function("f")
54905490 sage: integrate(f(x), x, 0, a).subs(a=cos(a))
54915491 integrate(f(x), x, 0, cos(a))
5492+
5493+ Check that :trac:`31530` is fixed::
5494+
5495+ sage: a, b = var("a b")
5496+ sage: (a + b*x).series(x, 2).subs(a=a, b=b)
5497+ (a) + (b)*x + Order(x^2)
54925498 """
54935499 cdef dict sdict = {}
54945500 cdef GEx res
@@ -5509,28 +5515,6 @@ cdef class Expression(CommutativeRingElement):
55095515 # Check for duplicate
55105516 _dict_update_check_duplicate(sdict, varkwds)
55115517
5512- # To work around the pynac bug in :trac:`30378`, we use two steps to do a
5513- # substitution that only involves plugging expressions into variables, but
5514- # where some of the expressions include variables that are in self.
5515- if all (self .parent(k).is_symbol() for k in sdict.keys()):
5516- dict_vars = tuple (v for k in sdict.keys()
5517- for v in self .parent(sdict[k]).variables())
5518- if not set (self .variables()).isdisjoint(dict_vars):
5519- # Step 1: replace each variable with a new temporary variable
5520- temp_vars = {v : self .parent().symbol() for v in self .variables()}
5521- with hold:
5522- first_step = self .substitute(temp_vars)
5523- # Step 2: make the original substitutions into the new variables
5524- result = first_step.substitute({
5525- temp_vars[v] :
5526- sdict[v] if v in sdict.keys() else v
5527- for v in self .variables()})
5528- if not set (result.variables()).issubset(self .variables() + dict_vars):
5529- raise RuntimeError (" substitution failed" )
5530- return result
5531-
5532- # We are not in the basic case of only substituting expressions into
5533- # variables, so we ask Ginac to do the work.
55345518 cdef GExMap smap
55355519 for k, v in sdict.iteritems():
55365520 smap.insert(make_pair((< Expression> self .coerce_in(k))._gobj,
0 commit comments