From b88f69734048c514b979e0b81dc6902c5d6daa21 Mon Sep 17 00:00:00 2001 From: eriksynn <159293101+eriksynn@users.noreply.github.com> Date: Fri, 17 May 2024 16:47:12 -0400 Subject: [PATCH] Check for more specific ua column heading and add more descriptive comment. --- .../tests/test_rules_engine/test_examples.py | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/rules-engine/tests/test_rules_engine/test_examples.py b/rules-engine/tests/test_rules_engine/test_examples.py index d1ab50c0..e8331dcc 100644 --- a/rules-engine/tests/test_rules_engine/test_examples.py +++ b/rules-engine/tests/test_rules_engine/test_examples.py @@ -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): @@ -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: