diff options
author | Frederick Muriuki Muriithi | 2025-07-14 13:44:27 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-07-14 13:44:48 -0500 |
commit | 58480d532a73997474692b5df4c186a60ef61208 (patch) | |
tree | fd739ed9c8a29543d637133c8d565d28114dbb7b /r_qtl/r_qtl2.py | |
parent | 444031b36f49787f88ecbd4b892b2a855f211284 (diff) | |
download | gn-uploader-58480d532a73997474692b5df4c186a60ef61208.tar.gz |
Use `yield from …` form.
Use the `yield from` form rather than iterating through the elements
of the built sequence.
Diffstat (limited to 'r_qtl/r_qtl2.py')
-rw-r--r-- | r_qtl/r_qtl2.py | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/r_qtl/r_qtl2.py b/r_qtl/r_qtl2.py index 06175ce..0ef487f 100644 --- a/r_qtl/r_qtl2.py +++ b/r_qtl/r_qtl2.py @@ -411,22 +411,19 @@ def file_data(zfile: ZipFile, try: if isinstance(cdata[member_key], list): - for row in (line for lines in + yield from (line for lines in (file_data( zfile, member_key, {**cdata, member_key: innerfile}, process_value, process_transposed_value) for innerfile in cdata[member_key]) - for line in lines): - yield row + for line in lines) return if not cdata.get(f"{member_key}_transposed", False): - for row in with_non_transposed(zfile, member_key, cdata, process_value): - yield row + yield from with_non_transposed(zfile, member_key, cdata, process_value) return - for row in with_transposed( - zfile, member_key, cdata, process_transposed_value): - yield row + yield from with_transposed( + zfile, member_key, cdata, process_transposed_value) except KeyError as exc: raise MissingFileException(*exc.args) from exc @@ -477,8 +474,7 @@ def raw_file_data(zipfilepath: Union[str, Path], with (ZipFile(str(zipfilepath), "r") as zfile, zfile.open(memberfilename) as innerfile): wrappedfile = io.TextIOWrapper(innerfile) - for line in wrappedfile: - yield line + yield from wrappedfile def strip_comments(rawdata: Iterator[str], commentchar) -> Iterator[str]: """Remove comments from raw text.""" @@ -568,8 +564,7 @@ def load_samples(zipfilepath: Union[str, Path], def read_text_file(filepath: Union[str, Path]) -> Iterator[str]: """Read the raw text from a text file.""" with open(filepath, "r", encoding="utf8") as _file: - for line in _file: - yield line + yield from _file def read_csv_file(filepath: Union[str, Path], |