Skip to content

Compute run rate from balls, not from the overs figure - #94

Open
dhairyapathak2005-cmyk wants to merge 1 commit into
outside-edge:masterfrom
dhairyapathak2005-cmyk:fix/run-rate-part-overs
Open

dhairyapathak2005-cmyk wants to merge 1 commit into
outside-edge:masterfrom
dhairyapathak2005-cmyk:fix/run-rate-part-overs

Conversation

@dhairyapathak2005-cmyk

Copy link
Copy Markdown

What

Match.team_1_run_rate, Match.team_2_run_rate and each innings' run_rate are too high for any innings that ends mid-over (a completed chase, a side bowled out).

Why

ESPN writes overs in cricket notation: 19.4 is 19 overs and 4 balls. _normalize divided runs by that figure, so 159 off 19.4 overs came out at 8.2 an over instead of 8.08. The recorded fixture shows the notation: its partnerships pair overs: 13.4 with balls: 82.

Change

  • New _run_rate helper divides by balls bowled, using ESPN's balls and ballsPerOver. When balls is missing it converts the overs figure.
  • Innings of whole overs are unchanged (the fixture's 8.8 and 7.95 stay).
  • Four tests, including one that loads the fixture with the second innings ending at 19.4 overs. Changelog entry under Unreleased.

Testing

uv run pytest (153 passed, 18 live tests skipped), ruff check, ruff format --check and pyright are clean. I did not run the --live tests, so this is not checked against a live match page.

🤖 Generated with Claude Code

https://claude.ai/code/session_011R2whb7Ajr1ogzUchRBNVy

ESPN writes overs in cricket notation: 19.4 is 19 overs and 4 balls. The
innings run rate divided runs by that figure, so any innings that ended
mid-over (a completed chase, a side bowled out) got too high a rate:
159 off 19.4 overs came out at 8.2 instead of 8.08.

Divide by the balls bowled instead. ESPN's innings record carries `balls`
and `ballsPerOver`; when `balls` is missing, convert the overs figure.
The recorded fixture shows the notation: its partnerships pair overs 13.4
with balls 82. Innings of whole overs are unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011R2whb7Ajr1ogzUchRBNVy

This branch has not been deployed

No deployments
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.

1 participant