Created
June 10, 2017 15:16
-
-
Save dkmehrmann/d3b66767ffc284c5fe12719caca785ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import sys | |
from nhlscrapi.games.game import Game, GameKey, GameType | |
from nhlscrapi.games.cumstats import Score, ShotCt, Corsi, Fenwick | |
print(sys.version) | |
season = 2014 # 2013-2014 season | |
game_num = 1226 # | |
game_type = GameType.Regular # regular season game | |
game_key = GameKey(season, game_type, game_num) | |
# define stat types that will be counted as the plays are parsed | |
cum_stats = { | |
'Score': Score(), | |
'Shots': ShotCt(), | |
'Corsi': Corsi(), | |
'Fenwick': Fenwick() | |
} | |
game = Game(game_key, cum_stats=cum_stats) | |
print('\nTest 1\n') | |
print('\n-----------------OUTPUT-----------------\n') | |
print(game.cum_stats) | |
print('\n----------------EXPECTED----------------\n') | |
print("""{'Corsi': <nhlscrapi.games.cumstats.Corsi at 0x7fb5c4694090>, | |
'Fenwick': <nhlscrapi.games.cumstats.Fenwick at 0x7fb5c46940d0>, | |
'Score': <nhlscrapi.games.cumstats.Score at 0x7fb5c468cfd0>, | |
'Shots': <nhlscrapi.games.cumstats.ShotCt at 0x7fb5cc0be210>}""") | |
print('\nTest 2\n') | |
print('\n-----------------OUTPUT-----------------\n') | |
print('Final : {}'.format(game.cum_stats['Score'].total)) | |
print('Shootout : {}'.format(game.cum_stats['Score'].shootout.total)) | |
print('Shots : {}'.format(game.cum_stats['Shots'].total)) | |
print('EV Shot Atts : {}'.format(game.cum_stats['Corsi'].total)) | |
print('Corsi : {}'.format(game.cum_stats['Corsi'].share())) | |
print('FW Shot Atts : {}'.format(game.cum_stats['Fenwick'].total)) | |
print('Fenwick : {}'.format(game.cum_stats['Fenwick'].share())) | |
# http req for roster report | |
# only parses the sections related to officials and coaches | |
print('\nRefs : {}'.format(game.refs)) | |
print('Linesman : {}'.format(game.linesman)) | |
print('Coaches') | |
print(' Home : {}'.format(game.home_coach)) | |
print(' Away : {}'.format(game.away_coach)) | |
print('\n----------------EXPECTED----------------\n') | |
print("""Final : {'OTT': 3, 'PIT': 2} | |
Shootout : {'OTT': 2, 'PIT': 0} | |
Shots : {'OTT': 33, 'PIT': 28} | |
EV Shot Atts : {'OTT': 39, 'PIT': 36} | |
Corsi : {'PIT': 0.48, 'OTT': 0.52} | |
FW Shot Atts : {'OTT': 29, 'PIT': 30} | |
Fenwick : {'PIT': 0.5084745762711864, 'OTT': 0.4915254237288136} | |
Refs : {12: 'Justin St. Pierre', 20: 'Tim Peel'} | |
Linesman : {82: 'Ryan Galloway', 76: 'Michel Cormier'} | |
Coaches | |
Home : DAN BYLSMA | |
Away : PAUL MACLEAN""") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment