Skip to content

Commit ba142f6

Browse files
committed
chore: remove none
1 parent 504b923 commit ba142f6

15 files changed

Lines changed: 40 additions & 122 deletions

File tree

src/libecalc/common/list/list_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def elementwise_multiplication(*vectors: Sequence[float | None], periods: Period
110110

111111
def array_to_list(
112112
result_array: NDArray[np.float64] | NDArray[np.bool_] | list[NDArray[np.float64]] | None,
113-
) -> list[float | None] | None:
113+
) -> list[float] | None:
114114
"""Method to convert numpy arrays and list of numpy arrays into lists (or list of lists). Method is used recursively on lists so needs to handle None as well.
115115
116116
Args:
@@ -130,7 +130,7 @@ def array_to_list(
130130
elif isinstance(result_array, np.ndarray):
131131
if result_array.shape == (): # Handle 0D array (scalar)
132132
return [result_array.item()]
133-
return cast(list[float | None], result_array.tolist())
133+
return cast(list[float], result_array.tolist())
134134
else:
135135
# Unexpected type, log a warning and return an empty list)
136136
logger.warning(f"array_to_list received unexpected type: {type(result_array)}. Returning empty list.")

src/libecalc/core/result/results.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ def __init__(
173173
energy_usage: TimeSeriesStreamDayRate,
174174
power: TimeSeriesStreamDayRate | None,
175175
name: str,
176-
inlet_liquid_rate_m3_per_day: list[float | None],
177-
inlet_pressure_bar: list[float | None],
178-
outlet_pressure_bar: list[float | None],
179-
operational_head: list[float | None],
176+
inlet_liquid_rate_m3_per_day: list[float],
177+
inlet_pressure_bar: list[float],
178+
outlet_pressure_bar: list[float],
179+
operational_head: list[float],
180180
):
181181
super().__init__(periods=periods, is_valid=is_valid, energy_usage=energy_usage, power=power)
182182
self.name = name
@@ -198,8 +198,8 @@ def __init__(
198198
energy_usage: TimeSeriesStreamDayRate,
199199
power: TimeSeriesStreamDayRate | None,
200200
name: str,
201-
rate_sm3_day: list[float | None] | list[list[float | None]],
202-
max_standard_rate: list[float | None] | list[list[float | None]] | None,
201+
rate_sm3_day: list[float] | list[list[float]],
202+
max_standard_rate: list[float] | list[list[float]] | None,
203203
stage_results: list[CompressorStageResult],
204204
failure_status: list[CompressorTrainCommonShaftFailureStatus | None],
205205
turbine_result: TurbineResult | None,

src/libecalc/domain/infrastructure/energy_components/legacy_consumer/system/results.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, name: str, consumer_model_result: PumpModelResult | Compresso
2727
self.consumer_model_result = consumer_model_result
2828

2929
@property
30-
def energy_usage(self) -> list[float | None]:
30+
def energy_usage(self) -> list[float]:
3131
return self.consumer_model_result.energy_usage
3232

3333
@property
@@ -38,7 +38,7 @@ def power(self) -> NDArray:
3838
return np.zeros_like(self.consumer_model_result.energy_usage)
3939

4040
@property
41-
def rate(self) -> list[float | None]:
41+
def rate(self) -> list[float]:
4242
return self.consumer_model_result.rate
4343

4444

src/libecalc/domain/process/compressor/core/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def _calculate_remaining_capacity_in_train_given_standard_rate(
139139
result = self.compressor_model.evaluate()
140140
if result.power is None or len(result.power) == 0:
141141
return 0.0 # Return 0 if no power value available
142-
return float(result.power[0]) - (max_power - POWER_CALCULATION_TOLERANCE) # type: ignore[arg-type]
142+
return float(result.power[0]) - (max_power - POWER_CALCULATION_TOLERANCE)
143143

144144
def get_max_standard_rate(
145145
self, suction_pressures: NDArray[np.float64], discharge_pressures: NDArray[np.float64]

src/libecalc/domain/process/core/results/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ class EnergyFunctionResult(EnergyModelBaseResult):
5656

5757
def __init__(
5858
self,
59-
energy_usage: list[float | None],
59+
energy_usage: list[float],
6060
energy_usage_unit: Unit,
61-
power: list[float | None] | None = None,
61+
power: list[float] | None = None,
6262
power_unit: Unit | None = Unit.MEGA_WATT,
6363
**kwargs,
6464
):
@@ -73,7 +73,7 @@ def is_valid(self) -> list[bool]:
7373
"""We assume that all non-NaN results are valid calculation points except for a few exceptions where we override
7474
this method.
7575
"""
76-
return list(~np.isnan(self.energy_usage)) # type: ignore[arg-type]
76+
return list(~np.isnan(self.energy_usage))
7777

7878
@property
7979
def len(self) -> int:

src/libecalc/domain/process/core/results/compressor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ class CompressorTrainResult(EnergyFunctionResult):
182182

183183
def __init__(
184184
self,
185-
rate_sm3_day: Sequence[float | None] | list[list[float | None]],
186-
max_standard_rate: Sequence[float | None] | list[list[float | None]] | None = None,
185+
rate_sm3_day: Sequence[float | None] | list[list[float]],
186+
max_standard_rate: Sequence[float | None] | list[list[float]] | None = None,
187187
inlet_stream_condition: CompressorStreamCondition = None,
188188
outlet_stream_condition: CompressorStreamCondition = None,
189189
stage_results: Sequence[CompressorStageResult] = None,
@@ -257,7 +257,7 @@ def log_lost_result_data(attr: str) -> None:
257257
return self
258258

259259
@property
260-
def rate(self) -> list[float | None]:
260+
def rate(self) -> list[float]:
261261
return self.rate_sm3_day
262262

263263
@property

src/libecalc/domain/process/core/results/pump.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55

66
class PumpModelResult(EnergyFunctionResult):
7-
rate: list[float | None]
8-
suction_pressure: list[float | None]
9-
discharge_pressure: list[float | None]
10-
fluid_density: list[float | None]
11-
operational_head: list[float | None]
7+
rate: list[float]
8+
suction_pressure: list[float]
9+
discharge_pressure: list[float]
10+
fluid_density: list[float]
11+
operational_head: list[float]

src/libecalc/domain/process/core/results/turbine.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88

99
class TurbineResult(EnergyFunctionResult):
10-
load: list[float | None] # MW
11-
efficiency: list[float | None] # % Fraction between 0 and 1
12-
fuel_rate: list[float | None] # Sm3/day?
10+
load: list[float] # MW
11+
efficiency: list[float] # % Fraction between 0 and 1
12+
fuel_rate: list[float] # Sm3/day?
1313

14-
power: list[float | None]
14+
power: list[float]
1515
power_unit: Unit
1616

1717
exceeds_maximum_load: list[bool]

src/libecalc/domain/time_series_flow_rate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TimeSeriesFlowRate(ABC):
1313
"""
1414

1515
@abstractmethod
16-
def get_stream_day_values(self) -> list[float | None]:
16+
def get_stream_day_values(self) -> list[float]:
1717
"""
1818
Returns the evaluated flow rate values for each stream day.
1919
"""

src/libecalc/domain/time_series_power.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TimeSeriesPower(ABC):
1313
"""
1414

1515
@abstractmethod
16-
def get_stream_day_values(self) -> list[float | None]:
16+
def get_stream_day_values(self) -> list[float]:
1717
"""
1818
Returns the evaluated power values for each stream day.
1919
"""

0 commit comments

Comments
 (0)