Skip to content

Commit

Permalink
Check for more specific ua column heading and add more descriptive co…
Browse files Browse the repository at this point in the history
…mment.
  • Loading branch information
eriksynn committed May 17, 2024
1 parent 9ca204b commit b88f697
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions rules-engine/tests/test_rules_engine/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
# Each subdirectory contains a JSON file (named summary.json) which specifies the inputs for the test runner
ROOT_DIR = pathlib.Path(__file__).parent / "cases" / "examples"

# TODO: example-2 is OIL; need to find the source data for example-1 and example-4 for Natural Gas
FAILING_EXAMPLES = ("example-1", "example-2", "example-4")
# TODO: example-2 is OIL; need to find the source data for example-1 and example-4 for Natural Gas and update csv
YET_TO_BE_UPDATED_EXAMPLES = ("example-1", "example-2", "example-4")
# Filter out failing examples for now
INPUT_DATA = filter(lambda d: d not in FAILING_EXAMPLES, next(os.walk(ROOT_DIR))[1])
INPUT_DATA = filter(
lambda d: d not in YET_TO_BE_UPDATED_EXAMPLES, next(os.walk(ROOT_DIR))[1]
)


class Summary(SummaryInput, SummaryOutput):
Expand Down Expand Up @@ -72,17 +74,23 @@ def load_natural_gas(

# Choose the correct billing period heat loss (aka "ua") column based on the estimated balance point provided in SummaryOutput
ua_column_name = None
# First we will look for an exact match to the value of estimated balance point
# First we will look for an exact match to the value of the estimated balance point
for column_name in row:
if "ua" in column_name and str(estimated_balance_point) in column_name:
if (
"ua_at_" in column_name
and str(estimated_balance_point) in column_name
):
ua_column_name = column_name
break
# If we don't find that exact match, we round the balance point up to find our match
# It's possible that with further updates to summary data in xls and regen csv files, we wouldn't have this case
if ua_column_name == None:
ua_column_name = (
"ua_at_" + str(int(round(estimated_balance_point, 0))) + "f"
)
ua = row[ua_column_name].replace(",","").strip() # Remove commas and whitespace to cleanup the data
ua = (
row[ua_column_name].replace(",", "").strip()
) # Remove commas and whitespace to cleanup the data
if bool(ua):
whole_home_heat_loss_rate = float(ua)
else:
Expand Down

0 comments on commit b88f697

Please sign in to comment.