Skip to content

Commit 4bffed4

Browse files
paddymulclaude
andauthored
feat(polars): default pinned_rows include ?filtered_histogram (#830)
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) <noreply@anthropic.com>
1 parent 76743bf commit 4bffed4

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

buckaroo/polars_buckaroo.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,27 @@
1515
from .dataflow.dataflow import Sampling
1616
from .dataflow.autocleaning import PandasAutocleaning
1717
from .dataflow.widget_extension_utils import configure_buckaroo
18+
from .styling_helpers import obj_, pinned_histogram, pinned_filtered_histogram
1819

1920
class PLSampling(Sampling):
2021
pre_limit = False
2122
serialize_limit = 1_000_000
2223

23-
local_analysis_klasses = list(PL_ANALYSIS_V2) + [DefaultSummaryStatsStyling, DefaultMainStyling]
24+
25+
class PolarsMainStyling(DefaultMainStyling):
26+
"""Polars default styling — adds an optional ``?filtered_histogram``
27+
pinned row alongside the bare raw ``histogram``. The ``?`` prefix
28+
means JS only renders the row when at least one column has the
29+
``filtered_histogram`` key in ``merged_sd``, i.e. when a search
30+
filter is active. Polars materialises the filt scope cheaply, so
31+
showing both raw and filtered histograms side-by-side is the
32+
default; xorq skips computing filtered_histogram (#829) and pandas
33+
keeps the original ``[dtype, histogram]`` layout."""
34+
35+
pinned_rows = [obj_('dtype'), pinned_histogram(), pinned_filtered_histogram()]
36+
37+
38+
local_analysis_klasses = list(PL_ANALYSIS_V2) + [DefaultSummaryStatsStyling, PolarsMainStyling]
2439

2540

2641
class PolarsAutocleaning(PandasAutocleaning):

buckaroo/styling_helpers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ def inherit_(pkey):
1212

1313
def pinned_histogram():
1414
return {'primary_key_val': 'histogram', 'displayer_args': {'displayer': 'histogram'}}
15+
16+
def pinned_filtered_histogram():
17+
return {'primary_key_val': '?filtered_histogram', 'displayer_args': {'displayer': 'histogram'}}

0 commit comments

Comments
 (0)