Skip to content

Commit

Permalink
refactor: use or instead ternary if-else (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukany authored Aug 14, 2023
1 parent c5956ca commit cfd6124
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 56 deletions.
12 changes: 6 additions & 6 deletions edvart/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def add_overview(
self.sections.append(
Overview(
subsections=subsections,
verbosity=verbosity if verbosity is not None else self.verbosity,
verbosity=verbosity or self.verbosity,
columns=self._select_columns(use_columns, omit_columns),
verbosity_quick_info=verbosity_quick_info,
verbosity_data_types=verbosity_data_types,
Expand Down Expand Up @@ -402,7 +402,7 @@ def add_univariate_analysis(
self.sections.append(
UnivariateAnalysis(
df=self.df,
verbosity=verbosity if verbosity is not None else self.verbosity,
verbosity=verbosity or self.verbosity,
columns=self._select_columns(use_columns, omit_columns),
)
)
Expand Down Expand Up @@ -466,7 +466,7 @@ def add_bivariate_analysis(
self.sections.append(
BivariateAnalysis(
subsections=subsections,
verbosity=verbosity if verbosity is not None else self.verbosity,
verbosity=verbosity or self.verbosity,
columns=self._select_columns(use_columns, omit_columns),
columns_x=columns_x,
columns_y=columns_y,
Expand Down Expand Up @@ -523,7 +523,7 @@ def add_multivariate_analysis(
MultivariateAnalysis(
subsections=subsections,
df=self.df,
verbosity=verbosity if verbosity is not None else self.verbosity,
verbosity=verbosity or self.verbosity,
columns=self._select_columns(use_columns, omit_columns),
verbosity_pca=verbosity_pca,
verbosity_umap=verbosity_umap,
Expand Down Expand Up @@ -570,7 +570,7 @@ def add_group_analysis(
GroupAnalysis(
df=self.df,
groupby=groupby,
verbosity=verbosity if verbosity is not None else self.verbosity,
verbosity=verbosity or self.verbosity,
columns=self._select_columns(use_columns, omit_columns),
show_within_group_statistics=show_within_group_statistics,
show_group_missing_values=show_group_missing_values,
Expand Down Expand Up @@ -817,7 +817,7 @@ def add_timeseries_analysis(
self.sections.append(
TimeseriesAnalysis(
subsections=subsections,
verbosity=verbosity if verbosity is not None else self.verbosity,
verbosity=verbosity or self.verbosity,
columns=self._select_columns(use_columns, omit_columns),
verbosity_time_analysis_plot=verbosity_time_analysis_plot,
verbosity_rolling_statistics=verbosity_rolling_statistics,
Expand Down
10 changes: 3 additions & 7 deletions edvart/report_sections/bivariate_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,9 @@ def __init__(
verbosity_contingency_table: Optional[Verbosity] = None,
color_col: Optional[str] = None,
):
verbosity_correlations = (
verbosity_correlations if verbosity_correlations is not None else verbosity
)
verbosity_pairplot = verbosity_pairplot if verbosity_pairplot is not None else verbosity
verbosity_contingency_table = (
verbosity_contingency_table if verbosity_contingency_table is not None else verbosity
)
verbosity_correlations = verbosity_correlations or verbosity
verbosity_pairplot = verbosity_pairplot or verbosity
verbosity_contingency_table = verbosity_contingency_table or verbosity

subsec = BivariateAnalysis.BivariateAnalysisSubsection

Expand Down
24 changes: 6 additions & 18 deletions edvart/report_sections/dataset_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,14 @@ def __init__(
verbosity_duplicate_rows: Optional[Verbosity] = None,
):
# Propagate global verbosity to subsection verbosities
verbosity_quick_info = (
verbosity_quick_info if verbosity_quick_info is not None else verbosity
)
verbosity_data_types = (
verbosity_data_types if verbosity_data_types is not None else verbosity
)
verbosity_data_preview = (
verbosity_data_preview if verbosity_data_preview is not None else verbosity
)
verbosity_missing_values = (
verbosity_missing_values if verbosity_missing_values is not None else verbosity
)
verbosity_quick_info = verbosity_quick_info or verbosity
verbosity_data_types = verbosity_data_types or verbosity
verbosity_data_preview = verbosity_data_preview or verbosity
verbosity_missing_values = verbosity_missing_values or verbosity
if verbosity_rows_with_missing_value is None:
verbosity_rows_with_missing_value = verbosity
verbosity_constant_occurence = (
verbosity_constant_occurence if verbosity_constant_occurence is not None else verbosity
)
verbosity_duplicate_rows = (
verbosity_duplicate_rows if verbosity_duplicate_rows is not None else verbosity
)
verbosity_constant_occurence = verbosity_constant_occurence or verbosity
verbosity_duplicate_rows = verbosity_duplicate_rows or verbosity

subsec = Overview.OverviewSubsection

Expand Down
4 changes: 2 additions & 2 deletions edvart/report_sections/multivariate_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def __init__(
verbosity_parallel_categories: Optional[Verbosity] = None,
color_col: Optional[str] = None,
):
verbosity_pca = verbosity_pca if verbosity_pca is not None else verbosity
verbosity_umap = verbosity_umap if verbosity_umap is not None else verbosity
verbosity_pca = verbosity_pca or verbosity
verbosity_umap = verbosity_umap or verbosity
verbosity_parallel_coordinates = (
verbosity_parallel_coordinates
if verbosity_parallel_coordinates is not None
Expand Down
28 changes: 7 additions & 21 deletions edvart/report_sections/timeseries_analysis/timeseries_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,32 +99,18 @@ def __init__(
self.sampling_rate = sampling_rate
self.stft_window_size = stft_window_size

verbosity_time_analysis_plot = (
verbosity_time_analysis_plot if verbosity_time_analysis_plot is not None else verbosity
)
verbosity_rolling_statistics = (
verbosity_rolling_statistics if verbosity_rolling_statistics is not None else verbosity
)
verbosity_boxplots_over_time = (
verbosity_boxplots_over_time if verbosity_boxplots_over_time is not None else verbosity
)
verbosity_time_analysis_plot = verbosity_time_analysis_plot or verbosity
verbosity_rolling_statistics = verbosity_rolling_statistics or verbosity
verbosity_boxplots_over_time = verbosity_boxplots_over_time or verbosity
verbosity_seasonal_decomposition = (
verbosity_seasonal_decomposition
if verbosity_seasonal_decomposition is not None
else verbosity
)
verbosity_stationarity_tests = (
verbosity_stationarity_tests if verbosity_stationarity_tests is not None else verbosity
)
verbosity_autocorrelation = (
verbosity_autocorrelation if verbosity_autocorrelation is not None else verbosity
)
verbosity_fourier_transform = (
verbosity_fourier_transform if verbosity_fourier_transform is not None else verbosity
)
verbosity_short_time_ft = (
verbosity_short_time_ft if verbosity_short_time_ft is not None else verbosity
)
verbosity_stationarity_tests = verbosity_stationarity_tests or verbosity
verbosity_autocorrelation = verbosity_autocorrelation or verbosity
verbosity_fourier_transform = verbosity_fourier_transform or verbosity
verbosity_short_time_ft = verbosity_short_time_ft or verbosity

subsec = TimeseriesAnalysis.TimeseriesAnalysisSubsection

Expand Down
4 changes: 2 additions & 2 deletions edvart/report_sections/univariate_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def histogram(
sns.boxplot(x=series, ax=ax_box, **boxplot_kwargs)
sns.histplot(
data=series,
bins=bins if bins is not None else "auto",
bins=bins or "auto",
stat="density" if density else "count",
ax=ax_hist,
kde=False,
Expand All @@ -142,7 +142,7 @@ def histogram(
plt.figure(figsize=figsize)
sns.histplot(
data=series,
bins=bins if bins is not None else "auto",
bins=bins or "auto",
stat="density" if density else "count",
kde=False,
**distplot_kwargs,
Expand Down

0 comments on commit cfd6124

Please sign in to comment.