diff --git a/buckaroo/buckaroo_widget.py b/buckaroo/buckaroo_widget.py index ad889f41b..720e3e037 100644 --- a/buckaroo/buckaroo_widget.py +++ b/buckaroo/buckaroo_widget.py @@ -58,16 +58,16 @@ def _bk_flash(event, **extra): class PdSampling(Sampling): @classmethod - def pre_stats_sample(kls, df): + def pre_stats_sample(cls, df): # this is a bad place for fixing the dataframe, but for now # it's expedient. There probably should be a nother processing # step df = check_and_fix_df(df) - if len(df.columns) > kls.max_columns: + if len(df.columns) > cls.max_columns: print("Removing excess columns, found %d columns" % len(df.columns)) - df = df[df.columns[:kls.max_columns]] - if kls.pre_limit and len(df) > kls.pre_limit: - sampled = df.sample(kls.pre_limit) + df = df[df.columns[:cls.max_columns]] + if cls.pre_limit and len(df) > cls.pre_limit: + sampled = df.sample(cls.pre_limit) if isinstance(sampled, pd.DataFrame): return sampled.sort_index() return sampled @@ -115,7 +115,7 @@ def get_story_config(self, include_summary_stats=False, test_name=None) -> str: 'secondary_df_viewer_config': EMPTY_DFVIEWER_CONFIG}} args_dict['args']['summary_stats_data'] = [] if include_summary_stats: - 1/0 # not supported yet + raise NotImplementedError("include_summary_stats isn't supported yet") # summary_stats data is big, and most of the time you won't want to serialize it #args_dict['summary_stats_data'] = {} #desrialize here @@ -145,6 +145,7 @@ def __init__(self, orig_df, debug=False, self.record_transcript = record_transcript self.exception = None kls = self.__class__ + widget = self class InnerDataFlow(kls.dataflow_klass): sampling_klass = kls.sampling_klass autocleaning_klass = kls.autocleaning_klass @@ -152,8 +153,8 @@ class InnerDataFlow(kls.dataflow_klass): autoclean_conf= kls.autoclean_conf analysis_klasses = kls.analysis_klasses - def _df_to_obj(idfself, df:pd.DataFrame): - return self._df_to_obj(df) + def _df_to_obj(self, df:pd.DataFrame): + return widget._df_to_obj(df) self.dataflow = InnerDataFlow( orig_df, @@ -258,7 +259,7 @@ def add_processing(self, df_processing_func, /): class DecoratedProcessing(ColAnalysis): provides_defaults = {} @classmethod - def post_process_df(kls, df): + def post_process_df(cls, df): new_df = df_processing_func(df) return [new_df, {}] post_processing_method = proc_func_name diff --git a/buckaroo/customizations/styling.py b/buckaroo/customizations/styling.py index bfba52731..73379dc9b 100644 --- a/buckaroo/customizations/styling.py +++ b/buckaroo/customizations/styling.py @@ -69,7 +69,7 @@ class DefaultMainStyling(StylingAnalysis): @classmethod - def style_column(kls, col:str, column_metadata: Any) -> Any: + def style_column(cls, col:str, column_metadata: Any) -> Any: # `_type` is the discriminator for displayer choice. If column_metadata # is empty (polars/index edge case) or arrives without `_type` — e.g. # a no-cleaning run where only an op-contributed entry (highlight_*) @@ -126,7 +126,7 @@ def style_column(kls, col:str, column_metadata: Any) -> Any: header_name = column_metadata.get('orig_col_name', col) has_histogram = any( pr.get('displayer_args', {}).get('displayer') == 'histogram' - for pr in kls.pinned_rows) + for pr in cls.pinned_rows) min_w = estimate_min_width_px(disp, header_name, column_metadata, has_histogram) base_config['ag_grid_specs'] = {'minWidth': min_w} # ag_grid_specs from column_metadata (e.g. init_sd carrying diff --git a/buckaroo/server/data_loading.py b/buckaroo/server/data_loading.py index 24ff46ab2..b7bebce95 100644 --- a/buckaroo/server/data_loading.py +++ b/buckaroo/server/data_loading.py @@ -24,12 +24,12 @@ class ServerSampling(Sampling): pre_limit = 1_000_000 @classmethod - def pre_stats_sample(kls, df): + def pre_stats_sample(cls, df): df = check_and_fix_df(df) - if len(df.columns) > kls.max_columns: - df = df[df.columns[:kls.max_columns]] - if kls.pre_limit and len(df) > kls.pre_limit: - sampled = df.sample(kls.pre_limit) + if len(df.columns) > cls.max_columns: + df = df[df.columns[:cls.max_columns]] + if cls.pre_limit and len(df) > cls.pre_limit: + sampled = df.sample(cls.pre_limit) if isinstance(sampled, pd.DataFrame): return sampled.sort_index() return sampled diff --git a/buckaroo/xorq_buckaroo.py b/buckaroo/xorq_buckaroo.py index f621c98f0..6b9149c40 100644 --- a/buckaroo/xorq_buckaroo.py +++ b/buckaroo/xorq_buckaroo.py @@ -264,7 +264,7 @@ class DecoratedXorqProcessing(ColAnalysis): provides_defaults = {} @classmethod - def post_process_df(kls, expr): + def post_process_df(cls, expr): return [expr_processing_func(expr), {}] post_processing_method = proc_func_name