Skip to content

Commit

Permalink
doc: update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixAbrahamsson authored and samedii committed Jun 15, 2021
1 parent 1591d9e commit cf4b0c1
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions kw6/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ def from_path(path, header_path=None):
)

def __getitem__(self, indices_or_slice):
'''
Access a position by frame index. Supports slicing and array indexing
Example:
.. code-block:: python
from pathlib import Path
import kw6
stream = kw6.Stream.from_path(Path('...'))
position = stream[10]
positions = stream[10: 20]
positions = stream[[5, 7, 9]]
all_positions = stream[:]
'''
if type(indices_or_slice) == int:
if indices_or_slice < 0:
raise IndexError('Negative indexing not supported.')
Expand Down Expand Up @@ -76,8 +92,6 @@ def empty(self):
return self.stream.peek(1) == b''

def _seek(self, frame_index: types.FRAME_INDEX):
'''Go to stream position indicated by frame_index'''

self._seek_closest_stored_position(frame_index)

if PositionHeader.peek(self.stream).frame_index > frame_index:
Expand Down Expand Up @@ -113,6 +127,7 @@ def __iter__(self):
yield position

def close_(self):
'''Close the stream file object, makes the stream unusable'''
self.stream.close()


Expand Down

0 comments on commit cf4b0c1

Please sign in to comment.