Skip to content

fix(stat_bin): name the ngroup computed variable correctly - #1135

Merged
has2k1 merged 3 commits into
has2k1:mainfrom
raashish1601:fix/stat-bin-ngroup
Oct 8, 2026
Merged

has2k1 merged 3 commits into
has2k1:mainfrom
raashish1601:fix/stat-bin-ngroup

Conversation

@raashish1601

Copy link
Copy Markdown
Contributor

stat_bin documents an ngroup computed variable ("number of points in group", added in #462), but result_dataframe creates the column as "ngroup:" with a stray colon. So mapping it fails:

ggplot(df, aes("x", y=after_stat("count / ngroup"), fill="g")) + geom_histogram(binwidth=1)
# PlotnineError: Could not evaluate the 'y' mapping: 'count / ngroup'
# (original error: name 'ngroup' is not defined)

This renames the column to ngroup, which is also the name already listed in stat_bin.CREATES.

Testing: added test_histogram_ngroup, which fails on main and passes with the fix. tests/test_geom_bar_col_histogram.py, tests/test_binning.py, tests/test_stat_calculate_methods.py and tests/test_geom_freqpoly.py pass, ruff is clean. Added a changelog entry under Bug Fixes.

@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.87%. Comparing base (986704a) to head (8124070).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1135   +/-   ##
=======================================
  Coverage   88.87%   88.87%           
=======================================
  Files         229      229           
  Lines       17290    17290           
  Branches     2203     2203           
=======================================
  Hits        15366    15366           
  Misses       1295     1295           
  Partials      629      629           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread tests/test_geom_bar_col_histogram.py Outdated
@has2k1
has2k1 merged commit e102863 into has2k1:main Oct 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants