Skip to content

Commit c562db9

Browse files
committed
add an error for if the custom_palette supplied is a dict but no labels were supplied
1 parent d658e1d commit c562db9

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

dabest/forest_plot.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ def check_for_errors(
177177
# Custom palette
178178
if custom_palette is not None and not isinstance(custom_palette, (dict, list, str, type(None))):
179179
raise TypeError("The `custom_palette` must be either a dictionary, list, string, or `None`.")
180+
if isinstance(custom_palette, dict) and labels is None:
181+
raise ValueError("The `labels` argument must be provided if `custom_palette` is a dictionary.")
180182

181183

182184
# Halfviolin alpha and desat

nbs/API/forest_plot.ipynb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@
236236
" # Custom palette\n",
237237
" if custom_palette is not None and not isinstance(custom_palette, (dict, list, str, type(None))):\n",
238238
" raise TypeError(\"The `custom_palette` must be either a dictionary, list, string, or `None`.\")\n",
239+
" if isinstance(custom_palette, dict) and labels is None:\n",
240+
" raise ValueError(\"The `labels` argument must be provided if `custom_palette` is a dictionary.\")\n",
239241
"\n",
240242
"\n",
241243
" # Halfviolin alpha and desat\n",

0 commit comments

Comments
 (0)