Skip to content

Commit cb58822

Browse files
committed
REF: Improve unclear traceback on plot_heaymap()
Fixes #901
1 parent 48b656b commit cb58822

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

backtesting/_plotting.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,9 @@ def plot_heatmaps(heatmap: pd.Series, agg: Union[Callable, str], ncols: int,
675675
isinstance(heatmap.index, pd.MultiIndex)):
676676
raise ValueError('heatmap must be heatmap Series as returned by '
677677
'`Backtest.optimize(..., return_heatmap=True)`')
678+
if len(heatmap.index.levels) < 2:
679+
raise ValueError('`plot_heatmap()` requires at least two optimization '
680+
'variables to plot')
678681

679682
_bokeh_reset(filename)
680683

0 commit comments

Comments
 (0)