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>
22 lines
390 B
Python
22 lines
390 B
Python
from decimal import ROUND_HALF_EVEN, Decimal
|
|
import math
|
|
|
|
from batters.models import bp_singles, wh_singles
|
|
|
|
|
|
|
|
def test_decimals():
|
|
assert Decimal(8) == 8
|
|
|
|
|
|
def test_bp_singles():
|
|
assert bp_singles(23) == 5
|
|
assert bp_singles(6) == 5
|
|
assert bp_singles(3) == 0
|
|
|
|
|
|
def test_wh_singles():
|
|
assert wh_singles(11, .36) == 3.75
|
|
assert wh_singles(12, .45) == Decimal('7.95')
|
|
|