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

@DresdenGman DresdenGman commented Nov 3, 2026 •

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. The parser implementations are moved without intended semantic changes; the before/after comparisons below demonstrate identical outputs for the tested cases.
  • 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.

  • Closes Migrate functionality from private _parse_bsrn and _parse_epw to their read functions #2469

  • I am familiar with the contributing guidelines

  • I attest that all AI-generated material has been vetted for accuracy and is in compliance with the pvlib license

  • Tests added

  • Adds description and name entries in the appropriate "what's new" file in docs/sphinx/source/whatsnew for all changes. Includes link to the GitHub Issue with :issue:`num` or this Pull Request with :pull:`num`. Includes contributor name and/or GitHub username (link with :ghuser:`user`).

  • New code is fully documented. Includes numpydoc compliant docstrings, examples, and comments where necessary.

  • Pull request is nearly complete and ready for detailed review.

  • Maintainer: Appropriate GitHub Labels (including remote-data) and Milestone are assigned to the Pull Request and linked Issue.

@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
@DresdenGman

Copy link
Copy Markdown
Author

Hi @RDaxini — thanks for pointing this out, and apologies for missing the required template. I've updated the PR description with the full pvlib checklist and completed the applicable items. I've also reviewed the contributing guidelines and the iotools code paths and tests involved in this change.

I also saw the earlier discussion on #2469 about the familiarity this task requires. I completely understand if you'd prefer to leave it closed on that basis; but if the PR as updated now meets the project's requirements, I'd be grateful if you'd consider reopening it for review.

Either way, thank you for your time.

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