Skip to content

Handle empty groups in significance calculations - #1311

Merged
yakew7 merged 1 commit into
yakew7:mainfrom
ranjanasri6:fix-empty-group-warning
Nov 9, 2026
Merged

yakew7 merged 1 commit into
yakew7:mainfrom
ranjanasri6:fix-empty-group-warning

Conversation

@ranjanasri6

Copy link
Copy Markdown

What does this PR fix?

Fixes the RuntimeWarning: Mean of empty slice that occurs when an intersectional group has no samples.

Changes made

  • Added safe handling for empty groups.
  • Return NaN for undefined gaps and confidence intervals.
  • Return a conservative p-value of 1.0 when a group is empty.
  • Added a regression test for empty groups.

Tests performed

  • python -m pytest tests/test_significance.py -q — 9 passed
  • python -m pytest tests/test_benchmark.py::test_empty_intersectional_cell_is_not_reported_significant -q -W error::RuntimeWarning — 1 passed

Closes #1303

@vercel

vercel Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@PRIYANKA2272004 is attempting to deploy a commit to the yashkewlani2020-gmailcom's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Hey @ranjanasri6, your first PR on Fair Code, that's awesome, thank you.

This project is about making AI more accountable, and contributions like yours are what keep that work going. We'll review your changes shortly.

If you haven't already, give the contributing guide a quick read: it covers how audits are structured and what we look for in a review.

And if you're finding Fair Code useful or interesting, a star on the repo genuinely helps more people find it - no pressure, just appreciated.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

@yakew7 @ahmdkaml - new PR touching a path you own, please review.

@yakew7
yakew7 merged commit 0062928 into yakew7:main Nov 9, 2026
18 of 19 checks passed
yakew7 added a commit that referenced this pull request Nov 11, 2026
Started in one run with check_contributors.py --stub ... --commits (snapshot
moved to PR #1313, the pull request summaries filled in the stubs) and the
TODO sentences replaced: the pending-closes draft note (#1310), empty groups
in significance (#1311) and the configurable builder timeout (#1313). PR
#1311's commit is authored by PRIYANKA2272004, who has no pull request of
her own, so ranjanasri6's commit count and PRIYANKA2272004 are documented
exceptions, and an identity map row is added for renuvenugopal178.
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.

significance.py emits RuntimeWarning: Mean of empty slice during the benchmark tests

3 participants