Skip to content

Migrate _parse_bsrn and _parse_epw logic into read_bsrn and read_epw - #2934

Closed
DresdenGman wants to merge 2 commits into
pvlib:mainfrom
DresdenGman:fix-2469-migrate-parse-to-read
Closed

DresdenGman wants to merge 2 commits into
pvlib:mainfrom
DresdenGman:fix-2469-migrate-parse-to-read

Conversation

@DresdenGman

Copy link
Copy Markdown

Closes #2469

Summary

As proposed in #2469, the parsing logic from the deprecated public parse_bsrn and parse_epw functions still sat in the private helpers _parse_bsrn and _parse_epw, leaving bsrn.py and epw.py structured differently from the other iotools modules and duplicating documentation. This PR moves that logic into read_bsrn and read_epw and deletes the private helpers. (The deprecated public functions were already removed in v0.16.0, so the helpers had no callers outside these two modules — 4 call sites in total.)

Changes

  • pvlib/iotools/bsrn.py: moved the body of _parse_bsrn verbatim into read_bsrn; updated get_bsrn to call read_bsrn with the in-memory buffer (a path read_bsrn already supports); removed _parse_bsrn and its duplicated docstring.
  • pvlib/iotools/epw.py: inlined the body of _parse_epw into read_epw; updated the HTTP branch to build a StringIO and go through _file_context_manager like the other input paths; removed _parse_epw and its duplicated docstring.
  • The inlined parser bodies are verbatim apart from indentation (22 lines re-wrapped to stay within the 79-character flake8 limit) and one variable rename (fbuf → f); the dispatch around them (get_bsrn, and read_epw's HTTP branch) is what changed. Behavior is unchanged.
  • docs/sphinx/source/whatsnew/v0.16.2.rst: added a maintenance entry.

Tests

  • Existing: test_bsrn.py + test_epw.py gave 10 passed / 3 skipped before this change (the skips are the credential-gated remote BSRN tests) and give the same results after it.
  • Behavior comparison: 7 cases (BSRN from .gz with defaults and with all longwave-radiation columns, BSRN from .dat, BSRN via a gzip buffer; EPW with defaults, with coerce_year=2015, and via StringIO) were compared before vs. after — DataFrame value hashes, shapes, and metadata fingerprints are identical in every case. Downstream checks: the Location.from_epw test passes and test_pvgis.py (which calls read_epw internally) is 29 passed.
  • New mocked tests for the two rerouted entry points (4 tests, bringing the two files to 14 passed / 3 skipped): get_bsrn is exercised end-to-end against a mocked FTP connection returning the sample gzip bytes — the result is value-identical to the local read_bsrn path, and a spy check confirms read_bsrn is called exactly once with the buffer and with a non-default logical_records forwarded verbatim; read_epw is exercised through a mocked urlopen, value-identical to the local path, including forwarding of coerce_year.

@RDaxini

RDaxini commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Closing this since the contributing guidelines have not been followed. Will consider re-opening if compliance is achieved. Core guidelines were also highlighted to you in #2932 (see #2932 (comment)).

@RDaxini RDaxini closed this Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate functionality from private _parse_bsrn and _parse_epw to their read functions

2 participants