Skip to content

Conversation

@MaxGhenis
Copy link
Contributor

@MaxGhenis MaxGhenis commented Jan 25, 2026

Summary

Replace patterns where True is used as a fallback condition in select statements with the explicit default parameter. This provides ~10% performance improvement for select operations according to time tests.

Before:

return select(
    [under_60_days, under_12_months, True],
    [0, 60, np.inf],
)

After:

return select(
    [under_60_days, under_12_months],
    [0, 60],
    default=np.inf,
)

Changes

Updated 9 files to use the default parameter:

  • count_days_postpartum.py - postpartum days calculation
  • ccdf_duration_of_care.py - childcare duration categorization
  • school_meal_tier.py - school meal tier determination
  • section_22_income.py - elderly/disabled credit income
  • race.py - race categorization
  • medicaid_category.py - Medicaid category selection
  • taxsim_state.py - TAXSIM state code mapping
  • wic_category.py - WIC demographic category
  • fsla_overtime_occupation_exemption_category.py - FSLA overtime exemption

Test plan

  • All existing tests pass (ran school meals, medicaid, CCDF, WIC, elderly/disabled tests)
  • Manual verification with test simulations
  • No functional changes - only refactoring select statements

Fixes #1176

🤖 Generated with Claude Code

Replace patterns where `True` is used as a fallback condition in `select`
statements with the `default` parameter. This provides ~10% performance
improvement for select operations.

Files updated:
- count_days_postpartum.py
- ccdf_duration_of_care.py
- school_meal_tier.py
- section_22_income.py
- race.py
- medicaid_category.py
- taxsim_state.py
- wic_category.py
- fsla_overtime_occupation_exemption_category.py

Fixes #1176

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@MaxGhenis MaxGhenis force-pushed the fix-select-default-arg branch from cf5cd58 to 925d580 Compare January 25, 2026 17:14
@MaxGhenis MaxGhenis merged commit f078ffb into main Jan 25, 2026
7 checks passed
@MaxGhenis MaxGhenis deleted the fix-select-default-arg branch January 25, 2026 17:33
@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.88%. Comparing base (7e781d3) to head (925d580).
⚠️ Report is 20 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##              main    #7240      +/-   ##
===========================================
- Coverage   100.00%   94.88%   -5.12%     
===========================================
  Files           12        9       -3     
  Lines          205      176      -29     
===========================================
- Hits           205      167      -38     
- Misses           0        9       +9     
Flag Coverage Δ
unittests 94.88% <ø> (-5.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

MaxGhenis added a commit that referenced this pull request Jan 25, 2026
Adds explicit default= keyword argument to select statements across 16 files
for better performance and code clarity. This is a continuation of #7240.

Files updated:
- taxsim_mstat.py (default=1 for SINGLE)
- pell_grant_efc.py (default=0)
- pell_grant_household_type.py (default=INDEPENDENT_SINGLE)
- ccdf_age_group.py (default=SCHOOL_AGE)
- ccdf_market_rate.py (default=0)
- age_group.py (default=WORKING_AGE)
- az_family_tax_credit_eligible.py (default=0)
- ia_standard_deduction_indiv.py (default=SINGLE)
- ia_amt_indiv.py (default=SINGLE)
- il_personal_exemption.py (default=0)
- il_personal_exemption_eligibility_status.py (default=BOTH_ELIGIBLE)
- mt_capital_gains_tax_applicable_threshold_indiv.py (default=single threshold)
- mt_capital_gains_tax_indiv.py (default=single rates)
- state_filing_status_if_married_filing_separately_on_same_return.py (default=SINGLE)
- wi_standard_deduction.py (default=single phase out)
- pr_earned_income_credit.py (default=single threshold)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

Use default arg to select instead of a dummy True condition

2 participants