Skip to content

Commit

Permalink
0.4.1: deprecate dynamic_draw_probability
Browse files Browse the repository at this point in the history
  • Loading branch information
sublee committed Jun 6, 2013
1 parent bd2314a commit 3543d52
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 33 deletions.
7 changes: 7 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 0.4.1
-------------

Released on Jun 6th 2013.

- Deprecates :func:`dynamic_draw_probability`.

Version 0.4
-----------

Expand Down
36 changes: 5 additions & 31 deletions trueskill/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from .mathematics import Gaussian, Matrix


__version__ = '0.4.1.dev'
__version__ = '0.4.1'
__all__ = [
# TrueSkill objects
'TrueSkill', 'Rating',
Expand All @@ -28,9 +28,9 @@
# default values
'MU', 'SIGMA', 'BETA', 'TAU', 'DRAW_PROBABILITY',
# draw probability helpers
'calc_draw_probability', 'calc_draw_margin', 'dynamic_draw_probability',
'calc_draw_probability', 'calc_draw_margin',
# deprecated features
'transform_ratings', 'match_quality',
'transform_ratings', 'match_quality', 'dynamic_draw_probability',
]


Expand Down Expand Up @@ -74,33 +74,6 @@ def calc_draw_margin(draw_probability, size, env=None):
return env.ppf((draw_probability + 1) / 2.) * math.sqrt(size) * env.beta


def dynamic_draw_probability(rating1, rating2, env=None):
"""The draw probability calculator which has been used on Xbox LIVE.
Set ``draw_probability`` option to this for using it::
TrueSkill(draw_probability=dynamic_draw_probability)
.. seealso::
Page 8 of `MSR-TR-2006-80 <http://research.microsoft.com/apps/pubs/
default.aspx?id=74419>`_.
:param rating1: the performance of the left team.
:param rating2: the performance of the right team.
:param env: the :class:`TrueSkill` object. Defaults to the global
environment.
.. versionadded:: 0.4
"""
if env is None:
env = global_env()
_2beta2 = 2 * env.beta ** 2
denom = _2beta2 + rating1.sigma ** 2 + rating2.sigma ** 2
delta = rating1.mu - rating2.mu
return math.sqrt(_2beta2 / denom) * math.exp(-delta ** 2 / (2 * denom))


def _team_sizes(rating_groups):
"""Makes a size map of each teams."""
team_sizes = [0]
Expand Down Expand Up @@ -715,5 +688,6 @@ def expose(rating):

# append deprecated methods into :class:`TrueSkill` and :class:`Rating`
from . import deprecated
from .deprecated import transform_ratings, match_quality
from .deprecated import (transform_ratings, match_quality,
dynamic_draw_probability)
deprecated.ensure_backward_compatibility(TrueSkill, Rating)
13 changes: 12 additions & 1 deletion trueskill/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from . import Rating, expose, global_env, rate_1vs1, quality_1vs1, DELTA


__all__ = ['transform_ratings', 'match_quality',
__all__ = ['transform_ratings', 'match_quality', 'dynamic_draw_probability',
'ensure_backward_compatibility']


Expand All @@ -28,6 +28,17 @@ def match_quality(rating_groups):
return global_env().match_quality(rating_groups)


def dynamic_draw_probability(rating1, rating2, env=None):
"""Deprecated. It was an approximation for :func:`quality_1vs1`.
.. deprecated:: 0.4.1
Use :func:`quality_1vs1` instead.
"""
from warnings import warn
warn('Use quality_1vs1 instead', DeprecationWarning)
return quality_1vs1(rating1, rating2, env=env)


# deprecated methods


Expand Down
4 changes: 3 additions & 1 deletion trueskilltests.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def test_deprecated_methods():
deprecated_call(env.rate_1vs1, r1, r2)
deprecated_call(env.quality_1vs1, r1, r2)
deprecated_call(lambda: Rating().exposure)
dyn = TrueSkill(draw_probability=dynamic_draw_probability)
deprecated_call(dyn.rate, [(r1,), (r2,)])


def test_deprecated_individual_rating_groups():
Expand Down Expand Up @@ -213,7 +215,7 @@ def generate_teams(sizes, env=None):


def generate_individual(size, env=None):
return generate_teams([1] * size, env)
return generate_teams([1] * size, env=env)


@various_backends
Expand Down

0 comments on commit 3543d52

Please sign in to comment.