Skip to content

Commit

Permalink
Fixes #109 (#110)
Browse files Browse the repository at this point in the history
* Fixes #109

Signed-off-by: Vivek Joshy <[email protected]>

* Optimize Imports

Signed-off-by: Vivek Joshy <[email protected]>

* Add changelog

Signed-off-by: Vivek Joshy <[email protected]>

* Perform isort

Signed-off-by: Vivek Joshy <[email protected]>

* Add mypy to tox

Signed-off-by: Vivek Joshy <[email protected]>

* Prevent Fail Fast

Signed-off-by: Vivek Joshy <[email protected]>

* Correct GitHub Actions for Tox

Signed-off-by: Vivek Joshy <[email protected]>

---------

Signed-off-by: Vivek Joshy <[email protected]>
  • Loading branch information
vivekjoshy authored Aug 24, 2023
1 parent 4cf5d7d commit a4439f7
Show file tree
Hide file tree
Showing 15 changed files with 293 additions and 254 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: ${{ matrix.os }} / ${{ matrix.python-version }} (${{ matrix.architecture }})
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: true
fail-fast: false
matrix:
os: [Ubuntu, MacOS, Windows]
python-version: ["3.8", "3.9", "3.10", "3.11"]
Expand Down
1 change: 1 addition & 0 deletions changes/109.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
model.rating() methods no longer revert to default model parameters when arguments are 0
8 changes: 6 additions & 2 deletions openskill/models/weng_lin/bradley_terry_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __str__(self) -> str:
def __hash__(self) -> int:
return hash((self.id, self.mu, self.sigma))

