Opened 8 years ago

Closed 7 years ago

#17849 closed defect (fixed)

substitute_function should not evaluate expression

Reported by: Ralf Stephan Owned by:
Priority: major Milestone: sage-6.8
Component: symbolics Keywords:
Cc: Merged in:
Authors: Ralf Stephan Reviewers: Marc Mezzarobba
Report Upstream: N/A Work issues:
Branch: c8ebd30 (Commits, GitHub, GitLab) Commit: c8ebd3056e2800dc9c760d94fd2d6b088ee541ab
Dependencies: #17759 Stopgaps:

Status badges

Description

One expects substitute_function to not do anything except exchanging parts of expressions but

sage: ex = sin(x) + atan2(0,0,hold=True) 
sage: ex.substitute_function(sin,cos)
...
RuntimeError: arctan2_eval(): arctan2(0,0) encountered
sage: ex = sin(x) + hypergeometric([1, 1], [2], -1)
sage: ex
hypergeometric((1, 1), (2,), -1) + sin(x)
sage: ex.substitute_function(sin,cos)              
AttributeError: 'SubstituteFunction' object has no attribute 'tuple'

Change History (10)

comment:1 Changed 8 years ago by Ralf Stephan

Dependencies: #17759

comment:2 Changed 8 years ago by Ralf Stephan

Calling operator(*map(self, ex.operands()), hold=True) as a quick fix in SubstituteFunction.composition presupposes that all operators accept the keyword.

comment:3 Changed 8 years ago by Ralf Stephan

Branch: u/rws/substitute_function_should_not_evaluate_expression

comment:4 Changed 8 years ago by Ralf Stephan

Authors: Ralf Stephan
Commit: 82332bb5eb54696d076b78bf62f21257a872ffad
Status: newneeds_review

New commits:

3781eec17759: convenience class symbolic ExpressionTreeWalker(Converter)
9375510Merge branch 'develop' into t/17759/public/17759
16aa81d17759: handle hold=True and hypergeometric
d8767cdMerge branch 'public/17759' of trac.sagemath.org:sage into t/17849/substitute_function_should_not_evaluate_expression
82332bb17849: adapt SubstituteFunction; add doctest

comment:5 Changed 7 years ago by Ralf Stephan

Branch: u/rws/substitute_function_should_not_evaluate_expressionu/rws/17849

comment:6 Changed 7 years ago by Ralf Stephan

Branch: u/rws/17849u/rws/substitute_function_should_not_evaluate_expression
Milestone: sage-6.6sage-6.8

comment:7 Changed 7 years ago by Ralf Stephan

Branch: u/rws/substitute_function_should_not_evaluate_expressionu/rws/17849
Commit: 82332bb5eb54696d076b78bf62f21257a872ffadc8ebd3056e2800dc9c760d94fd2d6b088ee541ab

New commits:

fa7328517759: convenience class symbolic ExpressionTreeWalker(Converter)
c8ebd30Merge branch 'u/rws/substitute_function_should_not_evaluate_expression' of trac.sagemath.org:sage into tmp3

comment:8 Changed 7 years ago by Marc Mezzarobba

Reviewers: Marc Mezzarobba
Status: needs_reviewpositive_review

comment:9 Changed 7 years ago by Ralf Stephan

Thanks.

comment:10 Changed 7 years ago by Volker Braun

Branch: u/rws/17849c8ebd3056e2800dc9c760d94fd2d6b088ee541ab
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.