Skip to content

Gracefully handle weighted sampling with no sequences - #2033

Merged
victorlin merged 1 commit into
masterfrom
victorlin/fix-weighted-sampling
Jul 22, 2026
Merged

Gracefully handle weighted sampling with no sequences#2033
victorlin merged 1 commit into
masterfrom
victorlin/fix-weighted-sampling

Conversation

@victorlin

@victorlin victorlin commented Jul 21, 2026

Copy link
Copy Markdown
Member

Description of proposed changes

When running with --group-by-weights and no sequence records pass earlier filters, get_weighted_group_sizes was called with an empty records_per_group dict. This caused pandas df.apply on an empty DataFrame to return a DataFrame instead of a Series, triggering an unhandled error when setting _augur_filter_input_size.

Exit early in get_weighted_group_sizes when records_per_group is empty so that the command completes and handles empty filter results through --empty-output-reporting.

Related issue(s)

Closes #2032

Checklist

  • Automated checks pass
  • Check if you need to add a changelog message
  • Check if you need to add tests
  • Check if you need to update docs

When running with `--group-by-weights` and no sequence records pass
earlier filters, `get_weighted_group_sizes` was called with an empty
`records_per_group` dict. This caused pandas `df.apply` on an empty
DataFrame to return a DataFrame instead of a Series, triggering an
unhandled error when setting `_augur_filter_input_size`.

Exit early in `get_weighted_group_sizes` when `records_per_group` is
empty so that the command completes and handles empty filter results
through `--empty-output-reporting`.
@victorlin victorlin self-assigned this Jul 21, 2026
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.24%. Comparing base (12b55ab) to head (f1e9f15).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
augur/filter/subsample.py 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2033      +/-   ##
==========================================
- Coverage   73.25%   73.24%   -0.02%     
==========================================
  Files          86       86              
  Lines       10754    10759       +5     
  Branches     2096     2098       +2     
==========================================
+ Hits         7878     7880       +2     
- Misses       2502     2504       +2     
- Partials      374      375       +1     

☔ 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 augur/filter/subsample.py
@victorlin
victorlin merged commit 4b98503 into master Jul 22, 2026
35 checks passed
@victorlin
victorlin deleted the victorlin/fix-weighted-sampling branch July 22, 2026 20:14
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.

filter: Error with --group-by-weights when no sequences pass filters

2 participants