-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RCT/YJ/get_swh_uses_associated_with_each_building_segment #1500
Merged
yunjoonjung-PNNL
merged 3 commits into
develop
from
RCT/YJ/get_swh_uses_associated_with_each_building_segment
Aug 20, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...ets/ashrae9012019/ruleset_functions/get_swh_uses_associated_with_each_building_segment.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from rct229.utils.jsonpath_utils import find_all | ||
|
||
|
||
def get_swh_uses_associated_with_each_building_segment( | ||
rmd: dict, building_segment_id: str | ||
) -> list[str]: | ||
""" | ||
This function gets all the SWH uses connected to a building segment or an empty list if no service water heating uses are found in the building segment. This function is primarily to encapsulate getting service water heating uses in one function so that if a change is made in the schema as to how service water heating use is specified, | ||
the RCT only needs to change in one place . | ||
|
||
Parameters | ||
---------- | ||
rmd: dict | ||
RMD at RuleSetModelDescription level | ||
building_segment_id: str | ||
building segment id | ||
|
||
Returns | ||
------- | ||
swh_uses_list: list | ||
A list containing the ids of all service water heating uses associated with a building segment | ||
""" | ||
|
||
swh_uses_list = find_all( | ||
f'$.buildings[*].building_segments[*][?(@.id="{building_segment_id}")].zones[*].spaces[*].service_water_heating_uses[*].id', | ||
rmd, | ||
) | ||
return swh_uses_list |
65 changes: 65 additions & 0 deletions
65
...shrae9012019/ruleset_functions/get_swh_uses_associated_with_each_building_segment_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from rct229.rulesets.ashrae9012019.ruleset_functions.get_swh_uses_associated_with_each_building_segment import ( | ||
get_swh_uses_associated_with_each_building_segment, | ||
) | ||
from rct229.schema.schema_utils import quantify_rmd | ||
from rct229.schema.validate import schema_validate_rmd | ||
|
||
TEST_RMD = { | ||
"id": "test_rmd", | ||
"buildings": [ | ||
{ | ||
"id": "Building 1", | ||
"building_open_schedule": "Required Building Schedule 1", | ||
"building_segments": [ | ||
{ | ||
"id": "Building Segment 1", | ||
"zones": [ | ||
{ | ||
"id": "Zone 1", | ||
"spaces": [ | ||
{ | ||
"id": "Space 1", | ||
"service_water_heating_uses": [ | ||
{"id": "service water heating uses 1"}, | ||
{"id": "service water heating uses 2"}, | ||
], | ||
}, | ||
], | ||
} | ||
], | ||
} | ||
], | ||
} | ||
], | ||
"type": "BASELINE_0", | ||
} | ||
|
||
TEST_RPD_FULL = { | ||
"id": "229", | ||
"ruleset_model_descriptions": [TEST_RMD], | ||
"data_timestamp": "2024-02-12T09:00Z", | ||
} | ||
|
||
TEST_RMD = quantify_rmd(TEST_RPD_FULL)["ruleset_model_descriptions"][0] | ||
|
||
|
||
def test__TEST_RPD__is_valid(): | ||
schema_validation_result = schema_validate_rmd(TEST_RPD_FULL) | ||
assert schema_validation_result[ | ||
"passed" | ||
], f"Schema error: {schema_validation_result['error']}" | ||
|
||
|
||
def test__get_swh_uses_associated_with_each_building_segment__bldg_segment_ids_exist(): | ||
assert get_swh_uses_associated_with_each_building_segment( | ||
TEST_RMD, "Building Segment 1" | ||
) == ["service water heating uses 1", "service water heating uses 2"] | ||
|
||
|
||
def test__get_swh_uses_associated_with_each_building_segment__bldg_segment_id_not_exist(): | ||
assert ( | ||
get_swh_uses_associated_with_each_building_segment( | ||
TEST_RMD, "Building Segment 2" | ||
) | ||
== [] | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add additional to include extreme case
or an empty list if no service water heating uses are found in the building segment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.