Commit 3b910ae
miranov25
PHASE 13.35.DF — group_by_bins + hist_norm for hist() (BUG-013)
Fixes 3 AttributeError crashes confirmed in 2026-05-20 live testing:
T2: group_by_bins leaks to ax.hist() (no facet)
T3: same crash in faceted subplot path
T4: hist_norm leaks to ax.hist()
Root cause: group_by_bins, group_by_quantiles, hist_norm, min_entries
absent from BOTH DFDraw.hist() method signature AND draw_hist() function
signature AND _HIST_FORWARDED_NAMES -> fall into **kwargs -> forwarded
to _draw_hist_grouped() **hist_kwargs -> reach ax.hist() which rejects.
Fixes (7 edits, ~300 LOC source + 384 LOC tests):
1. _HIST_FORWARDED_NAMES: add group_by_bins, group_by_quantiles,
hist_norm, min_entries (drawer.py)
2. draw_hist() signature: add the 4 as explicit params (histogram.py)
3. group_by routing block: BUG-012 guard (float + nunique>20 + no
bins -> ValueError with 'group_by_bins=N' guidance), pd.cut/qcut
binning with float16->float32 upcast, df.copy() to avoid caller
mutation, shared bin edges from x_data (sanitized at lines
259-307, NOT df[x].dropna() which would bypass nan_policy),
stats_dict['n_groups'] population (was missing — T1 observation)
4. _draw_hist_grouped(): pop 'weights' from hist_kwargs to avoid
ax.hist() double-weights TypeError; one-pass stacked loop building
data_list + labels + surviving_colors in lockstep (fixes v1.2
P1-D label misalignment AND P3 color-shift); n_rendered counter
in overlaid branch (v1.1 P1-C); str(group) labels (no
_format_interval_label import — v1.1 P1-A); return -> int
5. _group_weights(): new module-level helper (probability/density)
6. DFDraw.hist() signature: add the 4 params (required by R6
module-import validator — discovered during implementation)
7. _dispatch_faceted_render() call: forward the 4 params explicitly
(required after Edit 6 consumes them off **kwargs — discovered
when T3 architect-call test initially failed)
Architect's TPC/ITS production call now works end-to-end:
adf.draw('dyp_I6-dyp_recoV2', type='hist',
group_by='z', group_by_bins=5,
min_entries=25, facet_by='sec')
Live-tested: 9 sector panels x 5 drift-coordinate bins each.
§9 tests (+11):
HGB.1-3 group_by_bins + facet_by + shared bin edges
HN.1-3 hist_norm probability/None/density (math at data layer)
HGS.1-2 stats['n_groups'] + BUG-012 guard with actionable error
HGSt.1 stacked + min_entries label alignment (regression lock for
v1.2 P1-D, verified by failure injection)
HGBC.1-2 backward compat (single-hist path; categorical group_by)
Gate: 822 -> 833 / 0 / 0 / 1 skipped.
Spec: PHASE_13_35_DF_v1_3_Proposal_HistGroupByNorm.md (notes repo)
v1.0 -> v1.1: 5 factual source errors (Claude40 panel)
v1.1 -> v1.2: 3 P1s (Sonet50/Sonnet52_R1/Sonnet53_R2 panel)
v1.2 -> v1.3: 1 P1 stacked branch + 1 P2 comment + 1 §9 test add
v1.3 implementation by Claude48 + 2 discovered fixes + P3 color-shift.1 parent 458a952 commit 3b910ae
4 files changed
Lines changed: 578 additions & 20 deletions
File tree
- UTILS/dfextensions/dfdraw
- docs
- plots
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
597 | 604 | | |
598 | 605 | | |
599 | 606 | | |
| |||
3175 | 3182 | | |
3176 | 3183 | | |
3177 | 3184 | | |
| 3185 | + | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
| 3189 | + | |
| 3190 | + | |
| 3191 | + | |
| 3192 | + | |
3178 | 3193 | | |
3179 | 3194 | | |
3180 | 3195 | | |
| |||
3352 | 3367 | | |
3353 | 3368 | | |
3354 | 3369 | | |
| 3370 | + | |
| 3371 | + | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
3355 | 3380 | | |
3356 | 3381 | | |
3357 | 3382 | | |
| |||
3378 | 3403 | | |
3379 | 3404 | | |
3380 | 3405 | | |
| 3406 | + | |
| 3407 | + | |
| 3408 | + | |
| 3409 | + | |
| 3410 | + | |
3381 | 3411 | | |
3382 | 3412 | | |
3383 | 3413 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
146 | 183 | | |
147 | 184 | | |
148 | 185 | | |
| |||
176 | 213 | | |
177 | 214 | | |
178 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
179 | 225 | | |
180 | 226 | | |
181 | 227 | | |
| |||
374 | 420 | | |
375 | 421 | | |
376 | 422 | | |
377 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
378 | 468 | | |
379 | | - | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
380 | 473 | | |
381 | | - | |
| 474 | + | |
| 475 | + | |
382 | 476 | | |
383 | 477 | | |
| 478 | + | |
384 | 479 | | |
385 | 480 | | |
386 | 481 | | |
| |||
432 | 527 | | |
433 | 528 | | |
434 | 529 | | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
435 | 533 | | |
436 | | - | |
437 | | - | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
438 | 540 | | |
439 | | - | |
440 | | - | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
441 | 551 | | |
442 | | - | |
443 | | - | |
| 552 | + | |
| 553 | + | |
444 | 554 | | |
445 | 555 | | |
446 | 556 | | |
447 | 557 | | |
448 | | - | |
449 | | - | |
| 558 | + | |
| 559 | + | |
450 | 560 | | |
451 | 561 | | |
452 | 562 | | |
453 | | - | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
454 | 567 | | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
460 | 591 | | |
461 | | - | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
462 | 596 | | |
463 | 597 | | |
464 | 598 | | |
465 | | - | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
466 | 610 | | |
467 | 611 | | |
468 | 612 | | |
| |||
0 commit comments