-
Notifications
You must be signed in to change notification settings - Fork 261
Add a function to concatenate multiple ArraySequence objects #494
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
Add a function to concatenate multiple ArraySequence objects #494
Conversation
Codecov Report
@@ Coverage Diff @@
## master #494 +/- ##
==========================================
+ Coverage 93.97% 94.03% +0.06%
==========================================
Files 166 166
Lines 21836 22015 +179
Branches 2327 2345 +18
==========================================
+ Hits 20520 20702 +182
+ Misses 885 878 -7
- Partials 431 435 +4
Continue to review full report at Codecov.
|
Tested for my RGB use case (zipping 3 ArraySequence) and work perfectly. |
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.
A few small comments.
|
||
Parameters | ||
---------- | ||
seqs: list of :class:`ArraySequence` objects |
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 guess it just has to be iterable, and does not have to be exactly a list?
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.
You are right. I'll clarify.
|
||
|
||
def test_concatenate(): | ||
seq = SEQ_DATA['seq'].copy() # In case there is in-place modification. |
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.
Should there be in-place modification? Worth testing?
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.
No, it shouldn't. I added a test.
seq = SEQ_DATA['seq'] | ||
seqs = [seq[:, [i]] for i in range(seq.common_shape[0])] | ||
new_seq = concatenate(seqs, axis=0) | ||
assert_true(len(new_seq), seq.common_shape[0]*len(seq)) |
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 think PEP8 likes spaces around the *
here.
I totally forgot about this one. @matthew-brett: all your comments should be addressed now. |
Thanks - merged. |
This PR adds the function
nibabel.streamlines.array_sequence.concatenate(seqs, axis)
that can concatenate multipleArraySequence
objects along the provided axis.