Skip to content

Commit 169e402

Browse files
committed
fix undefined behavior for string as timeseries
parameter in Network.gui()
1 parent e707720 commit 169e402

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

disstans/network.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,7 +2621,7 @@ def graphical_cme(self,
26212621

26222622
def gui(self,
26232623
station: str | None = None,
2624-
timeseries: list[str] | None = None,
2624+
timeseries: str | list[str] | None = None,
26252625
fit_list: list[str] | None = None,
26262626
sum_models: bool = True,
26272627
verbose: bool = False,
@@ -2670,7 +2670,7 @@ def gui(self,
26702670
station
26712671
Pre-select a station.
26722672
timeseries
2673-
List of strings with the descriptions of the timeseries to plot.
2673+
String or list of strings with the descriptions of the timeseries to plot.
26742674
``None`` defaults to all timeseries.
26752675
fit_list
26762676
List of strings containing the model names of the subset of the models
@@ -2758,6 +2758,15 @@ def gui(self,
27582758
gui_kw_args
27592759
Override default GUI settings of :attr:`~disstans.config.defaults`.
27602760
"""
2761+
2762+
# check the timeseries setting
2763+
if isinstance(timeseries, str):
2764+
timeseries = [timeseries]
2765+
else:
2766+
assert (timeseries is None) or (isinstance(timeseries, list) and
2767+
all([isinstance(t, str) for t in timeseries])), \
2768+
f"'timeseries' must be None, a string, or list of strings, got '{timeseries}'."
2769+
27612770
# create map and timeseries figures
27622771
gui_settings = defaults["gui"].copy()
27632772
gui_settings.update(gui_kw_args)

0 commit comments

Comments
 (0)