question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DeprecationWarning: tostring() is deprecated

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
tomMoralcommented, Jun 23, 2020

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.

1reaction
lestevecommented, Jun 23, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DeprecationWarning: tostring() is deprecated. Use tobytes ...
tostring() apparently is deprecated since version 3.2, I guess that the warning pops up now because the method will be removed in version...
Read more >
tensorflow 1.15 raises DeprecationWarning: tostring ... - GitLab
tensorflow (v1.15) raises the following warning when numpy v1.19 or later is used: DeprecationWarning: tostring() is deprecated.
Read more >
python - What is the difference between tostring() and tobytes ...
tostring has been kept for backwards compatibility, but the use of tostring is deprecated. Share.
Read more >
LimaCCDs: Deprecation warning to replace `tostring` (#47) · Issues ...
While i was playing with the simulator i have received that stuff. No idea why it's the first time i notice that stuff....
Read more >
Meme Overflow on Twitter: "This error comes up ...
This error comes up, DeprecationWarning: tostring() is deprecated. Use tobytes() instead. which is effecting video playback ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found