Skip to content

Use np.isin for country check in winter_fuel_allowance (#257)#1650

Merged
MaxGhenis merged 1 commit intomainfrom
refactor/np-isin-wfa-257
May 1, 2026
Merged

Use np.isin for country check in winter_fuel_allowance (#257)#1650
MaxGhenis merged 1 commit intomainfrom
refactor/np-isin-wfa-257

Conversation

@vahid-ahmadi
Copy link
Copy Markdown
Collaborator

Summary

Replace (country == "ENGLAND") | (country == "WALES") in policyengine_uk/variables/gov/dwp/winter_fuel_allowance.py with np.isin(country, ["ENGLAND", "WALES"]), per the cleanup asked for in #257.

This is one of only two OR-chained equality patterns still in the repo — the other is (band == bands.HIGHER) | (band == bands.ADDITIONAL) in reforms/cps/marriage_tax_reforms.py, which I left alone: np.isin does not work on raw EnumArray (verified empirically — it returns all-False). Making that one work with np.isin would require first calling .decode_to_str() and comparing against string names, which is less idiomatic than the current enum comparison, so that cleanup is arguably not an improvement.

Closes #257 — leaves the codebase free of genuine OR-chained equality cases where np.isin is a clearer alternative.

Test plan

  • All 6 baseline YAML tests in policyengine_uk/tests/policy/baseline/gov/dwp/winter_fuel_allowance.yaml pass.
  • CI green.

🤖 Generated with Claude Code

One of the last OR-chained equality checks in the codebase. All 6
baseline winter-fuel YAML tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vahid-ahmadi vahid-ahmadi self-assigned this Apr 29, 2026
Copy link
Copy Markdown
Collaborator

@MaxGhenis MaxGhenis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed: the country predicate is equivalent to the prior England/Wales OR check and follows existing np usage. CI is green.

@MaxGhenis MaxGhenis merged commit ac3aba4 into main May 1, 2026
8 checks passed
@MaxGhenis MaxGhenis deleted the refactor/np-isin-wfa-257 branch May 1, 2026 16:33
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 np.isin instead of adding == conditions

2 participants