Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use new Verbosity enum instead of int #81

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions edvart/report_sections/bivariate_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ def __init__(
else:
subsections_all = subsections

# Store subsections with 0 verbosity
self.subsections_0 = [sub for sub in subsections_all if verbosities[sub] == 0]
# Store subsections with LOW verbosity
self.subsections_low_verbosity = [
sub for sub in subsections_all if verbosities[sub] == Verbosity.LOW
]

if len(self.subsections_0) == len(subsections_all) and subsections is None:
self.subsections_0 = None
if len(self.subsections_low_verbosity) == len(subsections_all) and subsections is None:
self.subsections_low_verbosity = None

if (columns_x is None) != (columns_y is None):
raise ValueError("Either both or neither of columns_x, columns_y must be specified.")
Expand Down Expand Up @@ -231,10 +233,10 @@ def add_cells(self, cells: List[Dict[str, Any]]) -> None:
cells.append(section_header)
if self.verbosity == Verbosity.LOW:
code = "bivariate_analysis(df=df"
if self.subsections_0 is not None:
if self.subsections_low_verbosity is not None:
arg_subsections_names = [
f"BivariateAnalysis.BivariateAnalysisSubsection.{str(sub)}"
for sub in self.subsections_0
for sub in self.subsections_low_verbosity
]

code += f", subsections={arg_subsections_names}".replace("'", "")
Expand Down
15 changes: 9 additions & 6 deletions edvart/report_sections/dataset_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ def __init__(
else:
subsections_all = subsections

# Store subsections with 0 verbosity
self.subsections_0 = [sub for sub in subsections_all if verbosities[sub] == 0]
# Store subsections with LOW verbosity
self.subsections_low_verbosity = [
sub for sub in subsections_all if verbosities[sub] == Verbosity.LOW
]

if len(self.subsections_0) == len(subsections_all) and subsections is None:
self.subsections_0 = None
if len(self.subsections_low_verbosity) == len(subsections_all) and subsections is None:
self.subsections_low_verbosity = None

# Construct objects that implement subsections
enum_to_implementation = {
Expand Down Expand Up @@ -212,9 +214,10 @@ def add_cells(self, cells: List[Dict[str, Any]]) -> None:

if self.verbosity == Verbosity.LOW:
code = "overview_analysis(df=df"
if self.subsections_0 is not None:
if self.subsections_low_verbosity is not None:
arg_subsections_names = [
f"Overview.OverviewSubsection.{str(sub)}" for sub in self.subsections_0
f"Overview.OverviewSubsection.{str(sub)}"
for sub in self.subsections_low_verbosity
]
code += f", subsections={arg_subsections_names}".replace("'", "")
if self.columns is not None:
Expand Down
14 changes: 8 additions & 6 deletions edvart/report_sections/multivariate_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@ def __init__(
else:
subsections_all = subsections

# Store subsections with 0 verbosity
self.subsections_0 = [sub for sub in subsections_all if verbosities[sub] == 0]
# Store subsections with LOW verbosity
self.subsections_low_verbosity = [
sub for sub in subsections_all if verbosities[sub] == Verbosity.LOW
]

if len(self.subsections_0) == len(subsections_all) and subsections is None:
self.subsections_0 = None
if len(self.subsections_low_verbosity) == len(subsections_all) and subsections is None:
self.subsections_low_verbosity = None

enum_to_implementation = {
subsec.PCA: PCA(df, verbosity_pca, columns, color_col=color_col),
Expand Down Expand Up @@ -210,10 +212,10 @@ def add_cells(self, cells: List[Dict[str, Any]]) -> None:
cells.append(section_header)
if self.verbosity == Verbosity.LOW:
code = "multivariate_analysis(df=df"
if self.subsections_0 is not None:
if self.subsections_low_verbosity is not None:
arg_subsections_names = [
f"MultivariateAnalysis.MultivariateAnalysisSubsection.{str(sub)}"
for sub in self.subsections_0
for sub in self.subsections_low_verbosity
]
code += f", subsections={arg_subsections_names}".replace("'", "")
if self.columns is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,13 @@ def __init__(
else:
subsections_all = subsections

# Store subsections with Verbosity.LOW
self.subsections_0 = [sub for sub in subsections_all if verbosities[sub] == Verbosity.LOW]
# Store subsections with LOW verbosity
self.subsections_low_verbosity = [
sub for sub in subsections_all if verbosities[sub] == Verbosity.LOW
]

if len(self.subsections_0) == len(subsections_all) and subsections is None:
self.subsections_0 = None
if len(self.subsections_low_verbosity) == len(subsections_all) and subsections is None:
self.subsections_low_verbosity = None

if subsections is None:
subsections_implementations = list(enum_to_implementation.values())
Expand Down Expand Up @@ -258,18 +260,19 @@ def add_cells(self, cells: List[Dict[str, Any]]) -> None:
subsec = TimeseriesAnalysis.TimeseriesAnalysisSubsection
code = "timeseries_analysis(df=df"

if self.subsections_0 is not None:
if self.subsections_low_verbosity is not None:
arg_subsections_names = [
f"TimeseriesAnalysis.TimeseriesAnalysisSubsection.{str(sub)}"
for sub in self.subsections_0
for sub in self.subsections_low_verbosity
]
code += f", subsections={arg_subsections_names}".replace("'", "")

stft_included_or_empty = (
self.subsections_0 is None or subsec.ShortTimeFT in self.subsections_0
self.subsections_low_verbosity is None
or subsec.ShortTimeFT in self.subsections_low_verbosity
)
include_sampling_rate = self.sampling_rate is not None and (
stft_included_or_empty or subsec.FourierTransform in self.subsections_0
stft_included_or_empty or subsec.FourierTransform in self.subsections_low_verbosity
)
if include_sampling_rate:
code += f", sampling_rate={self.sampling_rate}"
Expand Down