Skip to content

Commit

Permalink
SourcePipe: docstring for __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
ebonnal committed Nov 19, 2023
1 parent b0e9be7 commit b779f2a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kioss/_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,15 @@ def superintend(self, n_samples: int = 0, n_error_samples: int = 8) -> List[T]:

class SourcePipe(APipe[T]):
def __init__(self, source: Callable[[], Iterator[T]]):
"""
Initialize a Pipe with a data source.
The source must be a callable that returns an iterator, i.e., an object implementing __iter__ and __next__ methods.
Each subsequent iteration over the pipe will use a fresh iterator obtained from `source()`.
Args:
source (Callable[[], Iterator[T]]): A factory function called to obtain a fresh data source iterator for each iteration.
"""
super().__init__()
if not isinstance(source, Callable):
raise TypeError(
Expand Down

0 comments on commit b779f2a

Please sign in to comment.