Skip to content

Commit 6d65a12

Browse files
author
miranov25
committed
fix(quantile_fit_nd): exclude q_center from nuisance axes; silence single-groupby warning
- Evaluator was treating 'q_center' as a nuisance axis (detected by *_center), causing axis misalignment and AxisError in moveaxis. Exclude it explicitly. - When grouping by a single nuisance bin column, use scalar grouper to avoid pandas FutureWarning.
1 parent 273d6f8 commit 6d65a12

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

UTILS/dfextensions/quantile_fit_nd/quantile_fit_nd.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ def fit_quantile_linear_nd(
158158
for ch_val, df_ch in df.groupby(channel_key, sort=False, dropna=False):
159159
# iterate bins of nuisance axes
160160
if bin_cols:
161-
gb = df_ch.groupby(bin_cols, sort=False, dropna=False)
161+
if len(bin_cols) == 1:
162+
# avoid FutureWarning: use scalar grouper when only one column
163+
gb = df_ch.groupby(bin_cols[0], sort=False, dropna=False)
164+
else:
165+
gb = df_ch.groupby(bin_cols, sort=False, dropna=False)
162166
else:
163167
# single group with empty tuple key
164168
df_ch = df_ch.copy()
@@ -294,8 +298,11 @@ def _build_index(self):
294298
t = self.table
295299
if "channel_id" not in t.columns or "q_center" not in t.columns:
296300
raise ValueError("Calibration table missing 'channel_id' or 'q_center'.")
297-
# detect nuisance axes from columns ending with _center
298-
self.axes = [c[:-7] for c in t.columns if c.endswith("_center")]
301+
# detect nuisance axes from columns ending with _center, but EXCLUDE q_center
302+
self.axes = []
303+
for c in t.columns:
304+
if c.endswith("_center") and c != "q_center":
305+
self.axes.append(c[:-7]) # strip '_center'
299306
self.q_centers = np.sort(t["q_center"].unique())
300307
# map channel -> nested dicts of arrays over (q, axis1, axis2, ...)
301308
self.store: Dict[Any, Dict[str, Any]] = {}

0 commit comments

Comments
 (0)