Skip to content

Commit c5a4b6d

Browse files
sanghoonioclaude
andcommitted
Use sqrt(n) binning for scalar histograms in bedset aggregation
Match the client-side collection histogram bin count: min(25, max(3, ceil(sqrt(n)))). Previously used min(25, n) which produced too many bins for small collections. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ea92a13 commit c5a4b6d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

bbconf/modules/aggregation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import logging
8+
import math
89
from typing import Dict, List, Optional
910

1011
from sqlalchemy import text
@@ -172,7 +173,7 @@ def _sql_histogram(
172173
n: int,
173174
) -> dict:
174175
"""Build a histogram for a single scalar column using width_bucket."""
175-
num_bins = min(_SCALAR_HIST_BINS, n)
176+
num_bins = min(_SCALAR_HIST_BINS, max(3, math.ceil(math.sqrt(n))))
176177

177178
if col_min == col_max:
178179
# All values identical — single bin

0 commit comments

Comments
 (0)