This repository was archived by the owner on Jan 30, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -4872,6 +4872,8 @@ cdef class Expression(CommutativeRingElement):
48724872 43/42
48734873 sage: ((1+x)/x).subs({x: 42})
48744874 43/42
4875+ sage: (x+1/x+1).subs(1/x==pi)
4876+ pi + x + 1
48754877 """
48764878 from sage.symbolic.ring import SR
48774879 cdef dict sdict = {}
@@ -4892,11 +4894,17 @@ cdef class Expression(CommutativeRingElement):
48924894 # Check for duplicate
48934895 _dict_update_check_duplicate(sdict, varkwds)
48944896
4897+ def is_fraction (e ):
4898+ return ((e.operator() == operator.pow and e.operands()[1 ]< 0 ) or
4899+ (e.operator() == operator.mul and
4900+ any (t.operator()== operator.pow and t.operands()[1 ]< 0
4901+ for t in e.operands())))
4902+
48954903 cdef GExMap smap, invmap
48964904 for k, v in sdict.iteritems():
48974905 smap.insert(make_pair((< Expression> self .coerce_in(k))._gobj,
48984906 (< Expression> self .coerce_in(v))._gobj))
4899- if not SR(v).is_trivial_zero():
4907+ if not SR(v).is_trivial_zero() and not is_fraction(SR(k)) :
49004908 invmap.insert(make_pair((< Expression> self .coerce_in(1 / k))._gobj,
49014909 (< Expression> self .coerce_in(1 / v))._gobj))
49024910
You can’t perform that action at this time.
0 commit comments