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
47 changes: 16 additions & 31 deletions draftfast/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,52 +252,37 @@ def __init__(
def get_player_id(self, player_map):
return player_map[self.name + ' ' + self.possible_positions]

def to_table_row(self):
return [
self.formatted_position,
self.name,
self.team,
self.matchup,
cs(self.cost),
self.proj,
self.__format_v_avg(),
'LOCK' if self.lock else ''
]

def to_exposure_table_row(self, n, s_min, s_max):
return [
self.formatted_position,
self.name,
self.team,
self.matchup,
cs(self.cost),
self.proj,
n,
s_min,
s_max
]

def is_opposing_team_in_match_up(self, team):
return (team.upper() != self.team.upper()) and \
(team.upper() in self.matchup.upper())

def __repr__(self):
def __get_player_dict(self):
v_avg = self.__format_v_avg()
player_dict = dict(
pos=self.formatted_position,
name=self.name,
team=self.team,
match=self.matchup,
cost=cs(self.cost),
proj=self.proj,
proj='{:0.2f}'.format(self.proj),
v_avg=v_avg,
lock='LOCK' if self.lock else ''
)
return player_dict

def to_table_row(self):
return [v for k,v in self.__get_player_dict().items()]

def __repr__(self):
player_dict = self.__get_player_dict()
return "[{pos: <2}] {name: <20} {team} {match} " \
"(${cost}, {proj} ({v_avg})), {lock}".format(
**player_dict)

def to_exposure_table_row(self, n, s_min, s_max):
row = [v for k,v in self.__get_player_dict()][:-2]
row += [n, s_min, s_max]

def is_opposing_team_in_match_up(self, team):
return (team.upper() != self.team.upper()) and \
(team.upper() in self.matchup.upper())

def __eq__(self, player):
return self.pos == player.pos and \
self.name == player.name and \
Expand Down
1 change: 1 addition & 0 deletions draftfast/test/test_exposure.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def test_deterministic_exposure_limits():
{'name': 'Andrew Luck', 'min': 0.5, 'max': 0.7},
{'name': 'Alshon Jeffery', 'min': 1, 'max': 1},
],
verbose=True,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this is debugging cruft :-)

)
ntools.assert_equal(len(rosters), iterations)
ntools.assert_equal(len(exposure_diffs), 0)
Expand Down