Skip to content

Commit

Permalink
created exception for plot_type when entered incorrectly in kde_distr…
Browse files Browse the repository at this point in the history
…ibution
  • Loading branch information
lshpaner committed Aug 6, 2024
1 parent fcff969 commit 4767c89
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/eda_toolkit/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 4767c89

Please sign in to comment.