Skip to content

Commit f77d917

Browse files
authored
refactor: consolidate conditions (#1561)
Refs: equinor/ecalc-internal#1814
1 parent 77e5d7e commit f77d917

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/libecalc/presentation/yaml/mappers/process_simulation_mapper.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,14 @@ def _resolve_fluid_model_reference(self, ref: str | YamlFluidModel) -> YamlFluid
224224
return ref
225225

226226
def _map_conditions(
227-
self, condition: YamlExpressionType | None, conditions: list[YamlExpressionType] | None
227+
self, conditions: YamlExpressionType | list[YamlExpressionType] | None
228228
) -> YamlExpressionType | None:
229-
if condition is not None:
230-
assert isinstance(condition, ExpressionType)
231-
return condition
232-
if conditions is not None:
233-
assert isinstance(conditions, list)
229+
if conditions is None:
230+
return None
231+
if isinstance(conditions, list):
234232
return handle_condition_list(conditions)
235-
return None
233+
assert isinstance(conditions, ExpressionType)
234+
return conditions
236235

237236
def _get_regularity(self) -> Regularity:
238237
return Regularity(
@@ -247,7 +246,9 @@ def _map_rate(
247246
time_series_expression=TimeSeriesExpression(
248247
expression_evaluator=self._expression_evaluator,
249248
expression=yaml_rate.value,
250-
condition=self._map_conditions(yaml_rate.condition, yaml_rate.conditions),
249+
condition=self._map_conditions(
250+
yaml_rate.conditions if yaml_rate.conditions is not None else yaml_rate.condition
251+
),
251252
),
252253
consumption_rate_type=yaml_rate.type,
253254
regularity=self._get_regularity(),

0 commit comments

Comments
 (0)