Skip to content

Commit a4439f7

Browse files
authored
Fixes #109 (#110)
* Fixes #109 Signed-off-by: Vivek Joshy <8206808+vivekjoshy@users.noreply.github.com> * Optimize Imports Signed-off-by: Vivek Joshy <8206808+vivekjoshy@users.noreply.github.com> * Add changelog Signed-off-by: Vivek Joshy <8206808+vivekjoshy@users.noreply.github.com> * Perform isort Signed-off-by: Vivek Joshy <8206808+vivekjoshy@users.noreply.github.com> * Add mypy to tox Signed-off-by: Vivek Joshy <8206808+vivekjoshy@users.noreply.github.com> * Prevent Fail Fast Signed-off-by: Vivek Joshy <8206808+vivekjoshy@users.noreply.github.com> * Correct GitHub Actions for Tox Signed-off-by: Vivek Joshy <8206808+vivekjoshy@users.noreply.github.com> --------- Signed-off-by: Vivek Joshy <8206808+vivekjoshy@users.noreply.github.com>
1 parent 4cf5d7d commit a4439f7

15 files changed

+293
-254
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
name: ${{ matrix.os }} / ${{ matrix.python-version }} (${{ matrix.architecture }})
1717
runs-on: ${{ matrix.os }}-latest
1818
strategy:
19-
fail-fast: true
19+
fail-fast: false
2020
matrix:
2121
os: [Ubuntu, MacOS, Windows]
2222
python-version: ["3.8", "3.9", "3.10", "3.11"]

changes/109.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
model.rating() methods no longer revert to default model parameters when arguments are 0

openskill/models/weng_lin/bradley_terry_full.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __str__(self) -> str:
7575
def __hash__(self) -> int:
7676
return hash((self.id, self.mu, self.sigma))
7777

