Skip to content

Commit a6e5026

Browse files
matthew-brettMarcCote
authored andcommitted
DOC: small docstring edits for ArraySequence
Minor docstring edits
1 parent 96a221f commit a6e5026

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

nibabel/streamlines/array_sequence.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def is_array_sequence(obj):
1313
class ArraySequence(object):
1414
""" Sequence of ndarrays having variable first dimension sizes.
1515
16-
This is a container allowing to store multiple ndarrays where each ndarray
17-
might have different first dimension size but a *common* size for the
16+
This is a container that can store multiple ndarrays where each ndarray
17+
might have a different first dimension size but a *common* size for the
1818
remaining dimensions.
1919
2020
More generally, an instance of :class:`ArraySequence` of length $N$ is
@@ -26,7 +26,8 @@ class ArraySequence(object):
2626
BUFFER_SIZE = 87382 * 4 # About 4 Mb if item shape is 3 (e.g. 3D points).
2727

2828
def __init__(self, iterable=None):
29-
"""
29+
""" Initialize array sequence instance
30+
3031
Parameters
3132
----------
3233
iterable : None or iterable or :class:`ArraySequence`, optional
@@ -100,6 +101,10 @@ def append(self, element):
100101
Element to append. The shape must match already inserted elements
101102
shape except for the first dimension.
102103
104+
Returns
105+
-------
106+
None
107+
103108
Notes
104109
-----
105110
If you need to add multiple elements you should consider
@@ -130,10 +135,14 @@ def extend(self, elements):
130135
If :class:`ArraySequence` object, its data are simply appended to
131136
the data of this ArraySequence.
132137
138+
Returns
139+
-------
140+
None
141+
133142
Notes
134143
-----
135-
The shape of the elements to be added must match the one of the
136-
data of this :class:`ArraySequence` except for the first dimension.
144+
The shape of the elements to be added must match the one of the data of
145+
this :class:`ArraySequence` except for the first dimension.
137146
"""
138147
if not is_array_sequence(elements):
139148
self.extend(ArraySequence(elements))
@@ -162,10 +171,19 @@ def extend(self, elements):
162171
self._offsets = np.r_[self._offsets, offsets]
163172

164173
def copy(self):
165-
""" Creates a copy of this :class:`ArraySequence` object. """
166-
# We do not simply deepcopy this object since we might have a chance
167-
# to use less memory. For example, if the array sequence being copied
168-
# is the result of a slicing operation on a array sequence.
174+
""" Creates a copy of this :class:`ArraySequence` object.
175+
176+
Returns
177+
-------
178+
seq_copy : :class:`ArraySequence` instance
179+
Copy of `self`.
180+
181+
Notes
182+
-----
183+
We do not simply deepcopy this object because we have a chance to use
184+
less memory. For example, if the array sequence being copied is the
185+
result of a slicing operation on an array sequence.
186+
"""
169187
seq = ArraySequence()
170188
total_lengths = np.sum(self._lengths)
171189
seq._data = np.empty((total_lengths,) + self._data.shape[1:],
@@ -185,7 +203,7 @@ def copy(self):
185203
return seq
186204

187205
def __getitem__(self, idx):
188-
""" Gets sequence(s) through advanced indexing.
206+
""" Get sequence(s) through standard or advanced numpy indexing.
189207
190208
Parameters
191209
----------
@@ -200,7 +218,7 @@ def __getitem__(self, idx):
200218
-------
201219
ndarray or :class:`ArraySequence`
202220
If `idx` is an int, returns the selected sequence.
203-
Otherwise, returns a :class:`ArraySequence` object which is view
221+
Otherwise, returns a :class:`ArraySequence` object which is a view
204222
of the selected sequences.
205223
"""
206224
if isinstance(idx, (numbers.Integral, np.integer)):

0 commit comments

Comments
 (0)