From 43d4b98bc5ba2327f8f88e5e545e892adc2b32ae Mon Sep 17 00:00:00 2001 From: siufai6 Date: Thu, 3 Aug 2023 16:04:18 +0100 Subject: [PATCH] Update lib.py to fix #901 Heatmap plots requires at least two parameters (variables) in the heatmap Series. Add an assert before calling _plot_heatmap to guard against the case of having only 1 variable. --- backtesting/lib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backtesting/lib.py b/backtesting/lib.py index 14c01efd..2da6f6c9 100644 --- a/backtesting/lib.py +++ b/backtesting/lib.py @@ -138,6 +138,7 @@ def plot_heatmaps(heatmap: pd.Series, [plot_objective]: \ https://scikit-optimize.github.io/stable/modules/plots.html#plot-objective """ + assert heatmap.index.nlevels >= 2, "Heatmap plots requires at least 2 optimized parameters." return _plot_heatmaps(heatmap, agg, ncols, filename, plot_width, open_browser)