Commit Graph

14 Commits

Author SHA1 Message Date
Cal Corum
8e24b4e686 fix: return default 8 on XBT% parse error in running() (#8)
Closes #8

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-20 21:32:14 -05:00
Cal Corum
0a17745389 Run black and ruff across entire codebase
Standardize formatting with black and apply ruff auto-fixes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 14:24:33 -05:00
Cal Corum
db3822565c Add offense_col resolver for retrosheet pipeline to fix 883 silent KeyErrors
The FullCard migration requires offense_col and player_id on each player's
DataFrame row. The retrosheet pipeline calculates ratings before posting,
so both fields were missing — causing silent card layout builder failures.

Adds a three-tier resolution: CSV cache → API bulk fetch → deterministic
hash fallback. Also includes player_id fallback in both calcs modules.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 15:37:59 -06:00
Cal Corum
39c652e55c Extract BattingCardRatingsModel and PitchingCardRatingsModel into models.py files
Move each ratings model class (and, for batters, the helper functions it
depends on) into a dedicated models.py so that calcs_*.py can import from
card_builder.py at module level without circular imports.

- batters/models.py: BattingCardRatingsModel + bp_singles, wh_singles,
  one_singles, bp_homeruns, triples, two_doubles, hit_by_pitch, strikeouts,
  flyout_a, flyout_bq, flyout_b, groundball_a, groundball_c
- pitchers/models.py: PitchingCardRatingsModel (no helper deps needed)
- batters/calcs_batter.py: imports model + build_batter_full_cards at top
- pitchers/calcs_pitcher.py: imports model + build_pitcher_full_cards at top
- batters/card_builder.py: imports from batters.models
- pitchers/card_builder.py: imports from pitchers.models
- tests/test_batter_calcs.py: import bp_singles, wh_singles from batters.models

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-25 16:42:51 -06:00
Cal Corum
a72abc01a3 Add FullCard/CardColumn/CardResult models and card builder pipeline
- card_layout.py: Port PlayResult, PLAY_RESULTS, EXACT_CHANCES, get_chances(),
  CardResult, CardColumn, FullCard, FullBattingCard, FullPitchingCard from
  database/app/card_creation.py. card_output() uses col_* key names.
  get_chances() always returns Decimal to avoid float/Decimal type errors.

- batters/card_builder.py: Port get_batter_card_data() algorithm as
  build_batter_full_cards(ratings_vl, ratings_vr, offense_col, player_id, hand).
  assign_bchances() returns float tuples for compatibility with float-based
  BattingCardRatingsModel fields.

- pitchers/card_builder.py: Port get_pitcher_card_data() algorithm as
  build_pitcher_full_cards(). assign_pchances() returns float tuples.
  Includes card.add_fatigue() at end of each card iteration.

- batters/calcs_batter.py: Integrate card builder in get_batter_ratings().
  After computing raw ratings, call build_batter_full_cards() and merge
  9 col_* rendered column fields into each ratings dict. Lazy import to
  avoid circular dependency.

- pitchers/calcs_pitcher.py: Same integration for get_pitcher_ratings().

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-25 16:21:26 -06:00
Cal Corum
25d4d9a63c Migrate to rotating file logger 2024-11-10 14:42:12 -06:00
Cal Corum
3388c4e0c5 Pitching peripherals done 2024-10-26 20:18:54 -05:00
Cal Corum
b3102201c8 Added Devil Rays to club and franchise lists
Fixed bphr fraction bug
Removed player post limit
2024-10-25 12:24:08 -05:00
Cal Corum
5c6d706160 Player post complete
Batting card post complete
2024-10-25 07:06:06 -05:00
Cal Corum
eb79430de7 Calc rate stats on batting ratings for cost calcs 2024-10-20 22:56:58 -05:00
Cal Corum
d8e30ec5f9 Batting cards and ratings being calculated; began positions 2024-10-19 23:02:32 -05:00
Cal Corum
9a1e98db96 Triples bug fix 2024-07-01 14:35:14 -05:00
Cal Corum
0c77f3971d S7 cleanup and SSS bug fixes 2024-04-28 15:32:05 -05:00
Cal Corum
92e5240e65 Refactor pit/bat/def to modules 2023-11-05 12:18:42 -06:00