From 5a4021d2cb31141723f3b963b57bae6373e202dd Mon Sep 17 00:00:00 2001 From: Jostein Solaas <33114722+jsolaas@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:03:44 +0100 Subject: [PATCH] chore: remove unused method (#357) --- .../consumer_function/results.py | 10 +--- .../consumer_function/utils.py | 55 ------------------- 2 files changed, 1 insertion(+), 64 deletions(-) diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function/results.py b/src/libecalc/core/consumers/legacy_consumer/consumer_function/results.py index d87528b540..e715eeedb4 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function/results.py +++ b/src/libecalc/core/consumers/legacy_consumer/consumer_function/results.py @@ -2,7 +2,7 @@ from abc import abstractmethod from enum import Enum -from typing import List, Literal, NamedTuple, Optional, Union +from typing import List, Literal, Optional, Union import numpy as np from numpy.typing import NDArray @@ -15,14 +15,6 @@ from libecalc.core.models.results.base import EnergyFunctionResult -class ConditionsAndPowerLossResult(NamedTuple): - condition: NDArray[np.float64] - power_loss_factor: NDArray[np.float64] - energy_usage_after_condition_before_power_loss_factor: NDArray[np.float64] - resulting_energy_usage: NDArray[np.float64] - resulting_power_usage: Optional[NDArray[np.float64]] - - class ConsumerFunctionResultBase(BaseModel): """Result object for ConsumerFunction. diff --git a/src/libecalc/core/consumers/legacy_consumer/consumer_function/utils.py b/src/libecalc/core/consumers/legacy_consumer/consumer_function/utils.py index 770d888b8b..c86920e2d8 100644 --- a/src/libecalc/core/consumers/legacy_consumer/consumer_function/utils.py +++ b/src/libecalc/core/consumers/legacy_consumer/consumer_function/utils.py @@ -4,65 +4,10 @@ import numpy as np from numpy.typing import NDArray -from libecalc.core.consumers.legacy_consumer.consumer_function.results import ( - ConditionsAndPowerLossResult, -) from libecalc.dto import VariablesMap from libecalc.expression import Expression -def calculate_energy_usage_with_conditions_and_power_loss( - variables_map: VariablesMap, - energy_usage: NDArray[np.float64], - condition_expression: Expression, - power_loss_factor_expression: Expression, - power_usage: Optional[NDArray[np.float64]] = None, -) -> ConditionsAndPowerLossResult: - condition = get_condition_from_expression( - variables_map=variables_map, - condition_expression=condition_expression, - ) - energy_usage_after_condition_before_power_loss_factor = ( - energy_usage * condition if condition is not None else deepcopy(energy_usage) - ) - power_usage_after_condition_before_power_loss_factor = ( - (power_usage * condition if condition is not None else deepcopy(power_usage)) - if power_usage is not None - else None - ) - - # Apply power loss factor - power_loss_factor = ( - power_loss_factor_expression.evaluate( - variables=variables_map.variables, fill_length=len(variables_map.time_vector) - ) - if power_loss_factor_expression is not None - else None - ) - # Set final energy usage to energy usage after conditioning and power loss factor - resulting_energy_usage = apply_power_loss_factor( - energy_usage=energy_usage_after_condition_before_power_loss_factor, - power_loss_factor=power_loss_factor, - ) - - resulting_power_usage = ( - apply_power_loss_factor( - energy_usage=power_usage_after_condition_before_power_loss_factor, - power_loss_factor=power_loss_factor, - ) - if power_usage_after_condition_before_power_loss_factor is not None - else None - ) - - return ConditionsAndPowerLossResult( - condition=condition, - power_loss_factor=power_loss_factor, - energy_usage_after_condition_before_power_loss_factor=energy_usage_after_condition_before_power_loss_factor, - resulting_energy_usage=resulting_energy_usage, - resulting_power_usage=resulting_power_usage, - ) - - def get_condition_from_expression( variables_map: VariablesMap, condition_expression: Expression,