Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NFL Rosters Not Finding Any Players #723

Open
joeyagreco opened this issue Apr 17, 2022 · 1 comment
Open

NFL Rosters Not Finding Any Players #723

joeyagreco opened this issue Apr 17, 2022 · 1 comment

Comments

@joeyagreco
Copy link

joeyagreco commented Apr 17, 2022

Describe the bug
Upon instantiating a roster for a given team, the players field will always be an empty list (or dict).

To Reproduce
Sample code:

import sportsipy.nfl.roster as roster

if __name__ == '__main__':
    r = roster.Roster("GNB", year=2010, slim=True)
    print(r.players)

Expected behavior
Should print a list of Player objects from the 2010 Green Bay Packers.

Desktop (please complete the following information):

  • OS: Windows 10
  • Sportsipy Version: 0.6.0
@cbdm
Copy link

cbdm commented May 14, 2022

Looks like they saw this issue a little back but the fix didn't make it to the pip version yet: fd33a4f.
If you're using a virtual environment, you can just modify that same file in your installed version (VENV_PATH/lib/pythonXX/site-packages/sportsipy/nfl/roster.py), or you can follow the instructions on the readme to install from source.

However, I still had a problem even with their solution.
If not using the _slim=True option, player names were not correctly populated.

So when I was debugging this problem with something like:

from sportsipy.nfl.teams import Teams as NFL_Teams
teams = NFL_Teams()
for team in teams:
    print(team.roster.__dict__)

My output was something like this:

{'_team': 'DAL', '_slim': False, '_coach': 'Mike McCarthy', '_players': [None (AnaeBr00), None (AngeBr00), None (ArmsDo00), None (BashTa00), None (BernFr01), None (BiadTy00), None (BohaQu00), None (BrowAn02), None (BrowKy00), None (BrowNo00), None (BuntIa00), None (BurtDe00), None (CanaMa00), None (ClemCo00), None (CollLa01), None (CoopAm00), None (CoxxJa00), None (CoylTy00), None (DiggTr00), None (ElliEz00), None (FaolAu00), None (FarnMa00), None (FehoSi00), None (GallNe00), None (GallMi00), None (GiffLu00), None (GolsCh00), None (GoodC.00), None (GregRa00), None (HajrLi00), None (HamiJu00), None (HardJa01), None (HillTr00), None (HookMa00), None (JarwBl00), None (JoseKe02), None (KamaAz01), None (KazeDa00), None (KearJa00), None (KnigBr01), None (LambCe00), None (LawrDe00), None (LewiJo01), None (MartZa00), None (McGoCo01), None (McKeSe01), None (McQuJa00), None (MukuIs00), None (NealKe01), None (NsekTy00), None (OdigOs00), None (ParsMi00), None (PollTo00), None (PresDa01), None (RalsNi00), None (RushCo00), None (SchuDa00), None (SmitIt00), None (SmitJa05), None (SmitTy00), None (SpriJe00), None (SteeTe01), None (ThomDa05), None (TurnMa00), None (UrbaBr00), None (VandLe00), None (WatkCa00), None (WillCo00), None (WilsCe01), None (WilsDo01), None (WrigNa00), None (ZuerGr00)]}

You can see that the player_ids are correct but all their names are missing (i.,e., None); but if you dig into a player object it has all stats populated*.
So I added another change around those lines to populate the names also; I added player_instance._name = self._get_name(player) after the Player instance is created in line 1876 of the same file.
This is obviously not the best solution, _name was supposed to be set in _parse_player_information, but it's a quick and dirty fix to get us unstuck :)

* '_most_recent_season' wasn't set correctly in the one I checked:

>>> player
None (AdamMi21)
>>> player.__dict__
{'_most_recent_season': '2011', ..., '_player_id': 'AdamMi21', '_season': ['2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', 'Career'], ...}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants