Skip to content

Commit

Permalink
Trac #20312: parent of argument lost with Functions
Browse files Browse the repository at this point in the history
Some Python objects as function arguments lose their parent, i.e. the
code in the specific function can no longer access it because the object
was coerced into SR. This can result in violation of the rule that
function input and output should be of the same type.
{{{
sage: S.<y> = PolynomialRing(RR)
sage: ex = sin(asin(y)); ex
y
sage: type(ex)
<type 'sage.symbolic.expression.Expression'>
sage: ex.is_symbol()
True
}}}
The specific function (here sin) code cannot remedy this because there
the damage is already done. The problem is in
`symbolic/function.pyx:BuiltinFunction.__call__` where the parent of
function arguments is lost.

See also #18832 and maybe #17790.

URL: http://trac.sagemath.org/20312
Reported by: rws
Ticket author(s): Ralf Stephan
Reviewer(s): Volker Braun
  • Loading branch information
Release Manager authored and vbraun committed May 6, 2016
2 parents fddbe1f + 58f3d00 commit 67e4937
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/sage/symbolic/function.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ cdef class BuiltinFunction(Function):
if (isinstance(arg_parent, PolynomialRing_commutative)
or isinstance(arg_parent, MPolynomialRing_polydict_domain)):
try:
return res.polynomial(ring=arg_parent)
return SR(res).polynomial(ring=arg_parent)
except TypeError:
return res
else:
Expand Down

0 comments on commit 67e4937

Please sign in to comment.