Skip to content
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

autowrap and ufuncify "helpers" arguments are inconsistent and poorly documented #10572

Open
ronanpaixao opened this issue Feb 12, 2016 · 4 comments
Labels
Documentation Easy to Fix This is a good issue for new contributors. Feel free to work on this if no one else has already. utilities.autowrap

Comments

@ronanpaixao
Copy link

utilities.autowrap.ufuncify() doesn't explain properly how the helpers argument should be used. The best documentation, of course, is an example. Maybe one can include this in the docstring (it can also work as a test if using doctest):

from sympy.utilities import autowrap
from sympy.abc import x, t
expr = 3*x+f(t)
func_ufunc = autowrap.ufuncify([x, t], expr, helpers=[['f', 4*x, [x]]])
func_ufunc(1, 0.125)
#3.5

It took a long time for me to find the proper "format" for the helpers, which really is like iterable_of(3-tuple(str, SymPy expression, list)).

utilities.autowrap.autowrap(), however, expects only a single helper function!

autowrap.autowrap(expr, args=[x, t], helpers=[['f', 4*x, [x]]])
Traceback (most recent call last):

  File "<ipython-input-105-729cbaf02a5a>", line 1, in <module>
    autowrap.autowrap(expr, args=[x, t], helpers=[['f', 4*x, [x]]])

  File "D:\Anaconda\lib\site-packages\sympy\utilities\autowrap.py", line 510, in autowrap
    for name_h, expr_h, args_h in helpers:

ValueError: need more than 1 value to unpack
func_autow = autowrap.autowrap(expr, args=[x, t], helpers=['f', 4*x, [x]])
func_autow(1, 0.1)
#3.4
@ronanpaixao
Copy link
Author

An important note: since autowrap doesn't allow for more helpers and the C/Cython backend doesn't support (out-of-the-box) some builtin function like sympy.Max, this pretty much blocks using C/Cython for expressions with more than one function, any function.

@moorepants
Copy link
Member

We recently fixed this #8889 and added an extensive addition with code gen examples. I think the helpers is now in the master branch. It will be released with the 1.0 release that will happen soon.

@moorepants
Copy link
Member

This was also recently merged: #10282

@moorepants
Copy link
Member

@ronanpaixao Would you mind submitting a pull request with your docstring additions?

@moorepants moorepants added utilities.autowrap Documentation Easy to Fix This is a good issue for new contributors. Feel free to work on this if no one else has already. labels Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Easy to Fix This is a good issue for new contributors. Feel free to work on this if no one else has already. utilities.autowrap
Projects
None yet
Development

No branches or pull requests

2 participants