Skip to content

Commit 8323b27

Browse files
authored
Fix/409 bug error handling in investparameterslinked periods (#415)
* Add early check for non existant periods with linked periods as a tuple used * Add extra except phrase to version handling in init
1 parent c72357e commit 8323b27

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

flixopt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
try:
99
__version__ = version('flixopt')
10-
except PackageNotFoundError:
10+
except (PackageNotFoundError, TypeError):
1111
# Package is not installed (development mode without editable install)
1212
__version__ = '0.0.0.dev0'
1313

flixopt/interface.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,11 @@ def transform_data(self, flow_system: FlowSystem, name_prefix: str = '') -> None
963963
raise TypeError(
964964
f'If you provide a tuple to "linked_periods", it needs to be len=2. Got {len(self.linked_periods)=}'
965965
)
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+
)
966971
logger.debug(f'Computing linked_periods from {self.linked_periods}')
967972
start, end = self.linked_periods
968973
if start not in flow_system.periods.values:

0 commit comments

Comments
 (0)