flixopt 3.0.3__py3-none-any.whl → 3.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of flixopt might be problematic. Click here for more details.

flixopt/__init__.py CHANGED
@@ -7,7 +7,7 @@ from importlib.metadata import PackageNotFoundError, version
7
7
 
8
8
  try:
9
9
  __version__ = version('flixopt')
10
- except PackageNotFoundError:
10
+ except (PackageNotFoundError, TypeError):
11
11
  # Package is not installed (development mode without editable install)
12
12
  __version__ = '0.0.0.dev0'
13
13
 
flixopt/components.py CHANGED
@@ -1304,16 +1304,18 @@ class Sink(Component):
1304
1304
  prevent_simultaneous_flow_rates: bool = False,
1305
1305
  **kwargs,
1306
1306
  ):
1307
- """
1308
- Initialize a Sink (consumes flow from the system).
1309
-
1310
- Supports legacy `sink=` keyword for backward compatibility (deprecated): if `sink` is provided it is used as the single input flow and a DeprecationWarning is issued; specifying both `inputs` and `sink` raises ValueError.
1311
-
1312
- Parameters:
1313
- label (str): Unique element label.
1314
- inputs (list[Flow], optional): Input flows for the sink.
1315
- meta_data (dict, optional): Arbitrary metadata attached to the element.
1316
- prevent_simultaneous_flow_rates (bool, optional): If True, prevents simultaneous nonzero flow rates across the element's inputs by wiring that restriction into the base Component setup.
1307
+ """Initialize a Sink (consumes flow from the system).
1308
+
1309
+ Supports legacy `sink=` keyword for backward compatibility (deprecated): if `sink` is provided
1310
+ it is used as the single input flow and a DeprecationWarning is issued; specifying both
1311
+ `inputs` and `sink` raises ValueError.
1312
+
1313
+ Args:
1314
+ label: Unique element label.
1315
+ inputs: Input flows for the sink.
1316
+ meta_data: Arbitrary metadata attached to the element.
1317
+ prevent_simultaneous_flow_rates: If True, prevents simultaneous nonzero flow rates
1318
+ across the element's inputs by wiring that restriction into the base Component setup.
1317
1319
 
1318
1320
  Note:
1319
1321
  The deprecated `sink` kwarg is accepted for compatibility but will be removed in future releases.
flixopt/effects.py CHANGED
@@ -480,19 +480,17 @@ class EffectCollection:
480
480
  def create_effect_values_dict(
481
481
  self, effect_values_user: PeriodicEffectsUser | TemporalEffectsUser
482
482
  ) -> dict[str, Scalar | TemporalDataUser] | None:
483
- """
484
- Converts effect values into a dictionary. If a scalar is provided, it is associated with a default effect type.
485
-
486
- Examples
487
- --------
488
- effect_values_user = 20 -> {'<standard_effect_label>': 20}
489
- effect_values_user = {None: 20} -> {'<standard_effect_label>': 20}
490
- effect_values_user = None -> None
491
- effect_values_user = {'effect1': 20, 'effect2': 0.3} -> {'effect1': 20, 'effect2': 0.3}
492
-
493
- Returns
494
- -------
495
- dict or None
483
+ """Converts effect values into a dictionary. If a scalar is provided, it is associated with a default effect type.
484
+
485
+ Examples:
486
+ ```python
487
+ effect_values_user = 20 -> {'<standard_effect_label>': 20}
488
+ effect_values_user = {None: 20} -> {'<standard_effect_label>': 20}
489
+ effect_values_user = None -> None
490
+ effect_values_user = {'effect1': 20, 'effect2': 0.3} -> {'effect1': 20, 'effect2': 0.3}
491
+ ```
492
+
493
+ Returns:
496
494
  A dictionary keyed by effect label, or None if input is None.
497
495
  Note: a standard effect must be defined when passing scalars or None labels.
498
496
  """
flixopt/elements.py CHANGED
@@ -207,6 +207,10 @@ class Bus(Element):
207
207
  logger.warning(
208
208
  f'In Bus {self.label_full}, the excess_penalty_per_flow_hour is 0. Use "None" or a value > 0.'
209
209
  )
210
+ if len(self.inputs) == 0 and len(self.outputs) == 0:
211
+ raise ValueError(
212
+ f'Bus "{self.label_full}" has no Flows connected to it. Please remove it from the FlowSystem'
213
+ )
210
214
 
211
215
  @property
212
216
  def with_excess(self) -> bool:
flixopt/interface.py CHANGED
@@ -963,6 +963,11 @@ class InvestParameters(Interface):
963
963
  raise TypeError(
964
964
  f'If you provide a tuple to "linked_periods", it needs to be len=2. Got {len(self.linked_periods)=}'
965
965
  )
966
+ if flow_system.periods is None:
967
+ raise ValueError(
968
+ f'Cannot use linked_periods={self.linked_periods} when FlowSystem has no periods defined. '
969
+ f'Please define periods in FlowSystem or use linked_periods=None.'
970
+ )
966
971
  logger.debug(f'Computing linked_periods from {self.linked_periods}')
967
972
  start, end = self.linked_periods
968
973
  if start not in flow_system.periods.values: