Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH: Allow path-like objects for tractogram load/saving #1421

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

Closed

Conversation

Copy link
Contributor

@jhlegarreta jhlegarreta commented Jul 5, 2025

Allow path-like objects for tractogram load/saving.

Crucially, this patch set uses the capabilities of pathlib.Path to get the suffix of a filename when detecing the format instead of relying on the splitext function of the os.path module, which requires a str instance.

Add the corresponding tests.

Change the docstrings to mark the types of the filenames as path-like objects instead of only str objects.

Copy link

codecov bot commented Jul 5, 2025
edited
Loading

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.44%. Comparing base (a8a1759) to head (5970509).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@
## master #1421 +/- ##
=======================================
 Coverage 95.44% 95.44% 
=======================================
 Files 209 209 
 Lines 29782 29803 +21 
 Branches 4472 4478 +6 
=======================================
+ Hits 28424 28445 +21 
 Misses 925 925 
 Partials 433 433 

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jhlegarreta jhlegarreta force-pushed the AllowPathlikeTractogramLoadSave branch from 5254601 to e263641 Compare July 5, 2025 21:40
Allow path-like objects for tractogram load/saving.
Crucially, this patch set uses the capabilities of `pathlib.Path` to get
the suffix of a filename when detecing the format instead of relying on
the `splitext` function of the `os.path` module, which requires a `str`
instance.
Add the corresponding tests.
Change the docstrings to mark the types of the filenames as `path-like`
objects instead of only `str` objects.
@jhlegarreta jhlegarreta force-pushed the AllowPathlikeTractogramLoadSave branch from e263641 to 92e8cb2 Compare July 5, 2025 21:49
Copy link
Contributor Author

jhlegarreta commented Jul 5, 2025
edited
Loading

Style errors predated this PR. Addressed in PR #1423.
Type checking errors predated this PR. Addressed in PR #1424.

Copy link
Contributor Author

@effigies this is ready to be merged.

Copy link
Member

relying on the splitext function of the os.path module, which requires a str instance.

In [3]: import os.path
In [4]: from pathlib import Path
In [5]: os.path.splitext('/path/to/streamline.tck')
Out[5]: ('/path/to/streamline', '.tck')

os.path was retrofitted to allow PathLikes in almost all of its functions. I don't think this change is necessary, but documenting and testing the support for PathLikes is welcome. Could you try reverting the splitext change and see if the tests still pass?

@jhlegarreta jhlegarreta deleted the AllowPathlikeTractogramLoadSave branch September 22, 2025 13:20
Copy link
Contributor Author

Closed by mistake. Sorry. Re-opened as #1435.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /