Skip to content
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

RF: Remove unnecessary call to asbytes for b-prepended strings #1331

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

jhlegarreta
Copy link
Contributor

@jhlegarreta jhlegarreta commented Jun 27, 2024

Remove unnecessary call to asbytes for b-prepended strings: strings
prepended with b are already treated as bytes literals:

  • TckFile.MAGIC_NUMBER is b'mrtrix tracks'
  • TrkFile.MAGIC_NUMBER is b'TRACK'

Documentation:
https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals

Fixes:

/home/runner/work/nibabel/nibabel/nibabel/streamlines/tests/test_streamlines.py:9:
 DeprecationWarning: `np.compat`, which was used during the Python 2 to 3 transition,
 is deprecated since 1.26.0, and will be removed
      from numpy.compat.py3k import asbytes

raised for example at:
https://github.com/nipy/nibabel/actions/runs/9637811213/job/26577586721#step:7:178

Copy link

codecov bot commented Jun 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.20%. Comparing base (d18022d) to head (d1235a6).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1331   +/-   ##
=======================================
  Coverage   92.20%   92.20%           
=======================================
  Files          98       98           
  Lines       12400    12400           
  Branches     2557     2557           
=======================================
  Hits        11433    11433           
  Misses        644      644           
  Partials      323      323           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Remove unnecessary call to `asbytes` for `b`-prepended strings: strings
prepended with `b` are already treated as bytes literals:
- `TckFile.MAGIC_NUMBER` is b'mrtrix tracks'
- `TrkFile.MAGIC_NUMBER` is b'TRACK'

Documentation:
https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals

Fixes:
```
/home/runner/work/nibabel/nibabel/nibabel/streamlines/tests/test_streamlines.py:9:
 DeprecationWarning: `np.compat`, which was used during the Python 2 to 3 transition,
 is deprecated since 1.26.0, and will be removed
      from numpy.compat.py3k import asbytes
```

raised for example at:
https://github.com/nipy/nibabel/actions/runs/9637811213/job/26577586721#step:7:178
@jhlegarreta jhlegarreta changed the title RF: Prefer using "b" to mark byte literals RF: Remove unnecessary call to asbytes for b-prepended strings Jun 27, 2024
@jhlegarreta
Copy link
Contributor Author

doctest build failures are unrelated.

@effigies effigies merged commit 0ebf390 into nipy:master Jun 27, 2024
48 of 49 checks passed
@jhlegarreta jhlegarreta deleted the FixNpCompatWarning branch June 27, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants