diff --git a/python/setup-python.sh b/python/setup-python.sh new file mode 100755 index 00000000..72f54326 --- /dev/null +++ b/python/setup-python.sh @@ -0,0 +1,4 @@ +python -m venv .venv +source .venv/bin/activate +pip install -e . +pip install -r requirements-dev.txt \ No newline at end of file diff --git a/python/src/rules_engine/engine.py b/python/src/rules_engine/engine.py index d8d5e149..8900cbd5 100644 --- a/python/src/rules_engine/engine.py +++ b/python/src/rules_engine/engine.py @@ -162,7 +162,7 @@ def convert_to_intermediate_billing_periods( temperature_input: TemperatureInput, billing_periods: list[ProcessedEnergyBillInput], fuel_type: FuelType, -) -> list[ProcessedEnergyBillIntermediate]: +) -> list[IntermediateProcessedEnergyBill]: """ Converts temperature data and billing period inputs into internal classes used for heat loss calculations. @@ -194,7 +194,7 @@ def convert_to_intermediate_billing_periods( else: raise ValueError("Unsupported fuel type.") - intermediate_billing_period = ProcessedEnergyBillIntermediate( + intermediate_billing_period = IntermediateProcessedEnergyBill( input=billing_period, avg_temps=temperature_input.temperatures[start_idx:end_idx], usage=billing_period.usage, @@ -401,7 +401,7 @@ class Home: def _init( self, heat_load_input: HeatLoadInput, - billing_periods: list[ProcessedEnergyBillIntermediate], + billing_periods: list[IntermediateProcessedEnergyBill], dhw_input: Optional[DhwInput], initial_balance_point: float = 60, ) -> None: @@ -413,7 +413,7 @@ def _init( self._initialize_billing_periods(billing_periods) def _initialize_billing_periods( - self, billing_periods: list[ProcessedEnergyBillIntermediate] + self, billing_periods: list[IntermediateProcessedEnergyBill] ) -> None: self.bills_winter = [] self.bills_summer = [] @@ -626,7 +626,7 @@ def _refine_balance_point(self, balance_point_sensitivity: float) -> None: def calculate( cls, heat_load_input: HeatLoadInput, - billing_periods: list[ProcessedEnergyBillIntermediate], + billing_periods: list[IntermediateProcessedEnergyBill], dhw_input: Optional[DhwInput], initial_balance_point: float = 60, initial_balance_point_sensitivity: float = 0.5, @@ -656,7 +656,7 @@ def calculate( return home_instance - def initialize_ua(self, billing_period: ProcessedEnergyBillIntermediate) -> None: + def initialize_ua(self, billing_period: IntermediateProcessedEnergyBill) -> None: """ Average heating usage, partial UA, initial UA. requires that self.home have non heating usage calculated. @@ -668,7 +668,7 @@ def initialize_ua(self, billing_period: ProcessedEnergyBillIntermediate) -> None billing_period.ua = billing_period.partial_ua / billing_period.total_hdd def calculate_partial_ua( - self, billing_period: ProcessedEnergyBillIntermediate + self, billing_period: IntermediateProcessedEnergyBill ) -> float: """ The portion of UA that is not dependent on the balance point @@ -684,7 +684,7 @@ def calculate_partial_ua( ) -class ProcessedEnergyBillIntermediate: +class IntermediateProcessedEnergyBill: """ An internal class storing data whence heating usage per billing period is calculated. diff --git a/python/src/rules_engine/refactor.md b/python/src/rules_engine/refactor.md index b487523d..037b5296 100644 --- a/python/src/rules_engine/refactor.md +++ b/python/src/rules_engine/refactor.md @@ -13,7 +13,7 @@ home variables used 1. Remove temporary_rules_engine.py 2. Rename rules-engine to "python" 3. Rename NormalizedBillingRecordBase class to BillingInput -4. Rename BillingPeriod to ProcessedEnergyBillIntermediate and billing_period to processed_energy_bill_intermediate +4. Rename BillingPeriod to IntermediateProcessedEnergyBill and billing_period to processed_energy_bill_intermediate 5. Combine get_outputs_normalized and convert_to_intermediate_billing_record and get rid of NormalizedBillingRecord. There is only one place NormalizedBillingRecord is used and combining code gets rid of the need for the class. - Change @@ -55,7 +55,7 @@ to inputBill.start_date, inputBill.end_date ) - processedBill = ProcessedEnergyBillIntermediate( + processedBill = IntermediateProcessedEnergyBill( input = inputBill, avg_temps = avg_temps, default_analysis_type = default_analysis_type diff --git a/python/tests/test_rules_engine/test_engine.py b/python/tests/test_rules_engine/test_engine.py index ffaff670..6c542528 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.ProcessedEnergyBillIntermediate]: +def sample_billing_periods() -> list[engine.IntermediateProcessedEnergyBill]: billing_periods = [ - engine.ProcessedEnergyBillIntermediate( + engine.IntermediateProcessedEnergyBill( dummy_billing_period_record, [28, 29, 30, 29], 50, @@ -36,7 +36,7 @@ def sample_billing_periods() -> list[engine.ProcessedEnergyBillIntermediate]: True, False, ), - engine.ProcessedEnergyBillIntermediate( + engine.IntermediateProcessedEnergyBill( dummy_billing_period_record, [32, 35, 35, 38], 45, @@ -44,7 +44,7 @@ def sample_billing_periods() -> list[engine.ProcessedEnergyBillIntermediate]: True, False, ), - engine.ProcessedEnergyBillIntermediate( + engine.IntermediateProcessedEnergyBill( dummy_billing_period_record, [41, 43, 42, 42], 30, @@ -52,7 +52,7 @@ def sample_billing_periods() -> list[engine.ProcessedEnergyBillIntermediate]: True, False, ), - engine.ProcessedEnergyBillIntermediate( + engine.IntermediateProcessedEnergyBill( dummy_billing_period_record, [72, 71, 70, 69], 0.96, @@ -66,10 +66,10 @@ def sample_billing_periods() -> list[engine.ProcessedEnergyBillIntermediate]: @pytest.fixture() def sample_billing_periods_with_outlier() -> ( - list[engine.ProcessedEnergyBillIntermediate] + list[engine.IntermediateProcessedEnergyBill] ): billing_periods = [ - engine.ProcessedEnergyBillIntermediate( + engine.IntermediateProcessedEnergyBill( dummy_billing_period_record, [41.7, 41.6, 32, 25.4], 60, @@ -77,7 +77,7 @@ def sample_billing_periods_with_outlier() -> ( True, False, ), - engine.ProcessedEnergyBillIntermediate( + engine.IntermediateProcessedEnergyBill( dummy_billing_period_record, [28, 29, 30, 29], 50, @@ -85,7 +85,7 @@ def sample_billing_periods_with_outlier() -> ( True, False, ), - engine.ProcessedEnergyBillIntermediate( + engine.IntermediateProcessedEnergyBill( dummy_billing_period_record, [32, 35, 35, 38], 45, @@ -93,7 +93,7 @@ def sample_billing_periods_with_outlier() -> ( True, False, ), - engine.ProcessedEnergyBillIntermediate( + engine.IntermediateProcessedEnergyBill( dummy_billing_period_record, [41, 43, 42, 42], 30, @@ -101,7 +101,7 @@ def sample_billing_periods_with_outlier() -> ( True, False, ), - engine.ProcessedEnergyBillIntermediate( + engine.IntermediateProcessedEnergyBill( dummy_billing_period_record, [72, 71, 70, 69], 0.96, @@ -361,7 +361,7 @@ def test_convert_to_intermediate_billing_periods( ) expected_results = [ - engine.ProcessedEnergyBillIntermediate( + engine.IntermediateProcessedEnergyBill( dummy_billing_period_record, [41.7, 41.6, 32, 25.4], 60, @@ -369,7 +369,7 @@ def test_convert_to_intermediate_billing_periods( False, False, ), - engine.ProcessedEnergyBillIntermediate( + engine.IntermediateProcessedEnergyBill( dummy_billing_period_record, [28, 29, 30, 29], 50, @@ -377,7 +377,7 @@ def test_convert_to_intermediate_billing_periods( False, False, ), - engine.ProcessedEnergyBillIntermediate( + engine.IntermediateProcessedEnergyBill( dummy_billing_period_record, [32, 35, 35, 38], 45, @@ -385,7 +385,7 @@ def test_convert_to_intermediate_billing_periods( False, False, ), - engine.ProcessedEnergyBillIntermediate( + engine.IntermediateProcessedEnergyBill( dummy_billing_period_record, [41, 43, 42, 42], 30, @@ -393,7 +393,7 @@ def test_convert_to_intermediate_billing_periods( False, False, ), - engine.ProcessedEnergyBillIntermediate( + engine.IntermediateProcessedEnergyBill( dummy_billing_period_record, [72, 71, 70, 69], 0.96,