-
-
Notifications
You must be signed in to change notification settings - Fork 491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor symbolic functions #7490
Comments
comment:2
After applying:
|
refactor symbolic functions |
comment:3
Attachment: trac_7490-refactor_symbolic_functions.patch.gz Hi Jason, This patch does not add a hold method to Cheers, Burcin |
comment:4
I uploaded a new patch with a doctest fix in This also fixes #6523 and #6286. It should provide a basis to #6949, #6961, #6220 and #6465. Note that the patch touches 42 files. I would appreciate it if we can get it in 4.3. Mike, while working on this, I had to tackle many of the problems you must have encountered during the symbolics switch. Can you take a look to see if I forgot anything/messed things up? |
rebased to 4.3.alpha0 |
comment:5
Attachment: trac_7490-refactor_symbolic_functions.rebase-4.3.alpha0.patch.gz I rebased the patch to 4.3.alpha0: attachment: trac_7490-refactor_symbolic_functions.rebase-4.3.alpha0.patch |
comment:6
Thanks Burcin. I'll tried to get it reviewed ASAP and have it the next thing in. |
comment:7
Here's my review. There are a number of things which break old code -- they should be deprecated first.
Conversion of polylog to maxima is broken:
instead of Some doctests are missing:
Why do you have to use
instead of
, which is more natural? In expression.pyx, some things are missing from the _convert docstring. Also, f._convert(int) gives Finally, there are some numerical issues it seems with evaluations: complex(I) gives 0.99999999999999967j instead of 1j. I'm not sure where the discrepancy is occurring. |
Reviewer: Mike Hansen |
revised patch based on 4.3.alpha0 |
comment:8
Attachment: trac_7490-refactor_symbolic_functions.take2.patch.gz Thanks for your comments Mike. Replying to @mwhansen:
Done:
I don't know why I left
Done.
I converted the doctest back to the original form. Return values of
I wrote a little more for the docstring and added a few examples. The fact that GiNaC leaves the
This seems to be an issue with complex embeddings of number field elements:
Of course, I added the last method that gets called for I suggest we open a separate ticket about this since it's independent of the symbolics code and someone who knows the number field code should take a look at it. |
Merged: sage-4.3.alpha1 |
comment:9
Looks good to me. Thanks for making those changes. I've made the number field embedding #7598. |
Attached patch refactors the symbolic function code in
sage/symbolic/function.pyx
.evalf()
now accepts a parent argument instead of a precisionThis allows us to use the numeric evaluation framework in ginac for
evaluating things with
RIF
,CIF
as well, not justRealField
, orComplexField
with the given precision.python arguments passed to custom methods of sfunctions are not
wrapped in
Expression
objects any more. No need to call.pyobject()
to unwrap these.
custom methods support calling methods on
self
.This would be useful if you need access to other function of the
defining class, or store tables of data calculated on demand.
__call__
method supports hold parameterThis works:
Custom methods for symbolic functions (
_eval_
,_evalf_
,_conjugate_
,_derivative_
, etc.) can bewritten in Cython for builtin functions (that are provided by the
Sage library)
New class hiearchy:
We have 4 different types of functions, those defined by
SymbolicFunction)
Things we need to do for these functions different for each of these,
perhaps similar for the last two. Normally initializing a function
means checking if it's already defined, if not, initializing a
structure from ginac called function_options, and registering this in
a table. There are also issues with pickling.
For ginac functions, we don't need any of this, since we can't change
it at python level. We only need to look up the serial number (the
indicator in the table) of the function. We don't need to do anything
to pickle or unpickle these either.
Pickling and unpickling library functions only needs an identifier
for the class to initialize it again if necessary.
User defined functions need to lookup if there is an existing
function in the table, since we should try to keep the table small.
There is also a new
function_factory()
function insage.symbolic.function_factory
(it needs to be in a python file) that creates
NewSymbolicFunction
classes on the fly for the function() calls from the command line.
The pynac package here is required for this patch:
http://sage.math.washington.edu/home/burcin/pynac/pynac-0.1.10.a0.spkg
CC: @mwhansen @jasongrout
Component: symbolics
Keywords: pynac
Author: Burcin Erocal
Reviewer: Mike Hansen
Merged: sage-4.3.alpha1
Issue created by migration from https://trac.sagemath.org/ticket/7490
The text was updated successfully, but these errors were encountered: