diff --git a/CHANGELOG.md b/CHANGELOG.md index 591232bfc..833a3f149 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,7 @@ If upgrading from v2.x, see the [v3.0.0 release notes](https://github.com/flixOp ### 📝 Docs ### 👷 Development +- Added type hints for submodel in all Interface classes ### 🚧 Known Issues diff --git a/flixopt/calculation.py b/flixopt/calculation.py index 9d2164e1e..57f42e761 100644 --- a/flixopt/calculation.py +++ b/flixopt/calculation.py @@ -54,6 +54,8 @@ class for defined way of solving a flow_system optimization active_timesteps: Deprecated. Use FlowSystem.sel(time=...) or FlowSystem.isel(time=...) instead. """ + model: FlowSystemModel | None + def __init__( self, name: str, @@ -88,7 +90,7 @@ def __init__( flow_system._used_in_calculation = True self.flow_system = flow_system - self.model: FlowSystemModel | None = None + self.model = None self.durations = {'modeling': 0.0, 'solving': 0.0, 'saving': 0.0} self.folder = pathlib.Path.cwd() / 'results' if folder is None else pathlib.Path(folder) diff --git a/flixopt/components.py b/flixopt/components.py index 09156e1dc..86610c3d2 100644 --- a/flixopt/components.py +++ b/flixopt/components.py @@ -160,6 +160,8 @@ class LinearConverter(Component): """ + submodel: LinearConverterModel | None + def __init__( self, label: str, @@ -376,6 +378,8 @@ class Storage(Component): With flow rates in m3/h, the charge state is therefore in m3. """ + submodel: StorageModel | None + def __init__( self, label: str, @@ -640,6 +644,8 @@ class Transmission(Component): """ + submodel: TransmissionModel | None + def __init__( self, label: str, diff --git a/flixopt/effects.py b/flixopt/effects.py index 6225734fe..f4a20c4dc 100644 --- a/flixopt/effects.py +++ b/flixopt/effects.py @@ -159,6 +159,8 @@ class Effect(Element): """ + submodel: EffectModel | None + def __init__( self, label: str, @@ -453,12 +455,14 @@ class EffectCollection: Handling all Effects """ + submodel: EffectCollectionModel | None + def __init__(self, *effects: Effect): self._effects = {} self._standard_effect: Effect | None = None self._objective_effect: Effect | None = None - self.submodel: EffectCollectionModel | None = None + self.submodel = None self.add_effects(*effects) def create_model(self, model: FlowSystemModel) -> EffectCollectionModel: diff --git a/flixopt/elements.py b/flixopt/elements.py index a0fd306c0..d983d4432 100644 --- a/flixopt/elements.py +++ b/flixopt/elements.py @@ -178,6 +178,8 @@ class Bus(Element): by the FlowSystem during system setup. """ + submodel: BusModel | None + def __init__( self, label: str, @@ -362,6 +364,8 @@ class Flow(Element): """ + submodel: FlowModel | None + def __init__( self, label: str, diff --git a/flixopt/flow_system.py b/flixopt/flow_system.py index ad43c183b..f97fb3603 100644 --- a/flixopt/flow_system.py +++ b/flixopt/flow_system.py @@ -75,6 +75,8 @@ class FlowSystem(Interface): connected_and_transformed automatically when trying to solve a calculation. """ + model: FlowSystemModel | None + def __init__( self, timesteps: pd.DatetimeIndex, diff --git a/flixopt/results.py b/flixopt/results.py index 75f8f300e..018619cb0 100644 --- a/flixopt/results.py +++ b/flixopt/results.py @@ -115,6 +115,8 @@ class CalculationResults: """ + model: linopy.Model | None + @classmethod def from_file(cls, folder: str | pathlib.Path, name: str) -> CalculationResults: """Load CalculationResults from saved files. diff --git a/flixopt/structure.py b/flixopt/structure.py index 07c558eee..8e89feca4 100644 --- a/flixopt/structure.py +++ b/flixopt/structure.py @@ -856,6 +856,8 @@ def __deepcopy__(self, memo): class Element(Interface): """This class is the basic Element of flixopt. Every Element has a label""" + submodel: ElementModel | None + def __init__(self, label: str, meta_data: dict | None = None): """ Args: @@ -864,7 +866,7 @@ def __init__(self, label: str, meta_data: dict | None = None): """ self.label = Element._valid_label(label) self.meta_data = meta_data if meta_data is not None else {} - self.submodel: ElementModel | None = None + self.submodel = None def _plausibility_checks(self) -> None: """This function is used to do some basic plausibility checks for each Element during initialization.