zero.stream.ManualStream.data¶
-
ManualStream.
data
(*, n_iterations=None, n_msteps=None)[source]¶ Iterate over the loader.
Exactly one of the arguments must be given.
- Parameters
n_iterations (Optional[Union[int, float]]) – if not None, the method behaves like
Stream.data
.n_msteps (Optional[Union[int, float]]) – if not None, items are produced until
ManualStream.mstep
increases by this value
- Raises
AssertionError – if both
n_iterations
andn_msteps
are given or both of them are omitted.AssertionError – if
n_iterations
is float, but notmath.inf
AssertionError – if
n_msteps
is float, but notmath.inf
- Return type
Iterator
Examples
stream = ManualStream(range(5)) data = stream.data(n_msteps=1) assert next(data) == 0 assert next(data) == 1 assert next(data) == 2 assert stream.iteration == 3 stream.increment_mstep() try: next(data) except StopIteration: print('StopIteration')
StopIteration