From 0283379b474ab687d798131769e28c1824e03741 Mon Sep 17 00:00:00 2001 From: Paddy Mullen Date: Thu, 21 May 2026 16:56:50 -0400 Subject: [PATCH] feat(polars): default pinned_rows include ?filtered_histogram MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds an optional ``?filtered_histogram`` pinned row to polars's default styling. The ``?`` prefix (#777) means JS hides the row when no column has the ``filtered_histogram`` key in ``merged_sd``, so a no-filter widget keeps a one-line ``[dtype, histogram]`` header. When the user runs a search, ``filtered_histogram`` gets layered onto each column's merged_sd entry (#785) and the row renders. Polars-only on purpose: - xorq skips computing ``filtered_histogram`` entirely (this PR's ``skip_stats_by_scope``), so the optional row never appears. - Pandas keeps the original ``[dtype, histogram]`` default. New ``pinned_filtered_histogram()`` helper in ``styling_helpers``, mirroring the existing ``pinned_histogram()``. New ``PolarsMainStyling(DefaultMainStyling)`` in ``polars_buckaroo`` overrides ``pinned_rows`` and replaces ``DefaultMainStyling`` in ``local_analysis_klasses``. Config-only — no behavior tests, just a new default in the styling pipeline. The optional-pinned-row plumbing (#777) is already exercised by ``gridUtils.test.ts``. Co-Authored-By: Claude Opus 4.7 (1M context) --- buckaroo/polars_buckaroo.py | 17 ++++++++++++++++- buckaroo/styling_helpers.py | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/buckaroo/polars_buckaroo.py b/buckaroo/polars_buckaroo.py index 8a164a8f8..c620b39c8 100644 --- a/buckaroo/polars_buckaroo.py +++ b/buckaroo/polars_buckaroo.py @@ -15,12 +15,27 @@ from .dataflow.dataflow import Sampling from .dataflow.autocleaning import PandasAutocleaning from .dataflow.widget_extension_utils import configure_buckaroo +from .styling_helpers import obj_, pinned_histogram, pinned_filtered_histogram class PLSampling(Sampling): pre_limit = False serialize_limit = 1_000_000 -local_analysis_klasses = list(PL_ANALYSIS_V2) + [DefaultSummaryStatsStyling, DefaultMainStyling] + +class PolarsMainStyling(DefaultMainStyling): + """Polars default styling — adds an optional ``?filtered_histogram`` + pinned row alongside the bare raw ``histogram``. The ``?`` prefix + means JS only renders the row when at least one column has the + ``filtered_histogram`` key in ``merged_sd``, i.e. when a search + filter is active. Polars materialises the filt scope cheaply, so + showing both raw and filtered histograms side-by-side is the + default; xorq skips computing filtered_histogram (#829) and pandas + keeps the original ``[dtype, histogram]`` layout.""" + + pinned_rows = [obj_('dtype'), pinned_histogram(), pinned_filtered_histogram()] + + +local_analysis_klasses = list(PL_ANALYSIS_V2) + [DefaultSummaryStatsStyling, PolarsMainStyling] class PolarsAutocleaning(PandasAutocleaning): diff --git a/buckaroo/styling_helpers.py b/buckaroo/styling_helpers.py index 0052cad3a..26c316c0b 100644 --- a/buckaroo/styling_helpers.py +++ b/buckaroo/styling_helpers.py @@ -12,3 +12,6 @@ def inherit_(pkey): def pinned_histogram(): return {'primary_key_val': 'histogram', 'displayer_args': {'displayer': 'histogram'}} + +def pinned_filtered_histogram(): + return {'primary_key_val': '?filtered_histogram', 'displayer_args': {'displayer': 'histogram'}}