Skip to content

Commit

Permalink
rename BillingPeriod to ProcessedBill
Browse files Browse the repository at this point in the history
  • Loading branch information
stemgene committed Nov 13, 2024
1 parent 6bde273 commit f0d0657
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
14 changes: 7 additions & 7 deletions python/src/rules_engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
):
Expand All @@ -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 = []
Expand Down Expand Up @@ -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.
Expand All @@ -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
"""
Expand All @@ -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.
Expand Down
32 changes: 16 additions & 16 deletions python/tests/test_rules_engine/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,33 @@


@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,
AnalysisType.ALLOWED_HEATING_USAGE,
True,
False,
),
engine.BillingPeriod(
engine.ProcessedBill(
dummy_billing_period_record,
[32, 35, 35, 38],
45,
AnalysisType.ALLOWED_HEATING_USAGE,
True,
False,
),
engine.BillingPeriod(
engine.ProcessedBill(
dummy_billing_period_record,
[41, 43, 42, 42],
30,
AnalysisType.ALLOWED_HEATING_USAGE,
True,
False,
),
engine.BillingPeriod(
engine.ProcessedBill(
dummy_billing_period_record,
[72, 71, 70, 69],
0.96,
Expand All @@ -65,41 +65,41 @@ 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,
AnalysisType.ALLOWED_HEATING_USAGE,
True,
False,
),
engine.BillingPeriod(
engine.ProcessedBill(
dummy_billing_period_record,
[28, 29, 30, 29],
50,
AnalysisType.ALLOWED_HEATING_USAGE,
True,
False,
),
engine.BillingPeriod(
engine.ProcessedBill(
dummy_billing_period_record,
[32, 35, 35, 38],
45,
AnalysisType.ALLOWED_HEATING_USAGE,
True,
False,
),
engine.BillingPeriod(
engine.ProcessedBill(
dummy_billing_period_record,
[41, 43, 42, 42],
30,
AnalysisType.ALLOWED_HEATING_USAGE,
True,
False,
),
engine.BillingPeriod(
engine.ProcessedBill(
dummy_billing_period_record,
[72, 71, 70, 69],
0.96,
Expand Down Expand Up @@ -363,39 +363,39 @@ 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,
AnalysisType.ALLOWED_HEATING_USAGE,
False,
False,
),
engine.BillingPeriod(
engine.ProcessedBill(
dummy_billing_period_record,
[28, 29, 30, 29],
50,
AnalysisType.ALLOWED_HEATING_USAGE,
False,
False,
),
engine.BillingPeriod(
engine.ProcessedBill(
dummy_billing_period_record,
[32, 35, 35, 38],
45,
AnalysisType.ALLOWED_HEATING_USAGE,
False,
False,
),
engine.BillingPeriod(
engine.ProcessedBill(
dummy_billing_period_record,
[41, 43, 42, 42],
30,
AnalysisType.ALLOWED_HEATING_USAGE,
False,
False,
),
engine.BillingPeriod(
engine.ProcessedBill(
dummy_billing_period_record,
[72, 71, 70, 69],
0.96,
Expand Down

0 comments on commit f0d0657

Please sign in to comment.