-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
NumPy vectorized function can not be dilled after using them #487
Comments
Caused by this: #443 (comment) Removing said lines from dill will fix the issue. I need to find an upper bound on the numpy version that didn't support ufunc pickling, but this is an easy issue to fix. The lower bound of the search is at numpy 1.15.0 because that is the oldest version of numpy that will work with the latest version of dill. |
Interesting, thanks for the super quick reply 🙏 I've tried your suggestion locally with a clean virtual environment, I'm not sure if that helps, but I've also tried |
As far as I can tell, dill has legacy support for pickling numpy arrays because once upon a time, numpy didn't support pickling. Modern numpy versions picked up the feature on their end, so dill doesn't need to support it anymore. Since this doesn't work when you change dill to pickle and produces the same message, I would file the issue under numpy/numpy. Correct me if I am wrong @mmckerns. |
In terms of the history, basically, yes. |
I understand that this issue is not really about dill, but since it's still open I'd like to share what I've found till now.
def f(x):
return x
uf = np.frompyfunc(f,1,1)
dill.detect.baditems(uf)
[<ufunc 'f (vectorized)'>]
|
@arielshulman: thanks for looking into this a bit more, and for the lead on the PR in |
I had encounter with a strange behavior when I used scikit-learn pipelines with
np.vectorize
function and pickle it using dill.I've managed to narrow the situation to this -
When I try to pickle a simple function that have been vectorized with non-regular
otype
suchobject
orstr
, if it occurs before running it, dill works fine but if I've used it once, the dill yells withPicklingError
.For example -
and the output is -
This test ran on Windows, but I've tested it on Linux as well and the same problem occurs.
Packages versions used for the test -
numpy==1.22.4
anddill==0.3.5.1
and also withdill==0.3.4
The text was updated successfully, but these errors were encountered: