{{ message }}

# Weightings not respected when supplied as dictionary #9

Closed
opened this issue Sep 4, 2014 · 4 comments
Closed

# Weightings not respected when supplied as dictionary#9

opened this issue Sep 4, 2014 · 4 comments

### bernd-wechner commented Sep 4, 2014

 In this sample: `````` # Multi Player example print("\nMultiplayer example") class Player(object): def __init__(self, name, rating, team): self.name = name self.rating = rating self.team = team p1 = Player('Player A', Rating(), 0) p2 = Player('Player B', Rating(), 0) p3 = Player('Player C', Rating(), 1) print(p1.rating, p2.rating, p3.rating) teams = [{p1: p1.rating, p2: p2.rating}, {p3: p3.rating}] ranks = [1, 2] weights = {(0, p1): 1, (0, p2): 1, (1, p3): 1} rated = trueskill.rate(teams, ranks, weights=weights) p1.rating = rated[p1.team][p1] p2.rating = rated[p2.team][p2] p3.rating = rated[p3.team][p3] print(p1.rating, p2.rating, p3.rating) `````` The result is: `````` Multiplayer example trueskill.Rating(mu=25.000, sigma=8.333) trueskill.Rating(mu=25.000, sigma=8.333) trueskill.Rating(mu=25.000, sigma=8.333) trueskill.Rating(mu=25.604, sigma=8.075) trueskill.Rating(mu=25.604, sigma=8.075) trueskill.Rating(mu=24.396, sigma=8.075) `````` All the weights were 1. Now give p2 a weight of 0.5: `````` weights = {(0, p1): 1, (0, p2): 0.5, (1, p3): 1} `````` The result is identical: If the weights are supplied as a list of tuples instead: `````` weights = weights = [(1, 0.5), (1,)] # for p1, p2, p3 respectively `````` Then the results reflect the weights: `````` Multiplayer example trueskill.Rating(mu=25.000, sigma=8.333) trueskill.Rating(mu=25.000, sigma=8.333) trueskill.Rating(mu=25.000, sigma=8.333) trueskill.Rating(mu=26.764, sigma=7.685) trueskill.Rating(mu=25.882, sigma=8.176) trueskill.Rating(mu=23.236, sigma=7.685) ``````
added a commit that referenced this issue Sep 4, 2014
``` fix issue #9 ```
``` 1ab9c1f ```

### sublee commented Sep 4, 2014

 Thanks to report. I fixed this error. Upgrade the package by: ``````\$ pip install -U trueskill `````` If your problem has been gone, please close this issue.

### bernd-wechner commented Sep 4, 2014

 Thanks enormously! Heungsub Lee wrote: |pip install -U trueskill|

### sublee commented Sep 11, 2014

 @bernd-wechner Is this issue fixed? Then I'll or you'll close it.

### bernd-wechner commented Sep 11, 2014

 Heungsub, Yep, it's fixed. Thanks heaps!. You can close it. Have not looked at code most week, but will get back into it some time in coming month. Regards, Bernd. Heungsub Lee wrote: @bernd-wechner https://github.com/bernd-wechner Is this issue fixed? Then I'll or you'll close it. — Reply to this email directly or view it on GitHub #9 (comment).