Replace deprecated numpy tostring/fromstring with tobytes/frombuffer#379
Open
marouenbg wants to merge 2 commits intonetZoo:develfrom
Open
Replace deprecated numpy tostring/fromstring with tobytes/frombuffer#379marouenbg wants to merge 2 commits intonetZoo:develfrom
marouenbg wants to merge 2 commits intonetZoo:develfrom
Conversation
np.ndarray.tostring() was removed in numpy 2.3+. Replace all tostring()/fromstring() calls with tobytes()/frombuffer() which have identical behavior and are the supported API. Fixes netZoo#378
- test_cobra: use numpy array for mean computation instead of pandas Series integer access (KeyError: 0 with string column index) - condor: use .iloc for positional access on iterrows() Series (KeyError: 2 with string column labels) - condor: use ki.sum() instead of float(sum(ki)) to avoid TypeError with np.matrix column vectors in newer numpy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace all
np.ndarray.tostring()/np.fromstring()calls withnp.ndarray.tobytes()/np.frombuffer()inlioness.py.Motivation
np.ndarray.tostring()was deprecated in favor oftobytes()(identical behavior) and was fully removed in numpy 2.3+. This causesAttributeErrorwhen running LIONESS with modern numpy versions.Fixes #378
Changes
netZooPy/lioness/lioness.py: replaced 4 active usages and 2 commented-out usages oftostring()/fromstring()withtobytes()/frombuffer().