77 lines
4.8 KiB
Python
77 lines
4.8 KiB
Python
"""
|
|
Test script to verify the new rarity thresholds work correctly.
|
|
"""
|
|
|
|
from rarity_thresholds import get_pitcher_thresholds, get_batter_thresholds
|
|
|
|
|
|
def test_joe_boyle():
|
|
"""Test Joe Boyle's rarity assignment with new thresholds."""
|
|
# Joe Boyle's stats from the analysis
|
|
joe_boyle_ops = 0.365
|
|
starter_rating = 4
|
|
|
|
# Old 2024 thresholds
|
|
old_thresholds = get_pitcher_thresholds(2024)
|
|
old_rarity = old_thresholds.get_rarity_for_starter(joe_boyle_ops)
|
|
|
|
# New 2025 thresholds
|
|
new_thresholds = get_pitcher_thresholds(2025)
|
|
new_rarity = new_thresholds.get_rarity_for_starter(joe_boyle_ops)
|
|
|
|
print("Joe Boyle Test:")
|
|
print(f" OPS-against: {joe_boyle_ops}")
|
|
print(f" Starter Rating: {starter_rating}")
|
|
print(f"\n 2024 Thresholds:")
|
|
print(f" HOF threshold: <= {old_thresholds.starter_hof}")
|
|
print(f" Assigned Rarity: {old_rarity} ({'Hall of Fame' if old_rarity == 99 else 'Diamond' if old_rarity == 1 else 'Gold' if old_rarity == 2 else 'Silver' if old_rarity == 3 else 'Bronze' if old_rarity == 4 else 'Common'})")
|
|
print(f"\n 2025 Thresholds:")
|
|
print(f" HOF threshold: <= {new_thresholds.starter_hof}")
|
|
print(f" Assigned Rarity: {new_rarity} ({'Hall of Fame' if new_rarity == 99 else 'Diamond' if new_rarity == 1 else 'Gold' if new_rarity == 2 else 'Silver' if new_rarity == 3 else 'Bronze' if new_rarity == 4 else 'Common'})")
|
|
|
|
assert old_rarity == 99, "Joe Boyle should be HOF with 2024 thresholds"
|
|
assert new_rarity != 99, "Joe Boyle should NOT be HOF with 2025 thresholds"
|
|
print("\n ✓ Test passed! Joe Boyle is no longer HOF with 2025 thresholds")
|
|
|
|
|
|
def test_threshold_ranges():
|
|
"""Test that thresholds are correctly ordered."""
|
|
pitcher_2024 = get_pitcher_thresholds(2024)
|
|
pitcher_2025 = get_pitcher_thresholds(2025)
|
|
batter_2024 = get_batter_thresholds(2024)
|
|
batter_2025 = get_batter_thresholds(2025)
|
|
|
|
print("\n\nThreshold Comparison:")
|
|
print("\nStarter Thresholds (lower OPS-against is better):")
|
|
print(f" {'Rarity':<15} {'2024':<10} {'2025':<10} {'Change':<10}")
|
|
print(f" {'-'*45}")
|
|
print(f" {'Hall of Fame':<15} {pitcher_2024.starter_hof:<10.3f} {pitcher_2025.starter_hof:<10.3f} {pitcher_2025.starter_hof - pitcher_2024.starter_hof:+.3f}")
|
|
print(f" {'Diamond':<15} {pitcher_2024.starter_diamond:<10.3f} {pitcher_2025.starter_diamond:<10.3f} {pitcher_2025.starter_diamond - pitcher_2024.starter_diamond:+.3f}")
|
|
print(f" {'Gold':<15} {pitcher_2024.starter_gold:<10.3f} {pitcher_2025.starter_gold:<10.3f} {pitcher_2025.starter_gold - pitcher_2024.starter_gold:+.3f}")
|
|
print(f" {'Silver':<15} {pitcher_2024.starter_silver:<10.3f} {pitcher_2025.starter_silver:<10.3f} {pitcher_2025.starter_silver - pitcher_2024.starter_silver:+.3f}")
|
|
print(f" {'Bronze':<15} {pitcher_2024.starter_bronze:<10.3f} {pitcher_2025.starter_bronze:<10.3f} {pitcher_2025.starter_bronze - pitcher_2024.starter_bronze:+.3f}")
|
|
|
|
print("\nReliever Thresholds (lower OPS-against is better):")
|
|
print(f" {'Rarity':<15} {'2024':<10} {'2025':<10} {'Change':<10}")
|
|
print(f" {'-'*45}")
|
|
print(f" {'Hall of Fame':<15} {pitcher_2024.reliever_hof:<10.3f} {pitcher_2025.reliever_hof:<10.3f} {pitcher_2025.reliever_hof - pitcher_2024.reliever_hof:+.3f}")
|
|
print(f" {'Diamond':<15} {pitcher_2024.reliever_diamond:<10.3f} {pitcher_2025.reliever_diamond:<10.3f} {pitcher_2025.reliever_diamond - pitcher_2024.reliever_diamond:+.3f}")
|
|
print(f" {'Gold':<15} {pitcher_2024.reliever_gold:<10.3f} {pitcher_2025.reliever_gold:<10.3f} {pitcher_2025.reliever_gold - pitcher_2024.reliever_gold:+.3f}")
|
|
print(f" {'Silver':<15} {pitcher_2024.reliever_silver:<10.3f} {pitcher_2025.reliever_silver:<10.3f} {pitcher_2025.reliever_silver - pitcher_2024.reliever_silver:+.3f}")
|
|
print(f" {'Bronze':<15} {pitcher_2024.reliever_bronze:<10.3f} {pitcher_2025.reliever_bronze:<10.3f} {pitcher_2025.reliever_bronze - pitcher_2024.reliever_bronze:+.3f}")
|
|
|
|
print("\nBatter Thresholds (higher OPS is better):")
|
|
print(f" {'Rarity':<15} {'2024':<10} {'2025':<10} {'Change':<10}")
|
|
print(f" {'-'*45}")
|
|
print(f" {'Hall of Fame':<15} {batter_2024.hof:<10.3f} {batter_2025.hof:<10.3f} {batter_2025.hof - batter_2024.hof:+.3f}")
|
|
print(f" {'Diamond':<15} {batter_2024.diamond:<10.3f} {batter_2025.diamond:<10.3f} {batter_2025.diamond - batter_2024.diamond:+.3f}")
|
|
print(f" {'Gold':<15} {batter_2024.gold:<10.3f} {batter_2025.gold:<10.3f} {batter_2025.gold - batter_2024.gold:+.3f}")
|
|
print(f" {'Silver':<15} {batter_2024.silver:<10.3f} {batter_2025.silver:<10.3f} {batter_2025.silver - batter_2024.silver:+.3f}")
|
|
print(f" {'Bronze':<15} {batter_2024.bronze:<10.3f} {batter_2025.bronze:<10.3f} {batter_2025.bronze - batter_2024.bronze:+.3f}")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
test_joe_boyle()
|
|
test_threshold_ranges()
|
|
print("\n\n✅ All tests passed!")
|