Hello,
The method joblib.numpy_pickle.NumpyArrayWrapper.write_array is using chunk.tostring, which is deprecated and should be replaced by chunk.tobytes:
File "_my_scrambled_path_/python3.7/site-packages/joblib/numpy_pickle.py", line 103, in write_array
pickler.file_handle.write(chunk.tostring('C'))
DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
Versions: python 3.7.4, joblib 0.15.1, numpy 1.19.0
ndarray.tostring is deprecated since numpy 1.19 according to this https://numpy.org/devdocs/reference/generated/numpy.ndarray.tostring.html.
ndarray.tobytes was added in numpy 1.9:
https://numpy.org/devdocs/reference/generated/numpy.ndarray.tobytes.html#numpy.ndarray.tobytes
The README says joblib supports numpy 1.6.1 (not sure if completely up-to-date).
Hmmm I guess in order to avoid the warning we could create a shim function i.e. something like this:
try:
import numpy as np
if LooseVersion(np.__version__) >= LooseVersion('1.9'):
def tobytes(arr, *args, **kwargs):
return arr.tobytes(*args, **kwargs)
else:
def tobytes(arr, *args, **kwargs):
return arr.tostring(*args, **kwargs)
except ImportError:
pass
And then use our tobytes function.
Since numpy moves quite slowly the tostring method is not going to be removed for some time, so doing nothing may be an option ... until our minimum numpy version goes to numpy 1.9.
scikit-learn requires numpy >= 1.13.3 so maybe bumping up the minimal numpy version may be another option.
Actually, master is not using tostring anymore since #1056 .
As we are moving away from old python version (numpy1.6 was released 9years ago), I would say it is okay to only support numpy1.9+ (2014) but it should indeed be fixed in the doc.
joblib 0.16.0 was released yesterday. It does not raise a warning when dumping numpy 1.19 arrays. I believe we can close. Let me know if I missed anything.
Most helpful comment
Actually,
masteris not usingtostringanymore since #1056 .As we are moving away from old python version (
numpy1.6was released 9years ago), I would say it is okay to only supportnumpy1.9+(2014) but it should indeed be fixed in the doc.