#14801: Piecewise functions done right
-------------------------------------+-------------------------------------
Reporter: vbraun | Owner: burcin
Type: defect | Status: new
Priority: major | Milestone: sage-6.2
Component: symbolics | Resolution:
Keywords: | Merged in:
Authors: Volker Braun | Reviewers:
Report Upstream: N/A | Work issues:
Branch: public/piecewise | Commit:
Dependencies: #14800, #14780, | 6d00b38418552984fa951bf9c4090da001a1ec9f
#9556, #13125 | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by rws):
Many doctests fail in the new code. For example:
{{{
sage: f = piecewise([((0,1), x^3), ([-1,0], -x^2)]); f
piecewise(x|-->x^3 on (0, 1), x|-->-x^2 on [-1, 0]; x)
sage: f(x=1/2)
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)
<ipython-input-2-6d710eda1bb0> in <module>()
----> 1 f(x=Integer(1)/Integer(2))
TypeError: new_f() got an unexpected keyword argument 'x'
}}}
I am not well versed in Python. I think there is maybe a problem in
`symbolic/function_factory.pyx:eval_on_operands()` (dynamic methods for
symbolic expressions, added with #9556) which is uncovered with this
ticket.
{{{
def eval_on_operands(f):
@sage_wraps(f)
def new_f(ex):
return f(*ex.operands())
return new_f
}}}
Apparently `f` gets some `new_f` on creation and tries to call it with a
named parameter but python barfs because the parameter wasn't expected in
`new_f`. Moreover, even without name `f(1/2)` barfs because the number of
arguments to `new_f` doesn't fit anymore. So only `f()` will call `new_f`
succesfully but that's useless.
--
Ticket URL: <http://trac.sagemath.org/ticket/14801#comment:7>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.