Conversation
CategoryCount(categories=[True, False]) only counted the first category, because the all-boolean branch read counts[categories[0]]. The per-category loop already handles boolean labels, so use it for every case.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
CategoryCountCalculation._calculate_valuehas a special branch for when every category is a boolean:CategoryCountaccepts several categories, socategories=[True, False]is valid, but that branch counts only the first one:Fix
Remove the boolean branch. The loop below it already looks up each label with
cat in counts/counts[cat], which works for boolean labels too. A boolean label on a0/1integer column still counts 0, as before.Tests
tests/future/metrics/test_category_count.pycovers multiple string categories (including a missing one) and boolean categories.[True, False]and[False, True]with aNonefail onmain(count 2 instead of 4, and 1 instead of 3). All 6 cases pass with the fix.tests/calculations tests/future tests/metrics tests/metric_preset tests/test_preset tests/test_suite tests/stattests) has the same 71 pre-existing failures asmain(allNo module named 'IPython', because I did not install the jupyter extra), and no new ones.ruff checkandruff format --checkpass on the changed files.Side note: the existing
tests/future/metrics/category_count.pyis not collected by pytest because of its file name, and it fails onmain(it comparesCountValue.countto an int). I left it unchanged.This PR was written with an AI coding agent (Claude Code, run by breken-ai), and I checked the reproduction and the tests above.