sol.models.rating
-- Ratings¶
-
class
sol.models.rating.
Rating
(**kwargs)¶ A particular rating a tournament can be related to.
-
championships
¶ Championships
using this rating by default.
-
classmethod
check_insert
(session, fields, user_id)¶ Check description validity
-
check_update
(fields)¶ Check description validity
-
default_deviation
¶ Default value of deviation (PHI) for the Glicko2 algorithm.
-
default_rate
¶ Default value of rate (MU) for the Glicko2 algorithm.
-
default_volatility
¶ Default value of volatility (SIGMA) for the Glicko2 algorithm.
-
description
¶ Description of the rating.
-
getPlayerRating
(player, before=None)¶ Return the rate of a player
- Parameters
player -- a Player instance
before -- a date instance
- Return type
an instance of glicko2.Rating
If before is not specified fetch the latest rate, otherwise the most recent one preceeding before.
The method considers the referenced rating as well as all those with an higher level.
-
higher_rate
¶ Higher value of the range used to interpolate players rates.
-
idrating
¶ Primary key.
-
inherit
¶ Whether to lookup rates in higher levels ratings.
-
isPhantom
(competitor)¶ Determine whether the given competitor is actually a Phantom.
- Parameters
competitor -- a Competitor instance
This is needed because someone use a concrete player as Phantom, to customize its name (not everybody have a good sense of humor…)
-
level
¶ Rating level.
-
lower_rate
¶ Lower value of the range used to interpolate players rates when (almost) all competitors are unrated.
-
outcomes
¶ Kind of formula used to compute match outcomes.
This is used to determine which formula will be used to compute the match outcomes to feed Glicko2 algorithm. It may be:
- glicko2
standard Glicko, giving 1.0 to the winner and 0.0 to the loser, 0.5 in case of draw, developed with Chess in mind;
- guido
Guido's variant, better suited to Carrom: basically each player is assigned a fraction of his own score divided by the sum of the scores of both players;
- expds
an exponential formula applied to the two concurrents final scores difference.
-
property
ranking
¶ Players sorted by their latest rate.
- Return type
sequence
- Returns
a sorted list of tuples containing the
player
, its latest rate, deviation and volatility, and the number of rates in this rating.
-
recompute
(mindate=None, scratch=False)¶ Recompute the whole rating.
- Parameters
mindate -- either
None
or a datescratch -- a boolean, True to recompute from scratch
If mindate is given, recompute the rating ignoring the tourneys before that date.
-
serialize
(serializer)¶ Reduce a single rating to a simple dictionary.
- Parameters
serializer -- a
Serializer
instance- Return type
dict
- Returns
a plain dictionary containing a flatified view of this rating
-
shouldConsiderTourney
(tourney)¶ Determine whether the given tourney should be considered.
- Parameters
tourney -- a Tourney instance
Only singles using the Swiss System should be considered. Also, "online" tournaments are excluded.
-
tau
¶ Value of TAU for the Glicko2 algorithm.
-
property
time_span
¶ Return the time span of this rating.
-
update
(data, missing_only=False)¶ Update entity with given data.
- Parameters
data -- a mapping kind of container
missing_only -- a boolean flag,
False
by default
- Return type
dict
- Returns
a mapping between field name and a tuple
(oldvalue, newvalue)
, for each modified field
First call
check_update()
to assert the validity of incoming data, then update the instance fields.If missing_only is
True
then only the fields that are currently empty (that is, their value is eitherNone
or an empty string) are updated. Note that in this case an exception is made forbool
fields: since in SoL they always have a value (i.e. they are never missing), they are always updated.
-