Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Returns a dict containing the FDR for each team, which is
calculated by scaling the average points conceded per position
between 1.0 and 5.0 using the given extrema.
:param dict points_against: A dict containing the points scored
against each team in the Premier League.
:param dict extrema: A dict containing the extrema for each
position and location.
:rtype: dict
"""
for team, positions in average_points.items():
for position, locations in positions.items():
min_h, max_h = extrema[position]["H"]
min_a, max_a = extrema[position]["A"]
fdr_h = scale(locations["H"], 5.0, 1.0, min_h, max_h)
fdr_a = scale(locations["A"], 5.0, 1.0, min_a, max_a)
average_points[team][position]["H"] = fdr_h
average_points[team][position]["A"] = fdr_a
return average_points
calculated by scaling the average points conceded per position
between 1.0 and 5.0 using the given extrema.
:param dict points_against: A dict containing the points scored
against each team in the Premier League.
:param dict extrema: A dict containing the extrema for each
position and location.
:rtype: dict
"""
for team, positions in average_points.items():
for position, locations in positions.items():
min_h, max_h = extrema[position]["H"]
min_a, max_a = extrema[position]["A"]
fdr_h = scale(locations["H"], 5.0, 1.0, min_h, max_h)
fdr_a = scale(locations["A"], 5.0, 1.0, min_a, max_a)
average_points[team][position]["H"] = fdr_h
average_points[team][position]["A"] = fdr_a
return average_points