-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
With NumPy 1.20, SymPy generated code cannot be serialized with dill #405
Comments
If you haven't cross-posted to |
Thanks, @mmckerns. I believe |
Indeed. I didn't see that. Posting the trace may be insightful, however. |
Thanks. WIth
|
This says that it first pickles the function |
Thanks. You might be interested in the discussion in the NumPy repository. Thanks for helping. |
Is the fact that the lambdified function is dynamically generated somehow tricking dill into doing the wrong thing for the |
@asmeurer: I'll dedicate a little bit of time this week to investigate it, and see if I can come up with a solution. |
I can confirm I can reproduce the error. @asmeurer: I seem to remember a previous issue with serializing a |
Confirming this is still an issue with:
Also, posting traceback with
This case may be fixed by: #477 |
I think that the the recurse issue is related to #466. The function >>> dill.detect.globalvars(lfunc)
dill.detect.globalvars <function _lambdifygenerated at 0x10ef8a050>
dill.detect.globalvars <function real at 0x10ebbc940>
dill.detect.globalvars <function _real_dispatcher at 0x10ebbc670>
dill.detect.globalvars <function real at 0x10ebbc8b0>
dill.detect.globalvars <built-in function asanyarray>
dill.detect.globalvars None
dill.detect.globalvars <function real at 0x10ebbc940>
dill.detect.globalvars <function _real_dispatcher at 0x10ebbc670>
dill.detect.globalvars <function real at 0x10ebbc8b0>
dill.detect.globalvars <built-in function asanyarray>
dill.detect.globalvars None |
Yeah... I'm not sure if it's due to the issue you quoted, but definitely |
It turns out the |
The issue still exists, and it might have to do with The code below works fine: import numpy as np
import dill
dill.settings['recurse'] = False
def foo(a):
return np.real(a) / np.real(a)
dill.detect.globalvars(foo) But importing from numpy import real
def bar(a):
return real(a) / real(a)
dill.detect.globalvars(bar) # maximum recursion depth reached Although import andes
import dill
dill.settings['recurse'] = True
from multiprocess import Pool
# `andes.system.example()` returns a new object every time
one_system = [andes.system.example()]
systems = [andes.system.example(), andes.system.example()]
first_system = [systems[0]]
def ex_runner(system):
return system
pass
ret = pool.map(ex_runner, systems) # fails: recursion issue
ret = pool.map(ex_runner, first_system) # fails: recursion issue
ret = pool.map(ex_runner, one_system) # works, but like `first_system`, `one_system` is a single-item list
dill.detect.globalvars(one_system[0].Fault.calls.s["gf"]) # fails due to recursion I followed the discussions above and tried |
@cuihantao: Your issue appears to be different than this issue. Please open a new issue and re-post.
|
This issue has been posted to the NumPy repository. Since it's related to dill, I'm reposting it here. The post to NumPy is at numpy/numpy#18547
I have been using SymPy to generate NumPy code through
lambdify
and using dill to serialize the code. Since upgraded to NumPy 1.20.1, some generated code cannot be serialized correctly due to a RecursionError. The example code works with NumPy 1.19.I have posted this issue in the SymPy and NumPy Gitter rooms, and I'm posting my bisecting results here.
Reproducing code example:
Prerequisites: SymPy 1.7.1, dill 0.3.3, NumPy 1.20.1
Based on my nonexhausive testings, the error occurs when the function includes
re
orim
. Other functions can be successfully serialized..Error message:
NumPy/Python version information:
1.20.1 3.8.8 | packaged by conda-forge | (default, Feb 20 2021, 16:12:38)
[Clang 11.0.1 ]
The text was updated successfully, but these errors were encountered: