From f0d0657f7dee6dd404e29129ab735108b25b0f12 Mon Sep 17 00:00:00 2001 From: stemgene <35020077+stemgene@users.noreply.github.com> Date: Wed, 13 Nov 2024 01:38:07 +0000 Subject: [PATCH] rename `BillingPeriod` to `ProcessedBill` --- python/src/rules_engine/engine.py | 14 ++++---- python/tests/test_rules_engine/test_engine.py | 32 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/python/src/rules_engine/engine.py b/python/src/rules_engine/engine.py index cc9cfbd1..3ad2514d 100644 --- a/python/src/rules_engine/engine.py +++ b/python/src/rules_engine/engine.py @@ -163,7 +163,7 @@ def convert_to_intermediate_billing_periods( temperature_input: TemperatureInput, billing_periods: list[NormalizedBillingPeriodRecordBase], fuel_type: FuelType, -) -> list[BillingPeriod]: +) -> list[ProcessedBill]: """ Converts temperature data and billing period inputs into internal classes used for heat loss calculations. @@ -195,7 +195,7 @@ def convert_to_intermediate_billing_periods( else: raise ValueError("Unsupported fuel type.") - intermediate_billing_period = BillingPeriod( + intermediate_billing_period = ProcessedBill( input=billing_period, avg_temps=temperature_input.temperatures[start_idx:end_idx], usage=billing_period.usage, @@ -402,7 +402,7 @@ class Home: def __init__( self, summary_input: SummaryInput, - billing_periods: list[BillingPeriod], + billing_periods: list[ProcessedBill], dhw_input: Optional[DhwInput], initial_balance_point: float = 60, ): @@ -413,7 +413,7 @@ def __init__( self.dhw_input = dhw_input self._initialize_billing_periods(billing_periods) - def _initialize_billing_periods(self, billing_periods: list[BillingPeriod]) -> None: + def _initialize_billing_periods(self, billing_periods: list[ProcessedBill]) -> None: self.bills_winter = [] self.bills_summer = [] self.bills_shoulder = [] @@ -641,7 +641,7 @@ def calculate( next_balance_point_sensitivity, ) - def initialize_ua(self, billing_period: BillingPeriod) -> None: + def initialize_ua(self, billing_period: ProcessedBill) -> None: """ Average heating usage, partial UA, initial UA. requires that self.home have non heating usage calculated. @@ -652,7 +652,7 @@ def initialize_ua(self, billing_period: BillingPeriod) -> None: billing_period.partial_ua = self.calculate_partial_ua(billing_period) billing_period.ua = billing_period.partial_ua / billing_period.total_hdd - def calculate_partial_ua(self, billing_period: BillingPeriod) -> float: + def calculate_partial_ua(self, billing_period: ProcessedBill) -> float: """ The portion of UA that is not dependent on the balance point """ @@ -667,7 +667,7 @@ def calculate_partial_ua(self, billing_period: BillingPeriod) -> float: ) -class BillingPeriod: +class ProcessedBill: """ An internal class storing data whence heating usage per billing period is calculated. diff --git a/python/tests/test_rules_engine/test_engine.py b/python/tests/test_rules_engine/test_engine.py index 40ca3346..ca63f742 100644 --- a/python/tests/test_rules_engine/test_engine.py +++ b/python/tests/test_rules_engine/test_engine.py @@ -26,9 +26,9 @@ @pytest.fixture() -def sample_billing_periods() -> list[engine.BillingPeriod]: +def sample_billing_periods() -> list[engine.ProcessedBill]: billing_periods = [ - engine.BillingPeriod( + engine.ProcessedBill( dummy_billing_period_record, [28, 29, 30, 29], 50, @@ -36,7 +36,7 @@ def sample_billing_periods() -> list[engine.BillingPeriod]: True, False, ), - engine.BillingPeriod( + engine.ProcessedBill( dummy_billing_period_record, [32, 35, 35, 38], 45, @@ -44,7 +44,7 @@ def sample_billing_periods() -> list[engine.BillingPeriod]: True, False, ), - engine.BillingPeriod( + engine.ProcessedBill( dummy_billing_period_record, [41, 43, 42, 42], 30, @@ -52,7 +52,7 @@ def sample_billing_periods() -> list[engine.BillingPeriod]: True, False, ), - engine.BillingPeriod( + engine.ProcessedBill( dummy_billing_period_record, [72, 71, 70, 69], 0.96, @@ -65,9 +65,9 @@ def sample_billing_periods() -> list[engine.BillingPeriod]: @pytest.fixture() -def sample_billing_periods_with_outlier() -> list[engine.BillingPeriod]: +def sample_billing_periods_with_outlier() -> list[engine.ProcessedBill]: billing_periods = [ - engine.BillingPeriod( + engine.ProcessedBill( dummy_billing_period_record, [41.7, 41.6, 32, 25.4], 60, @@ -75,7 +75,7 @@ def sample_billing_periods_with_outlier() -> list[engine.BillingPeriod]: True, False, ), - engine.BillingPeriod( + engine.ProcessedBill( dummy_billing_period_record, [28, 29, 30, 29], 50, @@ -83,7 +83,7 @@ def sample_billing_periods_with_outlier() -> list[engine.BillingPeriod]: True, False, ), - engine.BillingPeriod( + engine.ProcessedBill( dummy_billing_period_record, [32, 35, 35, 38], 45, @@ -91,7 +91,7 @@ def sample_billing_periods_with_outlier() -> list[engine.BillingPeriod]: True, False, ), - engine.BillingPeriod( + engine.ProcessedBill( dummy_billing_period_record, [41, 43, 42, 42], 30, @@ -99,7 +99,7 @@ def sample_billing_periods_with_outlier() -> list[engine.BillingPeriod]: True, False, ), - engine.BillingPeriod( + engine.ProcessedBill( dummy_billing_period_record, [72, 71, 70, 69], 0.96, @@ -363,7 +363,7 @@ def test_convert_to_intermediate_billing_periods( ) expected_results = [ - engine.BillingPeriod( + engine.ProcessedBill( dummy_billing_period_record, [41.7, 41.6, 32, 25.4], 60, @@ -371,7 +371,7 @@ def test_convert_to_intermediate_billing_periods( False, False, ), - engine.BillingPeriod( + engine.ProcessedBill( dummy_billing_period_record, [28, 29, 30, 29], 50, @@ -379,7 +379,7 @@ def test_convert_to_intermediate_billing_periods( False, False, ), - engine.BillingPeriod( + engine.ProcessedBill( dummy_billing_period_record, [32, 35, 35, 38], 45, @@ -387,7 +387,7 @@ def test_convert_to_intermediate_billing_periods( False, False, ), - engine.BillingPeriod( + engine.ProcessedBill( dummy_billing_period_record, [41, 43, 42, 42], 30, @@ -395,7 +395,7 @@ def test_convert_to_intermediate_billing_periods( False, False, ), - engine.BillingPeriod( + engine.ProcessedBill( dummy_billing_period_record, [72, 71, 70, 69], 0.96,