Opened 10 years ago

Last modified 7 years ago

#12289 closed enhancement

pass algorithm argument to custom numeric evalution methods — at Version 8

Reported by: burcin Owned by: burcin
Priority: major Milestone: sage-6.2
Component: symbolics Keywords: pynac sd35.5 sd40.5 sd48
Cc: benjaminfjones, dsm, kcrisman, kini, eviatarbach, vbraun Merged in:
Authors: Burcin Erocal Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by kcrisman)

Custom numeric evaluation functions defined in the _evalf_() method of symbolic functions accept only the parent of the result as an argument. We should expand this to allow passing an argument parameter as well.

See comment:7 for testing instructions.

For merging, apply trac_12289-evalf_dictionary_rebase.patch, trac_12289-add_algorithm_arg.patch, and trac_12289_py_float_fix.patch.

Change History (13)

Changed 10 years ago by burcin

Changed 10 years ago by burcin

Changed 10 years ago by burcin

comment:1 Changed 10 years ago by burcin

  • Cc benjaminfjones added

The evalf_dict branch of Pynac available here, with the attached patches applied to the Sage library, allows this:

sage: cot(1/2).n(algorithm='foo')
sage: cot(1/2).n()

The docstrings for _convert() etc. methods of symbolic expressions need to be updated to reflect these changes.

comment:2 Changed 10 years ago by benjaminfjones

  • Keywords sd35.5 added

I'm doing some testing of these patches along with rebasing #1173. Thanks Burcin!

comment:3 Changed 10 years ago by benjaminfjones

  • Cc dsm added
  • Keywords sd40.5 added

comment:4 Changed 10 years ago by benjaminfjones

I'm trying to rebase the patch trac_12289-evalf_dictionary.patch to sage-5.0, but I'm running into a problem with the type of py_funcs.py_float. In the patch py_float has type object (*)(object, object) but in sage-5.0, it has type object (*)(object, PyObject *) I guess because of a pynac change in the meantime.

To be more specific, with this type def for py_float:

cdef public object py_float(object n, object kwds) except +:

I rebuild sage and get:

Error compiling Cython file:
    py_funcs.py_is_prime = &py_is_prime

    py_funcs.py_integer_from_long = &py_integer_from_long
    py_funcs.py_integer_from_python_obj = &py_integer_from_python_obj
    py_funcs.py_float = &py_float

sage/symbolic/pynac.pyx:2040:24: Cannot assign type 'object (*)(object, object)' to 'object (*)(object, PyObject *)'

Any suggestions (burcin?)

comment:5 Changed 10 years ago by kcrisman

  • Cc kcrisman added

comment:6 Changed 10 years ago by kini

  • Cc kini added

Changed 10 years ago by benjaminfjones

rebase to sage-5.0 + pynac-0.2.4 spkg

Changed 10 years ago by benjaminfjones

fix py_float delcaration

comment:7 Changed 10 years ago by benjaminfjones

I've been working on this ticket today at sd40.5. I've got burcin's changes working in sage-5.0 with a caveat. Here's how to get the example in comment:1 working in sage-5.0:

  1. install the patched pynac-0.2.4.p1 spkg at this spkg is the pynac-0.2.4 spkg from #12950 which has been patched to include the changes from burcin's pynac-wip branch of pynac mentioned above.
  1. apply all patches at #12950, here is a shell script to help that (run from $SAGE_ROOT/devel/sage):
  1. apply the patches to $SAGE_ROOT/devel/sage
  1. sage -b

comment:8 Changed 10 years ago by kcrisman

  • Description modified (diff)

Patchbot, though, should only apply trac_12289-evalf_dictionary_rebase.patch, trac_12289-add_algorithm_arg.patch, and trac_12289_py_float_fix.patch

Note: See TracTickets for help on using tickets.