Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.

## [Unreleased]
### Patched
- Fixed issue where inactive members from past seasons messed up
power rankings

### Patched
- Fixed output for possibility the attribute doesn't exist in the API

Expand Down
11 changes: 10 additions & 1 deletion espnff/league.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,19 @@ def power_rankings(self, week):
teams_sorted = sorted(self.teams, key=lambda x: x.team_id,
reverse=False)

# deleted members from previous years still hold a team_id, so
# create a new mapping of team id to dominance matrix row/column
matrix_position_map = {}
count = 0
for team in teams_sorted:
matrix_position_map[team.team_id] = count
count += 1

# loop through our teams and create a matrix of wins
for team in teams_sorted:
wins = [0]*32
for mov, opponent in zip(team.mov[:week], team.schedule[:week]):
opp = int(opponent.team_id)-1
opp = matrix_position_map[opponent.team_id]
if mov > 0:
wins[opp] += 1
win_matrix.append(wins)
Expand Down