Skip to content

Change hours_worked label to 'Hours worked per week'#1609

Merged
MaxGhenis merged 2 commits intomainfrom
fix/hours-worked-label-451
Apr 20, 2026
Merged

Change hours_worked label to 'Hours worked per week'#1609
MaxGhenis merged 2 commits intomainfrom
fix/hours-worked-label-451

Conversation

@vahid-ahmadi
Copy link
Copy Markdown
Collaborator

Summary

  • Updates the hours_worked variable label from "Total amount of hours worked by this person" to "Hours worked per week"
  • The variable represents weekly hours (divided by WEEKS_IN_YEAR for weekly_hours, multiplied by 52 for annual wage calculations)

Fixes #451

Test plan

  • Verify label appears correctly in the PolicyEngine app

🤖 Generated with Claude Code

The variable represents weekly hours (used as hours/52 for weekly_hours
and hours*52 for annual calculations), so the label should reflect this.
Fixes #451.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vahid-ahmadi vahid-ahmadi requested a review from MaxGhenis April 16, 2026 12:26
@MaxGhenis
Copy link
Copy Markdown
Collaborator

The proposed label "Hours worked per week" contradicts how hours_worked is defined in the model:

  • policyengine-uk-data/policyengine_uk_data/datasets/frs.py:129 builds the input as hours_worked = tothours * 52 — i.e. FRS weekly hours scaled up to an annual figure.
  • policyengine_uk/variables/household/income/weekly_hours.py defines weekly_hours = hours_worked / WEEKS_IN_YEAR, which only makes sense if hours_worked is annual.

So hours_worked is an annual hours variable. Changing the label to "Hours worked per week" would cause model users to interpret e.g. 2,000 as weekly hours instead of ~40 weekly / ~2,000 annual — the kind of off-by-52 bug that's painful to spot after the fact.

If the intent is to make it friendlier, the accurate replacement is something like "Annual hours worked". If you'd rather change the semantics to weekly, that's a much bigger change — we'd also need to update frs.py to drop the * 52, update weekly_hours.py, and find any downstream callers that divide/multiply by WEEKS_IN_YEAR.

Flagging as blocking until one of those is chosen. Happy to push a one-line change to "Annual hours worked" if that's what you want.

hours_worked is annual: FRS input builds it as tothours * 52, and
weekly_hours divides it by WEEKS_IN_YEAR. A "per week" label would
misrepresent the variable by a factor of 52.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vahid-ahmadi
Copy link
Copy Markdown
Collaborator Author

Good catch — you're right, hours_worked is annual. Verified:

  • policyengine-uk-data/.../frs.py builds it as tothours * 52
  • variables/household/income/weekly_hours.py:16 derives weekly as hours_worked / WEEKS_IN_YEAR
  • dynamics/labour_supply.py:286 computes hours_per_week = hours_worked / 52
  • Test values (e.g. 1500, 1800, 2200) are annual-scale

Pushed 3d82a25c changing the label to "Annual hours worked" and updated the changelog entry to match. Keeping semantics as-is — not switching to weekly.

@vahid-ahmadi vahid-ahmadi self-assigned this Apr 17, 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.

Verified against the formula: weekly_hours = hours_worked / WEEKS_IN_YEAR, so hours_worked is annual. The updated label "Annual hours worked" matches. The PR title/body still say "per week" — that was an earlier draft; the actual diff is correct. Approving.

@MaxGhenis MaxGhenis merged commit 1d0e238 into main Apr 20, 2026
2 checks passed
@MaxGhenis MaxGhenis deleted the fix/hours-worked-label-451 branch April 20, 2026 11:24
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.

Change label for hours_worked

2 participants