Skip to content

Commit

Permalink
Merge 8a83807 into e35d727
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Sep 7, 2018
2 parents e35d727 + 8a83807 commit d807cb0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
language: python
python:
- 2.6
- 2.7
- 3.3
- 3.4
- 3.5
- 3.5-dev
- nightly
- pypy
- pypy3

matrix:
fast_finish: true
allow_failures:
- python: nightly

install:
- pip install -e .
- pip install coveralls

script:
- coverage run --source=trueskill setup.py test

after_success:
- coveralls
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,18 @@ def run_tests(self):
long_description=__doc__,
platforms='any',
packages=['trueskill'],
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
classifiers=['Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: Jython',
'Programming Language :: Python :: Implementation :: PyPy',
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py25, py26, py27, py31, py32, py33, pypy, jython
envlist = py27, py34, py35, pypy, jython

[testenv]
commands = {envpython} setup.py test
4 changes: 2 additions & 2 deletions trueskill/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,13 +544,13 @@ def variance_matrix(height, width):
# the player-team assignment and comparison matrix
def rotated_a_matrix(set_height, set_width):
t = 0
for r, (cur, next) in enumerate(zip(rating_groups[:-1],
for r, (cur, _next) in enumerate(zip(rating_groups[:-1],
rating_groups[1:])):
for x in range(t, t + len(cur)):
yield (r, x), flatten_weights[x]
t += 1
x += 1
for x in range(x, x + len(next)):
for x in range(x, x + len(_next)):
yield (r, x), -flatten_weights[x]
set_height(r + 1)
set_width(x + 1)
Expand Down
6 changes: 3 additions & 3 deletions trueskill/factorgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def __repr__(self):

class Factor(Node):

def __init__(self, vars):
self.vars = vars
for var in vars:
def __init__(self, variables):
self.vars = variables
for var in variables:
var[self] = Gaussian()

def down(self):
Expand Down
6 changes: 3 additions & 3 deletions trueskill/mathematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ def __ge__(self, other):
return self.mu >= other.mu

def __repr__(self):
return 'N(mu=%.3f, sigma=%.3f)' % (self.mu, self.sigma)
return 'N(mu={:.3f}, sigma={:.3f})'.format(self.mu, self.sigma)

def _repr_latex_(self):
latex = r'\mathcal{ N }( %.3f, %.3f^2 )' % (self.mu, self.sigma)
latex = r'\mathcal{{ N }}( {:.3f}, {:.3f}^2 )'.format(self.mu, self.sigma)
return '$%s$' % latex


Expand Down Expand Up @@ -252,7 +252,7 @@ def __rmul__(self, other):
return type(self)(src, height, width)

def __repr__(self):
return '%s(%s)' % (type(self).__name__, super(Matrix, self).__repr__())
return '{}({})'.format(type(self).__name__, super(Matrix, self).__repr__())

def _repr_latex_(self):
rows = [' && '.join(['%.3f' % cell for cell in row]) for row in self]
Expand Down
20 changes: 10 additions & 10 deletions trueskillhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def factor_graph_logging(color=False):
orig_factor_init = Factor.__init__
orig_variable_set = Variable.set
def repr_factor(factor):
return '{0}@{1}'.format(type(factor).__name__, id(factor))
return '{}@{}'.format(type(factor).__name__, id(factor))
def repr_gauss(gauss):
return 'N(mu=%.3f, sigma=%.3f, pi=%r, tau=%r)' % \
(gauss.mu, gauss.sigma, gauss.pi, gauss.tau)
Expand All @@ -104,8 +104,8 @@ def factor_init(self, *args, **kwargs):
return orig_factor_init(self, *args, **kwargs)
def variable_set(self, val):
old_value = Gaussian(pi=self.pi, tau=self.tau)
old_messages = dict((fac, Gaussian(pi=msg.pi, tau=msg.tau))
for fac, msg in self.messages.items())
old_messages = {fac: Gaussian(pi=msg.pi, tau=msg.tau)
for fac, msg in self.messages.items()}
delta = orig_variable_set(self, val)
# inspect outer frames
frames = inspect.getouterframes(inspect.currentframe())
Expand All @@ -126,24 +126,24 @@ def variable_set(self, val):
# print layer
if getattr(logger, '_prev_layer_name', None) != factor._layer_name:
logger._prev_layer_name = factor._layer_name
l(colored('[{0}]'.format(factor._layer_name), 'blue'))
l(colored('[{}]'.format(factor._layer_name), 'blue'))
# print factor
l(colored('<{0}.{1}>'.format(r(factor), methods[1]), 'cyan'))
l(colored('<{}.{}>'.format(r(factor), methods[1]), 'cyan'))
# print value
if old_value == self:
line = '{0}'.format(r(self))
line = '{}'.format(r(self))
else:
line = '{0} -> {1}'.format(r(old_value), r(self))
line = '{} -> {}'.format(r(old_value), r(self))
l(bullet(methods[0] == 'update_value') + line)
# print messages
fmt = '{0}: {1} -> {2}'.format
fmt = '{}: {} -> {}'.format
for fac, msg in self.messages.items():
old_msg = old_messages[fac]
changed = fac is factor and methods[0] == 'update_message'
if old_msg == msg:
line = '{0}: {1}'.format(r(fac), r(msg))
line = '{}: {}'.format(r(fac), r(msg))
else:
line = '{0}: {1} -> {2}'.format(r(fac), r(old_msg), r(msg))
line = '{}: {} -> {}'.format(r(fac), r(old_msg), r(msg))
l(bullet(changed) + line)
# print buffered logs
map(logger.debug, logs)
Expand Down

0 comments on commit d807cb0

Please sign in to comment.