Skip to content

Commit

Permalink
CU-8694dpy1c: Return empty generator upon empty stream (#423)
Browse files Browse the repository at this point in the history
* CU-8694dpy1c: Return empty generator upon empty stream

* CU-8694dpy1c: Fix empty generator returns

* CU-8694dpy1c: Simplify empty generator returns
  • Loading branch information
mart-r committed Aug 13, 2024
1 parent 75ca4e2 commit a51b35f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion medcat/meta_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,8 @@ def pipe(self, stream: Iterable[Union[Doc, FakeDoc]], *args, **kwargs) -> Iterat
"""
# Just in case
if stream is None or not stream:
return stream
# return an empty generator
return

config = self.config
id2category_value = {v: k for k, v in config.general['category_value2id'].items()}
Expand Down
3 changes: 2 additions & 1 deletion medcat/ner/transformers_ner.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ def pipe(self, stream: Iterable[Union[Doc, None]], *args, **kwargs) -> Iterator[
"""
# Just in case
if stream is None or not stream:
return stream
# return an empty generator
return

batch_size_chars = self.config.general['pipe_batch_size_in_chars']
yield from self._process(stream, batch_size_chars) # type: ignore
Expand Down

0 comments on commit a51b35f

Please sign in to comment.