Skip to content

Commit

Permalink
Merge pull request #398 from cwendt94/bb_fix_player_season_stats
Browse files Browse the repository at this point in the history
Basketball Fix Player Season Stats
  • Loading branch information
cwendt94 authored Nov 8, 2022
2 parents 63ebc23 + 719fc9f commit d95d441
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion espn_api/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.26.1'
__version__ = '0.26.2'
1 change: 1 addition & 0 deletions espn_api/basketball/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
}

STAT_ID_MAP = {
'00': 'total',
'10': 'projected',
'01': 'last_7',
'02': 'last_15',
Expand Down
4 changes: 2 additions & 2 deletions espn_api/basketball/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def __init__(self, data, year, pro_team_schedule = None):
else:
self.stats[id]['avg'] = None
self.stats[id]['total'] = {STATS_MAP[i]: split['stats'][i] for i in split['stats'].keys() if STATS_MAP[i] != ''}
self.total_points = self.stats.get(f'{year}', {}).get('applied_total', 0)
self.avg_points = self.stats.get(f'{year}', {}).get('applied_avg', 0)
self.total_points = self.stats.get(f'{year}_total', {}).get('applied_total', 0)
self.avg_points = self.stats.get(f'{year}_total', {}).get('applied_avg', 0)
self.projected_total_points= self.stats.get(f'{year}_projected', {}).get('applied_total', 0)
self.projected_avg_points = self.stats.get(f'{year}_projected', {}).get('applied_avg', 0)

Expand Down
8 changes: 5 additions & 3 deletions tests/basketball/integration/test_league.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ def test_league_init(self):

self.assertEqual(league.scoringPeriodId, 178)
player = league.teams[0].roster[0]
self.assertAlmostEqual(player.schedule['2']['team'], 'BKN')
self.assertEqual(player.schedule['2']['team'], 'BKN')
self.assertEqual(player.total_points, 3583.0)
self.assertEqual(player.avg_points, 45.35)

def test_league_scoreboard(self):
league = League(411647, 2019)
Expand Down Expand Up @@ -53,12 +55,12 @@ def test_league_box_scores(self):
def test_league_box_scores_category(self):
league = League(1631984064, 2023)

score = league.box_scores(scoring_period=15, matchup_total=False)
score = league.box_scores(matchup_period=3, scoring_period=21)

self.assertEqual(score[0].__repr__(), 'Box Score(Team(Team McWilliams) at Team(Team Wendt))')
self.assertEqual(score[0].away_lineup[0].name, 'Stephen Curry')
# comment for now until matchup week is over
# self.assertEqual(score[0].away_stats['PTS'], { 'value': 195.0, 'result': 'LOSS' })
self.assertEqual(score[0].away_stats['PTS'], { 'value': 733.0, 'result': 'WIN' })

def test_past_league(self):
league = League(411647, 2017)
Expand Down

0 comments on commit d95d441

Please sign in to comment.