-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
TST, MAINT: Update pickling tests by making them loop over all protocols #12090
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
TST, MAINT: Update pickling tests by making them loop over all protocols #12090
Conversation
numpy/core/_add_newdocs.py
Outdated
| None | ||
| protocol : int, optional | ||
| The pickle protocol used to serialize the array. | ||
| The default is 2 (in order to maintain python 2 support). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably need to use the .. versionadded:: 1.16.0 directive:
protocol : int, optional
The pickle protocol used to serialize the array.
The default is 2 (in order to maintain python 2 support).
.. versionadded:: 1.16.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
numpy/core/_add_newdocs.py
Outdated
| A string naming the dump file. | ||
| protocol : int, optional | ||
| The pickle protocol used to serialize the array. | ||
| The default is 2 (in order to maintain python 2 support). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
versionadded
|
In my opinion we should deprecate these methods - we already did for np.loads and np.ma.dumps. |
|
Indeed I find them redundant too. We would need to rewrite the test to use |
|
Should I remove these arguments? Or do we still want to keep the functionality? I will update the tests anyway then. |
|
No need to add arguments to deprecated methods IMHO. |
|
@eric-wieser do you want this PR to officially deprecate If former is chosen: according to doc/neps/nep-0023-backwards-compatibility.rst, the dump and dumps function should have their docstring updated and issue a There should be a test that checks that the warning is raised but that the methods still work (return the same results as Finally the changelog should also be updated to mention the deprecation. |
No, if that happens it should be a separate PR.
The change logs are generated by a script, but the release notes should have an entry. |
|
I note that the code in pickle5 has declarations after statements, which is C99. |
|
Thanks @pierreglaser . |
All imports of pickle from numpy modules are now done this way: >>> from numpy.core.numeric import pickle Also, some loops on protocol numbers are added over pickle tests that were not caught from numpy#12090
np.ndarray.dumpsandnp.ndarray.dumpwill now let the user specify a pickle protocol.pickling tests now loop over all possible protocols.
Part of #12011, that implements pickle protocol 5 for numpy arrays (this PR is currently being broken out in multiple shorter PRs for simplification and clarity purposes).
pinging @ogrisel @mattip