def __deepcopy__(self, memodict={}):
def __deepcopy__(self, memodict: Dict[Any, Any] = {}) -> "BradleyTerryFullRating":
blf = BradleyTerryFullRating(self.mu, self.sigma, self.name)
blf.id = self.id
return blf
Expand Down Expand Up @@ -369,7 +369,11 @@ def rating(
:return: :class:`BradleyTerryFullRating` object
"""
return self.BradleyTerryFullRating(mu or self.mu, sigma or self.sigma, name)
return self.BradleyTerryFullRating(
mu if mu is not None else self.mu,
sigma if sigma is not None else self.sigma,
name,
)

@staticmethod
def create_rating(
Expand Down
8 changes: 6 additions & 2 deletions openskill/models/weng_lin/bradley_terry_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __str__(self) -> str:
def __hash__(self) -> int:
return hash((self.id, self.mu, self.sigma))

def __deepcopy__(self, memodict={}):
def __deepcopy__(self, memodict: Dict[Any, Any] = {}) -> "BradleyTerryPartRating":
blp = BradleyTerryPartRating(self.mu, self.sigma, self.name)
blp.id = self.id
return blp
Expand Down Expand Up @@ -374,7 +374,11 @@ def rating(
:return: :class:`BradleyTerryPartRating` object
"""
return self.BradleyTerryPartRating(mu or self.mu, sigma or self.sigma, name)
return self.BradleyTerryPartRating(
mu if mu is not None else self.mu,
sigma if sigma is not None else self.sigma,
name,
)

@staticmethod
def create_rating(
Expand Down
9 changes: 6 additions & 3 deletions openskill/models/weng_lin/plackett_luce.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""
import copy
import itertools
import marshal
import math
import uuid
from functools import reduce
Expand Down Expand Up @@ -75,7 +74,7 @@ def __str__(self) -> str:
def __hash__(self) -> int:
return hash((self.id, self.mu, self.sigma))

def __deepcopy__(self, memodict={}):
def __deepcopy__(self, memodict: Dict[Any, Any] = {}) -> "PlackettLuceRating":
plr = PlackettLuceRating(self.mu, self.sigma, self.name)
plr.id = self.id
return plr
Expand Down Expand Up @@ -370,7 +369,11 @@ def rating(
:return: :class:`PlackettLuceRating` object
"""
return self.PlackettLuceRating(mu or self.mu, sigma or self.sigma, name)
return self.PlackettLuceRating(
mu if mu is not None else self.mu,
sigma if sigma is not None else self.sigma,
name,
)

@staticmethod
def create_rating(
Expand Down
8 changes: 6 additions & 2 deletions openskill/models/weng_lin/thurstone_mosteller_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def __str__(self) -> str:
def __hash__(self) -> int:
return hash((self.id, self.mu, self.sigma))

def __deepcopy__(self, memodict={}):
def __deepcopy__(
self, memodict: Dict[Any, Any] = {}
) -> "ThurstoneMostellerFullRating":
tmf = ThurstoneMostellerFullRating(self.mu, self.sigma, self.name)
tmf.id = self.id
return tmf
Expand Down Expand Up @@ -379,7 +381,9 @@ def rating(
:return: :class:`ThurstoneMostellerFullRating` object
"""
return self.ThurstoneMostellerFullRating(
mu or self.mu, sigma or self.sigma, name
mu if mu is not None else self.mu,
sigma if sigma is not None else self.sigma,
name,
)

@staticmethod
Expand Down
8 changes: 6 additions & 2 deletions openskill/models/weng_lin/thurstone_mosteller_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def __str__(self) -> str:
def __hash__(self) -> int:
return hash((self.id, self.mu, self.sigma))

def __deepcopy__(self, memodict={}):
def __deepcopy__(
self, memodict: Dict[Any, Any] = {}
) -> "ThurstoneMostellerPartRating":
tmp = ThurstoneMostellerPartRating(self.mu, self.sigma, self.name)
tmp.id = self.id
return tmp
Expand Down Expand Up @@ -381,7 +383,9 @@ def rating(
:return: :class:`ThurstoneMostellerPartRating` object
"""
return self.ThurstoneMostellerPartRating(
mu or self.mu, sigma or self.sigma, name
mu if mu is not None else self.mu,
sigma if sigma is not None else self.sigma,
name,
)

@staticmethod
Expand Down
40 changes: 20 additions & 20 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 44 additions & 44 deletions tests/models/data/bradleyterryfull.json
Original file line number Diff line number Diff line change
@@ -1,123 +1,123 @@
{
"model": {
"mu": 22.740988090624523,
"sigma": 9.777655160892776
"mu": 29.36396996731831,
"sigma": 4.171204886973876
},
"normal": {
"team_1": [
{
"mu": 26.902123327231017,
"sigma": 9.641221928578473
"mu": 31.153959099540106,
"sigma": 4.164662443820041
}
],
"team_2": [
{
"mu": 18.57985285401803,
"sigma": 9.583990536047741
"mu": 27.573980835096517,
"sigma": 4.161603879330805
},
{
"mu": 18.57985285401803,
"sigma": 9.583990536047741
"mu": 27.573980835096517,
"sigma": 4.161603879330805
}
]
},
"ranks": {
"team_1": [
{
"mu": 21.570293690901313,
"sigma": 9.641221928578473
"mu": 29.287206490045804,
"sigma": 4.164662443820041
}
],
"team_2": [
{
"mu": 23.911682490347733,
"sigma": 9.583990536047741
"mu": 29.44073344459082,
"sigma": 4.161603879330805
},
{
"mu": 23.911682490347733,
"sigma": 9.583990536047741
"mu": 29.44073344459082,
"sigma": 4.161603879330805
}
]
},
"scores": {
"team_1": [
{
"mu": 21.570293690901313,
"sigma": 9.641221928578473
"mu": 29.287206490045804,
"sigma": 4.164662443820041
}
],
"team_2": [
{
"mu": 23.911682490347733,
"sigma": 9.583990536047741
"mu": 29.44073344459082,
"sigma": 4.161603879330805
},
{
"mu": 23.911682490347733,
"sigma": 9.583990536047741
"mu": 29.44073344459082,
"sigma": 4.161603879330805
}
]
},
"limit_sigma": {
"team_1": [
{
"mu": 25.795627365614514,
"sigma": 9.593288544932829
"mu": 30.98575395732507,
"sigma": 4.164211798652542
}
],
"team_2": [
{
"mu": 27.001902040337235,
"sigma": 9.471890078708862
"mu": 30.91518357463656,
"sigma": 4.151834626521716
},
{
"mu": 27.001902040337235,
"sigma": 9.471890078708862
"mu": 30.91518357463656,
"sigma": 4.151834626521716
}
],
"team_3": [
{
"mu": 15.425434865921822,
"sigma": 9.560141746316821
"mu": 26.190972369993304,
"sigma": 4.159317810753674
},
{
"mu": 15.425434865921822,
"sigma": 9.560141746316821
"mu": 26.190972369993304,
"sigma": 4.159317810753674
},
{
"mu": 15.425434865921822,
"sigma": 9.560141746316821
"mu": 26.190972369993304,
"sigma": 4.159317810753674
}
]
},
"ties": {
"team_1": [
{
"mu": 28.78689813151606,
"sigma": 9.593288544932829
"mu": 32.000527612789725,
"sigma": 4.164211798652542
}
],
"team_2": [
{
"mu": 17.447862464945736,
"sigma": 9.471890078708862
"mu": 27.4709691990532,
"sigma": 4.151834626521716
},
{
"mu": 17.447862464945736,
"sigma": 9.471890078708862
"mu": 27.4709691990532,
"sigma": 4.151834626521716
}
],
"team_3": [
{
"mu": 21.98820367541177,
"sigma": 9.560141746316821
"mu": 28.620413090112006,
"sigma": 4.159317810753674
},
{
"mu": 21.98820367541177,
"sigma": 9.560141746316821
"mu": 28.620413090112006,
"sigma": 4.159317810753674
},
{
"mu": 21.98820367541177,
"sigma": 9.560141746316821
"mu": 28.620413090112006,
"sigma": 4.159317810753674
}
]
}
Expand Down
Loading

0 comments on commit a4439f7

Please sign in to comment.