This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
ENH: Indexes sorting options #150
Merged
Merged
Changes from 2 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
3343f34
enh: externalize sorting functions
esavary 1e305d9
fix:import statement
esavary 6a8a585
sty: fix style error
esavary 4e199a9
sty: fix style error
esavary b13c975
sty: fix style errors
esavary 148bb71
Apply suggestions from code review
esavary 5155f9f
fix: revert stylistic changes
esavary 9420ce5
fix: revert stylistic changes
esavary 3d7afb1
fix: revert stylistic changes
esavary 69611fa
Update src/eddymotion/utils.py
esavary 31fa9d6
Update src/eddymotion/utils.py
esavary 6320f66
Update src/eddymotion/utils.py
esavary 4998afa
fix: revert changes in estimator.py
esavary a424582
Apply suggestions from code review
esavary 88bea1d
fix: typos
esavary b58a708
enh: update args and test for bvalue_action
esavary 4366683
fix: docstring
esavary ee95877
fix: remove unused import
esavary e84bddd
Apply suggestions from code review
esavary 3c0b36d
fix: add link for new module documentation
esavary 22bbb68
fix: add exeption
esavary 43fe703
fix: bvalue_action implementation + typos
esavary 11f52a4
sty: remove white space
esavary cdfe20a
fix: typos
esavary f858a6a
sty: remove white space
esavary 90cf31c
Apply suggestions from code review
esavary fa43376
sty: change iterator names
esavary cdeb34f
sty: fix docstring
esavary 965b3c5
Apply suggestions from code review
esavary a43fdde
fix: random seed and add test
esavary ae19816
fix: typos
esavary d78c500
enh: generalize docstring
esavary 6aaa7d4
Update src/eddymotion/utils.py
esavary 4e7a418
Apply suggestions from code review
esavary 4163b0b
Apply suggestions from code review
esavary ed20ca8
fix: random generator test results
esavary d966c97
Apply suggestions from code review
esavary 0057079
sty: add typing
esavary 6f0d5fe
fix: remove unused import
esavary 2cc923a
Apply suggestions from code review
esavary 9bda539
fix: import position
esavary d1c9846
Apply suggestions from code review
esavary 807a468
fix: iterator typing in docstring
esavary fee865d
sty: fix ruff errors
esavary 5f0837d
Merge branch 'nipreps:main' into index-sorting
esavary caa72a5
sty: fix sty errors
esavary 911a730
sty: fix sty errors
esavary File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,3 +1,7 @@ | ||||||||||||
import random | ||||||||||||
from itertools import chain, zip_longest | ||||||||||||
from typing import Generator | ||||||||||||
|
||||||||||||
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- | ||||||||||||
# vi: set ft=python sts=4 ts=4 sw=4 et: | ||||||||||||
# | ||||||||||||
|
@@ -22,23 +26,20 @@ | |||||||||||
# | ||||||||||||
"""Iterators to traverse the volumes in a 4D image.""" | ||||||||||||
|
||||||||||||
import random | ||||||||||||
from itertools import chain, zip_longest | ||||||||||||
|
||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert the removal of imports and add the Generation import here:
Suggested change
|
||||||||||||
|
||||||||||||
oesteban marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
def linear_iterator(size=None, **kwargs): | ||||||||||||
def linear_iterator(size: int = None, **kwargs) -> Generator[int, None, None]: | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
""" | ||||||||||||
Traverse the dataset volumes in ascending order. | ||||||||||||
|
||||||||||||
Parameters | ||||||||||||
---------- | ||||||||||||
size : :obj:`int` | ||||||||||||
size : int, optional | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
Number of volumes in the dataset | ||||||||||||
(for instance, the number of orientations in a DWI) | ||||||||||||
|
||||||||||||
Returns | ||||||||||||
------- | ||||||||||||
:obj:`~typing.Generator` | ||||||||||||
Generator[int, None, None] | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
The sorted index order. | ||||||||||||
|
||||||||||||
Examples | ||||||||||||
|
@@ -55,24 +56,24 @@ def linear_iterator(size=None, **kwargs): | |||||||||||
return range(size) | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
|
||||||||||||
|
||||||||||||
def random_iterator(size=None, **kwargs): | ||||||||||||
def random_iterator(size: int = None, **kwargs) -> Generator[int, None, None]: | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
""" | ||||||||||||
Traverse the dataset volumes randomly. | ||||||||||||
|
||||||||||||
Parameters | ||||||||||||
---------- | ||||||||||||
size : :obj:`int` | ||||||||||||
size : int, optional | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
Number of volumes in the dataset | ||||||||||||
(for instance, the number of orientations in a DWI) | ||||||||||||
seed : :obj:`int` or :obj:`bool` or :obj:`bool` or ``None`` | ||||||||||||
If :obj:`int` or :obj:`str` or ``None``, initializes the seed of Python's random generator | ||||||||||||
seed : int or bool or None, optional | ||||||||||||
If int or str or None, initializes the seed of Python's random generator | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
with the given value. | ||||||||||||
If ``False``, the random generator is passed ``None``. | ||||||||||||
If ``True``, a default seed value is set. | ||||||||||||
If False, the random generator is passed None. | ||||||||||||
If True, a default seed value is set. | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
|
||||||||||||
Returns | ||||||||||||
------- | ||||||||||||
:obj:`~typing.Generator` | ||||||||||||
Generator[int, None, None] | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
The sorted index order. | ||||||||||||
oesteban marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
|
||||||||||||
Examples | ||||||||||||
|
@@ -104,18 +105,18 @@ def random_iterator(size=None, **kwargs): | |||||||||||
return (x for x in index_order) | ||||||||||||
|
||||||||||||
|
||||||||||||
def bvalue_iterator(size=None, **kwargs): | ||||||||||||
def bvalue_iterator(size: int = None, **kwargs) -> Generator[int, None, None]: | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
""" | ||||||||||||
Traverse the volumes in a DWI dataset by growing b-value. | ||||||||||||
|
||||||||||||
Parameters | ||||||||||||
---------- | ||||||||||||
bvalues : :obj:`list` | ||||||||||||
bvals : list | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
List of b-values corresponding to all orientations of the dataset. | ||||||||||||
|
||||||||||||
Returns | ||||||||||||
------- | ||||||||||||
:obj:`~typing.Generator` | ||||||||||||
Generator[int, None, None] | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
The sorted index order. | ||||||||||||
|
||||||||||||
Examples | ||||||||||||
|
@@ -131,19 +132,19 @@ def bvalue_iterator(size=None, **kwargs): | |||||||||||
return (index[1] for index in indexed_bvals) | ||||||||||||
|
||||||||||||
|
||||||||||||
def centralsym_iterator(size=None, **kwargs): | ||||||||||||
def centralsym_iterator(size: int = None, **kwargs) -> Generator[int, None, None]: | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
""" | ||||||||||||
Traverse the dataset starting from the center and alternatingly progressing to the sides. | ||||||||||||
|
||||||||||||
Parameters | ||||||||||||
---------- | ||||||||||||
size : :obj:`int` | ||||||||||||
size : int | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
Number of volumes in the dataset | ||||||||||||
(for instance, the number of orientations in a DWI) | ||||||||||||
|
||||||||||||
Returns | ||||||||||||
------- | ||||||||||||
:obj:`~typing.Generator` | ||||||||||||
Generator[int, None, None] | ||||||||||||
esavary marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
The sorted index order. | ||||||||||||
|
||||||||||||
Examples | ||||||||||||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, be careful, why these four lines here before the header?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the imports in 9bda539.