Versions¶
Constants and utilities for working with EnergyPlus version numbers. idfkit bundles schemas for every release from v8.9 through v26.2.
EnergyPlus version registry.
Defines all supported EnergyPlus versions since v8.9 (the first to publish epJSON schema) and provides utilities for version manipulation.
ENERGYPLUS_VERSIONS = ((8, 9, 0), (9, 0, 1), (9, 1, 0), (9, 2, 0), (9, 3, 0), (9, 4, 0), (9, 5, 0), (9, 6, 0), (22, 1, 0), (22, 2, 0), (23, 1, 0), (23, 2, 0), (24, 1, 0), (24, 2, 0), (25, 1, 0), (25, 2, 0), (26, 1, 0), (26, 2, 0))
module-attribute
¶
LATEST_VERSION = ENERGYPLUS_VERSIONS[-1]
module-attribute
¶
MINIMUM_VERSION = ENERGYPLUS_VERSIONS[0]
module-attribute
¶
describe_presence(present, absent)
¶
Which releases have something, as briefly as is still exact; both arguments must be non-empty.
added in 9.6.0 when every release lacking it comes before every release having it and the
two meet, removed in 23.1.0 for the reverse, and otherwise exists in the releases that
have it.
Examples:
>>> describe_presence([(26, 1, 0), (26, 2, 0)], [(25, 2, 0)])
'added in 26.1.0'
>>> describe_presence([(9, 5, 0)], [(9, 6, 0), (22, 1, 0)])
'removed in 9.6.0'
Source code in idfkit/versions.py
find_closest_version(version)
¶
Find the supported version to use for a version read from a file.
A release line is matched before a version number is. An IDF file writes its
version with two components, Version, 9.0;, which arrives here as
(9, 0, 0), so an exact match fails on the patch component for any release
whose patch is not zero. Matching on major and minor first, and taking the
highest patch in that line, is what makes a two-component header resolve to
the release it names.
Crossing a minor boundary is not a fallback, it is a different EnergyPlus
release. Ten object types reorder their fields between 8.9.0 and 9.0.1 alone,
RunPeriod and GlazedDoor among them, and IDF is positional: reading a
9.0 file against the 8.9.0 schema does not fail, it loads begin_year into
end_month and succeeds against a corrupted model. Only a version newer
than every supported release degrades to the newest one, which is a forward
tolerance the compatibility checker relies on and which never silently
reinterprets a release that exists.
Returns:
| Type | Description |
|---|---|
tuple[int, int, int] | None
|
The supported version to use, or None if no suitable version exists. |
Examples:
>>> find_closest_version((24, 1, 5))
(24, 1, 0)
>>> find_closest_version((9, 0, 0))
(9, 0, 1)
>>> find_closest_version((1, 0, 0)) is None
True
>>> find_closest_version((10, 0, 0)) is None
True
Source code in idfkit/versions.py
find_release(version)
¶
Find the supported release a version names, without any fallback.
This is the release-line half of find_closest_version: the version
itself when it is a supported release, else the highest supported release of
the same major and minor (a file headed Version, 9.0; reads as
(9, 0, 0) and names the 9.0.1 release). Unlike
find_closest_version, a version newer than every supported release is
not snapped to the latest one, which is what a migration source needs: a
model of a release idfkit does not know cannot be migrated from a neighbour.
Returns:
| Type | Description |
|---|---|
tuple[int, int, int] | None
|
The supported release, or None if no release of that line is supported. |
Examples:
>>> find_release((9, 0, 0))
(9, 0, 1)
>>> find_release((24, 1, 0))
(24, 1, 0)
>>> find_release((27, 1, 0)) is None
True
>>> find_release((8, 8, 0)) is None
True
Source code in idfkit/versions.py
format_releases(releases)
¶
releases, oldest first, with each run of three or more consecutive supported releases as a range.
Consecutive means adjacent in ENERGYPLUS_VERSIONS, not in the list given, so
a range never covers a release that was not checked: 8.9.0 to 9.5.0 names seven releases, and
8.9.0, 9.5.0 the two of a run of targets that skipped the ones between.
Examples:
Source code in idfkit/versions.py
github_release_tag(version)
¶
Return the GitHub release tag for a version.
Examples:
Source code in idfkit/versions.py
is_supported_version(version)
¶
Check if a version is in the supported set.
Examples:
>>> is_supported_version((24, 1, 0))
True
>>> is_supported_version((99, 0, 0))
False
>>> is_supported_version(MINIMUM_VERSION)
True
Raises:
| Type | Description |
|---|---|
TypeError
|
If version is a string such as |
Source code in idfkit/versions.py
not_in_release_message(obj_type, version)
¶
Why obj_type is missing from version, when another bundled release has it, else None.
Names the releases that have the type and, where a later release has it, how to get there:
migrate a model, or create one at that release. The wording names no document, since a schema
lookup (describe_object_type) raises it too.
Examples:
>>> msg = not_in_release_message("Lights:Definition", (26, 1, 0))
>>> msg.splitlines()[0] if msg else None
"'Lights:Definition' is not an object type of EnergyPlus 26.1.0: it was added in 26.2.0."
>>> not_in_release_message("Zone", (26, 1, 0)) is None
True
Source code in idfkit/versions.py
object_type_releases(obj_type)
¶
The bundled releases that have obj_type, matched case-insensitively, oldest first.
Empty when no bundled release has it. Answered from a generated table, without loading a schema.
Examples:
Source code in idfkit/versions.py
reject_version_string(version)
¶
Raise TypeError if version is a string such as "26.1", naming the tuple to pass instead.
The version arguments of the core API (new_document, get_schema, load_idf and the
helpers here) take a (major, minor, patch) tuple. A string used to be read as a sequence of
characters, which reported the version as 2.6.., failed comparing str with tuple,
or answered False.
Raises:
| Type | Description |
|---|---|
TypeError
|
If version is a string. |
Examples:
>>> reject_version_string((24, 1, 0))
>>> reject_version_string("26.1")
Traceback (most recent call last):
...
TypeError: version must be a (major, minor, patch) tuple, e.g. (26, 1, 0); got '26.1'
Source code in idfkit/versions.py
releases_between(since, before)
¶
Every supported release from since (inclusive) to before (exclusive).
This is the range as_version(doc, since=..., before=...) accepts, and the one
idfkit check reads statically; either bound may be None for an open end.
Examples:
Source code in idfkit/versions.py
version_dirname(version)
¶
Return the schema directory name for a version.
Examples:
Source code in idfkit/versions.py
version_string(version)
¶
Format a version tuple as a human-readable string.
Examples: