@@ -113,14 +113,22 @@ def __setitem__(self, key, value):
113
113
self .store [key ] = value
114
114
115
115
def extend (self , other ):
116
- if len (self ) != len (other ):
117
- msg = ("Size mismatched between the two PerArrayDict objects."
118
- " This PerArrayDict has {0} elements whereas the other "
119
- " has {1} elements." ).format (len (self ), len (other ))
120
- raise ValueError (msg )
116
+ """ Appends the elements of another :class:`PerArrayDict`.
117
+
118
+ That is, for each entry in this dictionary, we append the elements
119
+ coming from the other dictionary at the corresponding entry.
120
+
121
+ Parameters
122
+ ----------
123
+ other : :class:`PerArrayDict` object
124
+ Its data will be appended to the data of this dictionary.
121
125
126
+ Notes
127
+ -----
128
+ The entries in both dictionaries must match.
129
+ """
122
130
if sorted (self .keys ()) != sorted (other .keys ()):
123
- msg = ("Key mismatched between the two PerArrayDict objects."
131
+ msg = ("Entry mismatched between the two PerArrayDict objects."
124
132
" This PerArrayDict contains '{0}' whereas the other "
125
133
" contains '{1}'." ).format (sorted (self .keys ()),
126
134
sorted (other .keys ()))
@@ -159,12 +167,20 @@ def __setitem__(self, key, value):
159
167
self .store [key ] = value
160
168
161
169
def extend (self , other ):
162
- if len (self ) != len (other ):
163
- msg = ("Size mismatched between the two PerArrayDict objects."
164
- " This PerArrayDict has {0} elements whereas the other "
165
- " has {1} elements." ).format (len (self ), len (other ))
166
- raise ValueError (msg )
170
+ """ Appends the elements of another :class:`PerArraySequenceDict`.
167
171
172
+ That is, for each entry in this dictionary, we append the elements
173
+ coming from the other dictionary at the corresponding entry.
174
+
175
+ Parameters
176
+ ----------
177
+ other : :class:`PerArraySequenceDict` object
178
+ Its data will be appended to the data of this dictionary.
179
+
180
+ Notes
181
+ -----
182
+ The entries in both dictionaries must match.
183
+ """
168
184
if sorted (self .keys ()) != sorted (other .keys ()):
169
185
msg = ("Key mismatched between the two PerArrayDict objects."
170
186
" This PerArrayDict contains '{0}' whereas the other "
@@ -463,7 +479,21 @@ def to_world(self, lazy=False):
463
479
return self .apply_affine (self .affine_to_rasmm , lazy = lazy )
464
480
465
481
def extend (self , other ):
466
- # TODO: Make sure the other tractogram is compatible.
482
+ """ Appends the data of another :class:`Tractogram`.
483
+
484
+ Data that will be appended includes the streamlines and the content
485
+ of both dictionaries `data_per_streamline` and `data_per_point`.
486
+
487
+ Parameters
488
+ ----------
489
+ other : :class:`Tractogram` object
490
+ Its data will be appended to the data of this tractogram.
491
+
492
+ Notes
493
+ -----
494
+ The entries of `self.data_per_streamline` and `self.data_per_point`
495
+ must match those contained in the other tractogram.
496
+ """
467
497
self .streamlines .extend (other .streamlines )
468
498
self .data_per_streamline += other .data_per_streamline
469
499
self .data_per_point += other .data_per_point
@@ -708,7 +738,8 @@ def __getitem__(self, idx):
708
738
raise NotImplementedError ('LazyTractogram does not support indexing.' )
709
739
710
740
def extend (self , other ):
711
- raise NotImplementedError ('LazyTractogram does not support concatenation.' )
741
+ msg = 'LazyTractogram does not support concatenation.'
742
+ raise NotImplementedError (msg )
712
743
713
744
def __iter__ (self ):
714
745
count = 0
0 commit comments