78-
def __deepcopy__(self, memodict={}):
78+
def __deepcopy__(self, memodict: Dict[Any, Any] = {}) -> "BradleyTerryFullRating":
7979
blf = BradleyTerryFullRating(self.mu, self.sigma, self.name)
8080
blf.id = self.id
8181
return blf
@@ -369,7 +369,11 @@ def rating(
369369
370370
:return: :class:`BradleyTerryFullRating` object
371371
"""
372-
return self.BradleyTerryFullRating(mu or self.mu, sigma or self.sigma, name)
372+
return self.BradleyTerryFullRating(
373+
mu if mu is not None else self.mu,
374+
sigma if sigma is not None else self.sigma,
375+
name,
376+
)
373377

374378
@staticmethod
375379
def create_rating(

openskill/models/weng_lin/bradley_terry_part.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __str__(self) -> str:
8080
def __hash__(self) -> int:
8181
return hash((self.id, self.mu, self.sigma))
8282

83-
def __deepcopy__(self, memodict={}):
83+
def __deepcopy__(self, memodict: Dict[Any, Any] = {}) -> "BradleyTerryPartRating":
8484
blp = BradleyTerryPartRating(self.mu, self.sigma, self.name)
8585
blp.id = self.id
8686
return blp
@@ -374,7 +374,11 @@ def rating(
374374
375375
:return: :class:`BradleyTerryPartRating` object
376376
"""
377-
return self.BradleyTerryPartRating(mu or self.mu, sigma or self.sigma, name)
377+
return self.BradleyTerryPartRating(
378+
mu if mu is not None else self.mu,
379+
sigma if sigma is not None else self.sigma,
380+
name,
381+
)
378382

379383
@staticmethod
380384
def create_rating(

openskill/models/weng_lin/plackett_luce.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""
55
import copy
66
import itertools
7-
import marshal
87
import math
98
import uuid
109
from functools import reduce
@@ -75,7 +74,7 @@ def __str__(self) -> str:
7574
def __hash__(self) -> int:
7675
return hash((self.id, self.mu, self.sigma))
7776

78-
def __deepcopy__(self, memodict={}):
77+
def __deepcopy__(self, memodict: Dict[Any, Any] = {}) -> "PlackettLuceRating":
7978
plr = PlackettLuceRating(self.mu, self.sigma, self.name)
8079
plr.id = self.id
8180
return plr
@@ -370,7 +369,11 @@ def rating(
370369
371370
:return: :class:`PlackettLuceRating` object
372371
"""
373-
return self.PlackettLuceRating(mu or self.mu, sigma or self.sigma, name)
372+
return self.PlackettLuceRating(
373+
mu if mu is not None else self.mu,
374+
sigma if sigma is not None else self.sigma,
375+
name,
376+
)
374377

375378
@staticmethod
376379
def create_rating(

openskill/models/weng_lin/thurstone_mosteller_full.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ def __str__(self) -> str:
8383
def __hash__(self) -> int:
8484
return hash((self.id, self.mu, self.sigma))
8585

86-
def __deepcopy__(self, memodict={}):
86+
def __deepcopy__(
87+
self, memodict: Dict[Any, Any] = {}
88+
) -> "ThurstoneMostellerFullRating":
8789
tmf = ThurstoneMostellerFullRating(self.mu, self.sigma, self.name)
8890
tmf.id = self.id
8991
return tmf
@@ -379,7 +381,9 @@ def rating(
379381
:return: :class:`ThurstoneMostellerFullRating` object
380382
"""
381383
return self.ThurstoneMostellerFullRating(
382-
mu or self.mu, sigma or self.sigma, name
384+
mu if mu is not None else self.mu,
385+
sigma if sigma is not None else self.sigma,
386+
name,
383387
)
384388

385389
@staticmethod

openskill/models/weng_lin/thurstone_mosteller_part.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ def __str__(self) -> str:
8484
def __hash__(self) -> int:
8585
return hash((self.id, self.mu, self.sigma))
8686

87-
def __deepcopy__(self, memodict={}):
87+
def __deepcopy__(
88+
self, memodict: Dict[Any, Any] = {}
89+
) -> "ThurstoneMostellerPartRating":
8890
tmp = ThurstoneMostellerPartRating(self.mu, self.sigma, self.name)
8991
tmp.id = self.id
9092
return tmp
@@ -381,7 +383,9 @@ def rating(
381383
:return: :class:`ThurstoneMostellerPartRating` object
382384
"""
383385
return self.ThurstoneMostellerPartRating(
384-
mu or self.mu, sigma or self.sigma, name
386+
mu if mu is not None else self.mu,
387+
sigma if sigma is not None else self.sigma,
388+
name,
385389
)
386390

387391
@staticmethod

pdm.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/models/data/bradleyterryfull.json

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,123 @@
11
{
22
"model": {
3-
"mu": 22.740988090624523,
4-
"sigma": 9.777655160892776
3+
"mu": 29.36396996731831,
4+
"sigma": 4.171204886973876
55
},
66
"normal": {
77
"team_1": [
88
{
9-
"mu": 26.902123327231017,
10-
"sigma": 9.641221928578473
9+
"mu": 31.153959099540106,
10+
"sigma": 4.164662443820041
1111
}
1212
],
1313
"team_2": [
1414
{
15-
"mu": 18.57985285401803,
16-
"sigma": 9.583990536047741
15+
"mu": 27.573980835096517,
16+
"sigma": 4.161603879330805
1717
},
1818
{
19-
"mu": 18.57985285401803,
20-
"sigma": 9.583990536047741
19+
"mu": 27.573980835096517,
20+
"sigma": 4.161603879330805
2121
}
2222
]
2323
},
2424
"ranks": {
2525
"team_1": [
2626
{
27-
"mu": 21.570293690901313,
28-
"sigma": 9.641221928578473
27+
"mu": 29.287206490045804,
28+
"sigma": 4.164662443820041
2929
}
3030
],
3131
"team_2": [
3232
{
33-
"mu": 23.911682490347733,
34-
"sigma": 9.583990536047741
33+
"mu": 29.44073344459082,
34+
"sigma": 4.161603879330805
3535
},
3636
{
37-
"mu": 23.911682490347733,
38-
"sigma": 9.583990536047741
37+
"mu": 29.44073344459082,
38+
"sigma": 4.161603879330805
3939
}
4040
]
4141
},
4242
"scores": {
4343
"team_1": [
4444
{
45-
"mu": 21.570293690901313,
46-
"sigma": 9.641221928578473
45+
"mu": 29.287206490045804,
46+
"sigma": 4.164662443820041
4747
}
4848
],
4949
"team_2": [
5050
{
51-
"mu": 23.911682490347733,
52-
"sigma": 9.583990536047741
51+
"mu": 29.44073344459082,
52+
"sigma": 4.161603879330805
5353
},
5454
{
55-
"mu": 23.911682490347733,
56-
"sigma": 9.583990536047741
55+
"mu": 29.44073344459082,
56+
"sigma": 4.161603879330805
5757
}
5858
]
5959
},
6060
"limit_sigma": {
6161
"team_1": [
6262
{
63-
"mu": 25.795627365614514,
64-
"sigma": 9.593288544932829
63+
"mu": 30.98575395732507,
64+
"sigma": 4.164211798652542
6565
}
6666
],
6767
"team_2": [
6868
{
69-
"mu": 27.001902040337235,
70-
"sigma": 9.471890078708862
69+
"mu": 30.91518357463656,
70+
"sigma": 4.151834626521716
7171
},
7272
{
73-
"mu": 27.001902040337235,
74-
"sigma": 9.471890078708862
73+
"mu": 30.91518357463656,
74+
"sigma": 4.151834626521716
7575
}
7676
],
7777
"team_3": [
7878
{
79-
"mu": 15.425434865921822,
80-
"sigma": 9.560141746316821
79+
"mu": 26.190972369993304,
80+
"sigma": 4.159317810753674
8181
},
8282
{
83-
"mu": 15.425434865921822,
84-
"sigma": 9.560141746316821
83+
"mu": 26.190972369993304,
84+
"sigma": 4.159317810753674
8585
},
8686
{
87-
"mu": 15.425434865921822,
88-
"sigma": 9.560141746316821
87+
"mu": 26.190972369993304,
88+
"sigma": 4.159317810753674
8989
}
9090
]
9191
},
9292
"ties": {
9393
"team_1": [
9494
{
95-
"mu": 28.78689813151606,
96-
"sigma": 9.593288544932829
95+
"mu": 32.000527612789725,
96+
"sigma": 4.164211798652542
9797
}
9898
],
9999
"team_2": [
100100
{
101-
"mu": 17.447862464945736,
102-
"sigma": 9.471890078708862
101+
"mu": 27.4709691990532,
102+
"sigma": 4.151834626521716
103103
},
104104
{
105-
"mu": 17.447862464945736,
106-
"sigma": 9.471890078708862
105+
"mu": 27.4709691990532,
106+
"sigma": 4.151834626521716
107107
}
108108
],
109109
"team_3": [
110110
{
111-
"mu": 21.98820367541177,
112-
"sigma": 9.560141746316821
111+
"mu": 28.620413090112006,
112+
"sigma": 4.159317810753674
113113
},
114114
{
115-
"mu": 21.98820367541177,
116-
"sigma": 9.560141746316821
115+
"mu": 28.620413090112006,
116+
"sigma": 4.159317810753674
117117
},
118118
{
119-
"mu": 21.98820367541177,
120-
"sigma": 9.560141746316821
119+
"mu": 28.620413090112006,
120+
"sigma": 4.159317810753674
121121
}
122122
]
123123
}

0 commit comments

Comments
 (0)