Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit c8ebd30

Browse files
committed
Merge branch 'u/rws/substitute_function_should_not_evaluate_expression' of trac.sagemath.org:sage into tmp3
* 'u/rws/substitute_function_should_not_evaluate_expression' of trac.sagemath.org:sage: 17849: adapt SubstituteFunction; add doctest
2 parents fa73285 + 82332bb commit c8ebd30

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/sage/symbolic/expression.pyx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4628,6 +4628,17 @@ cdef class Expression(CommutativeRingElement):
46284628
sage: f = foo(x) + 1/foo(pi*y)
46294629
sage: f.substitute_function(foo, bar)
46304630
1/bar(pi*y) + bar(x)
4631+
4632+
TESTS:
4633+
4634+
Make sure :trac:`17849` is fixed::
4635+
4636+
sage: ex = sin(x) + atan2(0,0,hold=True)
4637+
sage: ex.substitute_function(sin,cos)
4638+
arctan2(0, 0) + cos(x)
4639+
sage: ex = sin(x) + hypergeometric([1, 1], [2], -1)
4640+
sage: ex.substitute_function(sin,cos)
4641+
cos(x) + hypergeometric((1, 1), (2,), -1)
46314642
"""
46324643
from sage.symbolic.expression_conversions import SubstituteFunction
46334644
return SubstituteFunction(self, original, new)()

src/sage/symbolic/expression_conversions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,7 @@ def composition(self, ex, operator):
18261826
if operator == self.original:
18271827
return self.new(*map(self, ex.operands()))
18281828
else:
1829-
return operator(*map(self, ex.operands()))
1829+
return super(SubstituteFunction, self).composition(ex, operator)
18301830

18311831
def derivative(self, ex, operator):
18321832
"""

0 commit comments

Comments
 (0)