8000 Add a function to concatenate multiple ArraySequence objects by MarcCote · Pull Request #494 · nipy/nibabel · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 5 commits into from
Feb 15, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Addressed @matthew-brett's comments
  • Loading branch information
MarcCote committed Jan 19, 2017
commit a3aedc73c517aff13c3b64f375fd2c642e71e946
2 changes: 1 addition & 1 deletion nibabel/streamlines/array_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def concatenate(seqs, axis):

Parameters
----------
seqs: list of :class:`ArraySequence` objects
seqs: iterable of :class:`ArraySequence` objects
Sequences to concatenate.
axis : int
Axis along which the sequences will be concatenated.
Expand Down
4 changes: 2 additions & 2 deletions nibabel/streamlines/tests/test_array_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,12 @@ def test_concatenate():
seq = SEQ_DATA['seq'].copy() # In case there is in-place modification.
Copy link
Member

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?

Copy link
Contributor Author

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.

seqs = [seq[:, [i]] for i in range(seq.common_shape[0])]
new_seq = concatenate(seqs, axis=1)
seq._data += 100 # Modifying the 'seq' shouldn't change 'new_seq'.
check_arr_seq(new_seq, SEQ_DATA['data'])
assert_true(not new_seq._is_view)

seq = SEQ_DATA['seq'].copy() # In case there is in-place modification.
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))
Copy link
Member

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.

assert_array_equal(new_seq._data, seq._data.T.reshape((-1, 1)))
0