#17531: allow algorithm keyword when _call_()ing BuiltinFunction
---------------------------+--------------------------------------
Reporter: rws | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.5
Component: symbolics | Keywords: symbolic functions
Merged in: | Authors:
Reviewers: | Report Upstream: N/A
Work issues: | Branch:
Commit: | Dependencies:
Stopgaps: |
---------------------------+--------------------------------------
As per http://trac.sagemath.org/ticket/17489#comment:17 and
http://trac.sagemath.org/ticket/17489#comment:23, the ticket should
improve the `BuiltinFunction` class, such that subclassed function classes
that have an `algorithm=...` keyword given via function call will
automatically have this keyword inserted into any `__evalf__` member
function call.
This means the following should be possible without changes to
`Function.__call__`:
{{{
sage: from sage.symbolic.function import BuiltinFunction
sage: class MyFunction(BuiltinFunction):
def evalf(self, *args, **kwds):
algorithm = kwds.get('algorithm', 'algoA')
if algorithm == 'algoA':
return 1
else:
return 0
....:
sage: f = MyFunction
sage: f(x)
1
sage: f(x, algorithm='algoB')
0
}}}
At the moment, as with all(?) symbolic functions we get
{{{
sage: f(x, algorithm='algoB')
TypeError: __init__() got an unexpected keyword argument 'algorithm'
sage: sin(x, algorithm='algoB')
TypeError: __call__() got an unexpected keyword argument 'algorithm'
}}}
So the ticket should also give a better error message for existing
functions.
--
Ticket URL: <http://trac.sagemath.org/ticket/17531>
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.