Skip to content

Parse two-digit EnergyPlus major versions in .eso files - #33

Merged
vojtech-db merged 1 commit into
mainfrom
fix/eso-version-parsing
Nov 11, 2026
Merged

vojtech-db merged 1 commit into
mainfrom
fix/eso-version-parsing

Conversation

@btokarzewskidb

Copy link
Copy Markdown
Contributor

Fixes #32.

Problem

get_eso_file_version took a fixed five-character slice and stripped the dots, so 25.2.0 became 252. That is below the 890 threshold read_file uses to decide whether the file has a sixth standard dictionary item (annual), so every EnergyPlus 10.0+ .eso was read as a pre-8.9 file:

  • the 6,1,Calendar Year of Simulation[] ! When Annual Report Variables Requested line was parsed as a variable under frequency '', so DBEsoFile.frequencies raised KeyError: '';
  • the annual marker line in the body was treated as a result, so files with !Annual outputs failed to parse (KeyError: 6).

Changes

  • get_eso_file_version now returns a (major, minor, patch) tuple (e.g. (25, 2, 0)) and compares against (8, 9, 0). It raises InvalidLineSyntax if the version can't be parsed. This changes the return type of this function and of the version from process_statement_line, from int to tuple. Both are used only inside the reader.
  • Once annual rows parsed, design-day environments exposed two more bugs. They declare annual variables but never report an annual row, so update_start_dates raised IndexError and find_num_of_days_annual raised ZeroDivisionError. Both now handle the empty case, and the design-day environments get n_days[A] == [].
  • I did not make DBEsoFile.frequencies tolerate unknown keys. With the root cause fixed, a KeyError there would point to a real parsing bug, and hiding it seemed worse.

Tests

  • Version parsing for 8.6, 9.2, 23.1, 25.2 and 26.2, including the ordering of one- and two-digit major versions.
  • frequencies for every versioned fixture (231, 251, 252).
  • A synthetic single-environment file with a 25.2 version line (frequencies and annual results).
  • New fixture tests/test_files/262_1ZoneUncontrolledAnnualOutputs.eso, run with EnergyPlus 26.2 from resources/252_1ZoneUncontrolledAnnualOutputs.idf (transitioned 25.2 → 26.2, which only changes the Version object) and the Chicago TMY3 file in resources/. It covers annual results across a 2018–2019 run period and the two design days with no annual rows. It is force-added because .gitignore excludes *.eso, as with the other fixtures.

pytest: 226 passed (213 before). ruff check, ruff format --check and pylint (10.00) are clean.

🤖 Generated with Claude Code

get_eso_file_version sliced five characters and stripped the dots, so
'25.2.0' became 252, below the 890 threshold for the sixth standard
dictionary item. Every EnergyPlus 10.0+ file was read as pre-8.9: the
annual dictionary line landed in the header under frequency '', so
DBEsoFile.frequencies raised KeyError, and files with annual outputs
failed to parse.

The version is now a (major, minor, patch) tuple compared against
(8, 9, 0). With annual rows parsed, design-day environments (which
declare annual variables but report no annual rows) exposed two
empty-list bugs in update_start_dates and find_num_of_days_annual;
both now handle the empty case.

Adds an EnergyPlus 26.2 .eso fixture with annual outputs, generated
from resources/252_1ZoneUncontrolledAnnualOutputs.idf (transitioned
to 26.2), plus version, frequencies and annual tests.

Fixes #32

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@btokarzewskidb btokarzewskidb self-assigned this Nov 5, 2026
@vojtech-db
vojtech-db merged commit f3fb7a6 into main Nov 11, 2026
7 checks passed
@btokarzewskidb
btokarzewskidb deleted the fix/eso-version-parsing branch November 13, 2026 09:33
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.

KeyError in DBEsoFile.frequencies for EnergyPlus 10.0+ files (version string mis-parsed)

2 participants