|
106 | 106 | " contrast_attr = contrast_attr_map.get(contrast_type)\n", |
107 | 107 | "\n", |
108 | 108 | " if not effect_attr:\n", |
109 | | - " raise ValueError(f\"Invalid effect_size: {effect_size}\")\n", |
| 109 | + " raise ValueError(f\"Invalid effect_size: {effect_size}\") \n", |
| 110 | + " if not contrast_attr:\n", |
| 111 | + " raise ValueError(f\"Invalid contrast_type: {contrast_type}. Available options: [`delta2`, `mini_meta`]\")\n", |
110 | 112 | "\n", |
111 | 113 | " return [\n", |
112 | 114 | " getattr(getattr(contrast, effect_attr), contrast_attr) for contrast in contrasts\n", |
|
211 | 213 | " from .plot_tools import halfviolin\n", |
212 | 214 | "\n", |
213 | 215 | " # Validate inputs\n", |
214 | | - " if not contrasts:\n", |
215 | | - " raise ValueError(\"The `contrasts` list cannot be empty.\")\n", |
| 216 | + " if contrasts is None:\n", |
| 217 | + " raise ValueError(\"The `contrasts` parameter cannot be None\")\n", |
| 218 | + " \n", |
| 219 | + " if not isinstance(contrasts, list) or not contrasts:\n", |
| 220 | + " raise ValueError(\"The `contrasts` argument must be a non-empty list.\")\n", |
| 221 | + " \n", |
| 222 | + " if selected_indices is not None and not isinstance(selected_indices, (list, type(None))):\n", |
| 223 | + " raise TypeError(\"The `selected_indices` must be a list of integers or `None`.\")\n", |
| 224 | + " \n", |
| 225 | + " if not isinstance(contrast_type, str):\n", |
| 226 | + " raise TypeError(\"The `contrast_type` argument must be a string.\")\n", |
| 227 | + " \n", |
| 228 | + " if xticklabels is not None and not all(isinstance(label, str) for label in xticklabels):\n", |
| 229 | + " raise TypeError(\"The `xticklabels` must be a list of strings or `None`.\")\n", |
| 230 | + " \n", |
| 231 | + " if not isinstance(effect_size, str):\n", |
| 232 | + " raise TypeError(\"The `effect_size` argument must be a string.\")\n", |
| 233 | + " \n", |
| 234 | + " if contrast_labels is not None and not all(isinstance(label, str) for label in contrast_labels):\n", |
| 235 | + " raise TypeError(\"The `contrast_labels` must be a list of strings or `None`.\")\n", |
216 | 236 | " \n", |
217 | 237 | " if contrast_labels is not None and len(contrast_labels) != len(contrasts):\n", |
218 | 238 | " raise ValueError(\"`contrast_labels` must match the number of `contrasts` if provided.\")\n", |
219 | 239 | " \n", |
| 240 | + " if not isinstance(ylabel, str):\n", |
| 241 | + " raise TypeError(\"The `ylabel` argument must be a string.\")\n", |
| 242 | + " \n", |
| 243 | + " if custom_palette is not None and not isinstance(custom_palette, (dict, list, str, type(None))):\n", |
| 244 | + " raise TypeError(\"The `custom_palette` must be either a dictionary, list, string, or `None`.\")\n", |
| 245 | + " \n", |
| 246 | + " if not isinstance(fontsize, (int, float)):\n", |
| 247 | + " raise TypeError(\"`fontsize` must be an integer or float.\")\n", |
| 248 | + " \n", |
| 249 | + " if not isinstance(marker_size, (int, float)) or marker_size <= 0:\n", |
| 250 | + " raise TypeError(\"`marker_size` must be a positive integer or float.\")\n", |
| 251 | + " \n", |
| 252 | + " if not isinstance(ci_line_width, (int, float)) or ci_line_width <= 0:\n", |
| 253 | + " raise TypeError(\"`ci_line_width` must be a positive integer or float.\")\n", |
| 254 | + " \n", |
| 255 | + " if not isinstance(zero_line_width, (int, float)) or zero_line_width <= 0:\n", |
| 256 | + " raise TypeError(\"`zero_line_width` must be a positive integer or float.\")\n", |
| 257 | + " \n", |
| 258 | + " if not isinstance(remove_spines, bool):\n", |
| 259 | + " raise TypeError(\"`remove_spines` must be a boolean value.\")\n", |
| 260 | + " \n", |
| 261 | + " if ax is not None and not isinstance(ax, plt.Axes):\n", |
| 262 | + " raise TypeError(\"`ax` must be a `matplotlib.axes.Axes` instance or `None`.\")\n", |
| 263 | + " \n", |
| 264 | + " if not isinstance(rotation_for_xlabels, (int, float)) or not 0 <= rotation_for_xlabels <= 360:\n", |
| 265 | + " raise TypeError(\"`rotation_for_xlabels` must be an integer or float between 0 and 360.\")\n", |
| 266 | + " \n", |
| 267 | + " if not isinstance(alpha_violin_plot, float) or not 0 <= alpha_violin_plot <= 1:\n", |
| 268 | + " raise TypeError(\"`alpha_violin_plot` must be a float between 0 and 1.\")\n", |
| 269 | + " \n", |
| 270 | + " if not isinstance(horizontal, bool):\n", |
| 271 | + " raise TypeError(\"`horizontal` must be a boolean value.\")\n", |
| 272 | + "\n", |
220 | 273 | " # Load plot data\n", |
221 | 274 | " contrast_plot_data = load_plot_data(contrasts, effect_size, contrast_type)\n", |
222 | 275 | "\n", |
|
307 | 360 | "\n", |
308 | 361 | " return fig" |
309 | 362 | ] |
| 363 | + }, |
| 364 | + { |
| 365 | + "cell_type": "code", |
| 366 | + "execution_count": null, |
| 367 | + "metadata": {}, |
| 368 | + "outputs": [ |
| 369 | + { |
| 370 | + "data": { |
| 371 | + "text/plain": [ |
| 372 | + "True" |
| 373 | + ] |
| 374 | + }, |
| 375 | + "execution_count": null, |
| 376 | + "metadata": {}, |
| 377 | + "output_type": "execute_result" |
| 378 | + } |
| 379 | + ], |
| 380 | + "source": [ |
| 381 | + "not []" |
| 382 | + ] |
310 | 383 | } |
311 | 384 | ], |
312 | 385 | "metadata": { |
|
0 commit comments