From 4767c894fc74a8b11cc8c704d39ce45ed5054b7b Mon Sep 17 00:00:00 2001 From: lshpaner Date: Mon, 5 Aug 2024 22:09:55 -0700 Subject: [PATCH] created exception for plot_type when entered incorrectly in kde_distribution --- src/eda_toolkit/main.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/eda_toolkit/main.py b/src/eda_toolkit/main.py index 027d9df..deb469a 100644 --- a/src/eda_toolkit/main.py +++ b/src/eda_toolkit/main.py @@ -769,6 +769,14 @@ def kde_distributions( print("Error: No variables of interest provided.") return + # Validate plot_type parameter + valid_plot_types = ["hist", "kde", "both"] + if plot_type.lower() not in valid_plot_types: + raise ValueError( + f"Invalid plot_type value. Expected one of {valid_plot_types}, " + f"got '{plot_type}' instead." + ) + # Validate stat parameter valid_stats = [ "count", @@ -886,7 +894,10 @@ def kde_distributions( ) ax.set_xlabel(col, fontsize=label_fontsize) - ax.set_ylabel(y_axis_label.capitalize(), fontsize=label_fontsize) + ax.set_ylabel( + y_axis_label.capitalize(), + fontsize=label_fontsize, + ) ax.set_title( "\n".join(textwrap.wrap(title, width=text_wrap)), fontsize=label_fontsize, @@ -1006,7 +1017,10 @@ def kde_distributions( ) ax.set_xlabel(var, fontsize=label_fontsize) - ax.set_ylabel(y_axis_label.capitalize(), fontsize=label_fontsize) + ax.set_ylabel( + y_axis_label.capitalize(), + fontsize=label_fontsize, + ) ax.set_title( "\n".join(textwrap.wrap(title, width=text_wrap)), fontsize=label_fontsize,