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

Open Beginner friendly
#1,303 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
numpy, python

Research direction

Start with the four reported lines in faircode/significance.py and the benchmark cases in tests/test_benchmark.py; run the issue's pytest command to reproduce the warnings. Trace which inputs create an empty group, then check how significance tests handle the explicit missing value and note. Done when an empty-group test is covered and the full run emits no RuntimeWarning from significance.py.

Written by the indexing model from the issue text.

Description

bug testing

Where: faircode/significance.py (lines 48, 57, 72, 86), tests/test_benchmark.py.

Current gap: The full test run reports 245 warnings; among them are RuntimeWarning: Mean of empty slice from four lines of significance.py and invalid value encountered in divide, 15 of them in tests/test_benchmark.py, which means a group with no rows reaches numpy.mean and the result is NaN without the code saying so.

Repro:

python3 -m pytest tests/test_benchmark.py -q -W error::RuntimeWarning

Suggested approach: Find which inputs produce an empty slice, return an explicit missing value (and a note) instead of calling mean on nothing, and turn these RuntimeWarnings into errors in the significance tests.

Done when: the full run emits no RuntimeWarning from significance.py and a test covers the empty-group input.

Dominant language
HTML
Stars
47
Forks
45
Avg merge
2h 47m
Merged PRs (30d)
92

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from yakew7/Fair-Code

All issues in yakew7/Fair-Code

Similar issues

More Machine Learning issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.