diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 42f547c..f56b056 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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"] diff --git a/changes/109.bugfix.rst b/changes/109.bugfix.rst new file mode 100644 index 0000000..d38cf4b --- /dev/null +++ b/changes/109.bugfix.rst @@ -0,0 +1 @@ +model.rating() methods no longer revert to default model parameters when arguments are 0 diff --git a/openskill/models/weng_lin/bradley_terry_full.py b/openskill/models/weng_lin/bradley_terry_full.py index b3d55a7..0ee2173 100644 --- a/openskill/models/weng_lin/bradley_terry_full.py +++ b/openskill/models/weng_lin/bradley_terry_full.py @@ -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 @@ -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( diff --git a/openskill/models/weng_lin/bradley_terry_part.py b/openskill/models/weng_lin/bradley_terry_part.py index e2c9ef4..d5b43b4 100644 --- a/openskill/models/weng_lin/bradley_terry_part.py +++ b/openskill/models/weng_lin/bradley_terry_part.py @@ -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 @@ -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( diff --git a/openskill/models/weng_lin/plackett_luce.py b/openskill/models/weng_lin/plackett_luce.py index b1c1f74..2c5ba79 100644 --- a/openskill/models/weng_lin/plackett_luce.py +++ b/openskill/models/weng_lin/plackett_luce.py @@ -4,7 +4,6 @@ """ import copy import itertools -import marshal import math import uuid from functools import reduce @@ -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 @@ -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( diff --git a/openskill/models/weng_lin/thurstone_mosteller_full.py b/openskill/models/weng_lin/thurstone_mosteller_full.py index 01f687b..470e39f 100644 --- a/openskill/models/weng_lin/thurstone_mosteller_full.py +++ b/openskill/models/weng_lin/thurstone_mosteller_full.py @@ -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 @@ -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 diff --git a/openskill/models/weng_lin/thurstone_mosteller_part.py b/openskill/models/weng_lin/thurstone_mosteller_part.py index b0eb676..9e2c585 100644 --- a/openskill/models/weng_lin/thurstone_mosteller_part.py +++ b/openskill/models/weng_lin/thurstone_mosteller_part.py @@ -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 @@ -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 diff --git a/pdm.lock b/pdm.lock index 1a2cb0b..7c87fa7 100644 --- a/pdm.lock +++ b/pdm.lock @@ -321,12 +321,12 @@ files = [ [[package]] name = "chardet" -version = "5.1.0" +version = "5.2.0" requires_python = ">=3.7" summary = "Universal encoding detector for Python 3" files = [ - {file = "chardet-5.1.0-py3-none-any.whl", hash = "sha256:362777fb014af596ad31334fde1e8c327dfdb076e1960d1694662d46a6917ab9"}, - {file = "chardet-5.1.0.tar.gz", hash = "sha256:0d62712b956bc154f85fb0a266e2a3c5913c2967e00348701b32411d6def31e5"}, + {file = "chardet-5.2.0-py3-none-any.whl", hash = "sha256:e1cf59446890a00105fe7b7912492ea04b6e6f06d4b742b2c788469e34c82970"}, + {file = "chardet-5.2.0.tar.gz", hash = "sha256:1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7"}, ] [[package]] @@ -1839,16 +1839,16 @@ files = [ [[package]] name = "polars" -version = "0.18.13" +version = "0.18.15" requires_python = ">=3.8" summary = "Blazingly fast DataFrame library" files = [ - {file = "polars-0.18.13-cp38-abi3-macosx_10_7_x86_64.whl", hash = "sha256:d71167aea2968d7f354f2553a56369684b66dca48efb7dc0963fee7041bfc267"}, - {file = "polars-0.18.13-cp38-abi3-macosx_11_0_arm64.whl", hash = "sha256:eaa55c2bfab114718f9605d3149d58d7f92f95533da1e23559994b7a12f9b3b2"}, - {file = "polars-0.18.13-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:543d136666b8be18f679587b48bdc45b4541f332a9050f0ee90449cbf3d01a35"}, - {file = "polars-0.18.13-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d052e18686c8a9b9a68c8360ad90e53886990460dc65aeb8f72d4c54859d398f"}, - {file = "polars-0.18.13-cp38-abi3-win_amd64.whl", hash = "sha256:4b340a193144b2f5276b9c3c538784da80d9aca28ad5f27b7c183cdc292876bc"}, - {file = "polars-0.18.13.tar.gz", hash = "sha256:b00d1c7700969c47f3202c5be54d074d99df51acb51943dc4b60cdcf759940fd"}, + {file = "polars-0.18.15-cp38-abi3-macosx_10_7_x86_64.whl", hash = "sha256:f7a4e4108efd2ab728249f792c89d2e7baffd65e0d6cd9f09b6c395363e3fbea"}, + {file = "polars-0.18.15-cp38-abi3-macosx_11_0_arm64.whl", hash = "sha256:7dee57ecc6f6151f1f9b960f6baa5032ba5e967d3a0dc0cda830be20745be58c"}, + {file = "polars-0.18.15-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2c713610c7c144f41987092e2ab2372937933fbdc494a65c08eea251af91b60f"}, + {file = "polars-0.18.15-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c48d248891cfe62ee58f852dabf54c6bd85d4fc83b3b61b759534be0d3b6ec81"}, + {file = "polars-0.18.15-cp38-abi3-win_amd64.whl", hash = "sha256:a2f1e3ad546b98601d06340606e90a8788c35e064b4d82d27301069ce744086e"}, + {file = "polars-0.18.15.tar.gz", hash = "sha256:0c483fc1cfb25d07443c0d51eff9a18b94ccdbf6b252212767524412667ca870"}, ] [[package]] @@ -2823,24 +2823,24 @@ files = [ [[package]] name = "tox" -version = "4.8.0" -requires_python = ">=3.7" +version = "4.10.0" +requires_python = ">=3.8" summary = "tox is a generic virtualenv management and test command line tool" dependencies = [ "cachetools>=5.3.1", - "chardet>=5.1", + "chardet>=5.2", "colorama>=0.4.6", "filelock>=3.12.2", "packaging>=23.1", - "platformdirs>=3.9.1", + "platformdirs>=3.10", "pluggy>=1.2", "pyproject-api>=1.5.3", "tomli>=2.0.1; python_version < \"3.11\"", - "virtualenv>=20.24.1", + "virtualenv>=20.24.3", ] files = [ - {file = "tox-4.8.0-py3-none-any.whl", hash = "sha256:4991305a56983d750a0d848a34242be290452aa88d248f1bf976e4036ee8b213"}, - {file = "tox-4.8.0.tar.gz", hash = "sha256:2adacf435b12ccf10b9dfa9975d8ec0afd7cbae44d300463140d2117b968037b"}, + {file = "tox-4.10.0-py3-none-any.whl", hash = "sha256:e4a1b1438955a6da548d69a52350054350cf6a126658c20943261c48ed6d4c92"}, + {file = "tox-4.10.0.tar.gz", hash = "sha256:e041b2165375be690aca0ec4d96360c6906451380520e4665bf274f66112be35"}, ] [[package]] @@ -2931,7 +2931,7 @@ files = [ [[package]] name = "virtualenv" -version = "20.24.2" +version = "20.24.3" requires_python = ">=3.7" summary = "Virtual Python Environment builder" dependencies = [ @@ -2940,8 +2940,8 @@ dependencies = [ "platformdirs<4,>=3.9.1", ] files = [ - {file = "virtualenv-20.24.2-py3-none-any.whl", hash = "sha256:43a3052be36080548bdee0b42919c88072037d50d56c28bd3f853cbe92b953ff"}, - {file = "virtualenv-20.24.2.tar.gz", hash = "sha256:fd8a78f46f6b99a67b7ec5cf73f92357891a7b3a40fd97637c27f854aae3b9e0"}, + {file = "virtualenv-20.24.3-py3-none-any.whl", hash = "sha256:95a6e9398b4967fbcb5fef2acec5efaf9aa4972049d9ae41f95e0972a683fd02"}, + {file = "virtualenv-20.24.3.tar.gz", hash = "sha256:e5c3b4ce817b0b328af041506a2a299418c98747c4b1e68cb7527e74ced23efc"}, ] [[package]] diff --git a/tests/models/data/bradleyterryfull.json b/tests/models/data/bradleyterryfull.json index 2a6d6a2..8754e40 100644 --- a/tests/models/data/bradleyterryfull.json +++ b/tests/models/data/bradleyterryfull.json @@ -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 } ] } diff --git a/tests/models/data/bradleyterrypart.json b/tests/models/data/bradleyterrypart.json index 51599df..b3f5fd5 100644 --- a/tests/models/data/bradleyterrypart.json +++ b/tests/models/data/bradleyterrypart.json @@ -1,123 +1,123 @@ { "model": { - "mu": 29.66445446901484, - "sigma": 9.186059617698977 + "mu": 23.42618920652956, + "sigma": 6.620037113814815 }, "normal": { "team_1": [ { - "mu": 33.900738249289056, - "sigma": 9.093918343757137 + "mu": 26.350714477306713, + "sigma": 6.566437175049652 } ], "team_2": [ { - "mu": 25.42817068874062, - "sigma": 9.055318751921908 + "mu": 20.501663935752408, + "sigma": 6.543886990267017 }, { - "mu": 25.42817068874062, - "sigma": 9.055318751921908 + "mu": 20.501663935752408, + "sigma": 6.543886990267017 } ] }, "ranks": { "team_1": [ { - "mu": 28.927058087490142, - "sigma": 9.093918343757137 + "mu": 22.95093312306163, + "sigma": 6.566437175049652 } ], "team_2": [ { - "mu": 30.401850850539535, - "sigma": 9.055318751921908 + "mu": 23.90144528999749, + "sigma": 6.543886990267017 }, { - "mu": 30.401850850539535, - "sigma": 9.055318751921908 + "mu": 23.90144528999749, + "sigma": 6.543886990267017 } ] }, "scores": { "team_1": [ { - "mu": 28.927058087490142, - "sigma": 9.093918343757137 + "mu": 22.95093312306163, + "sigma": 6.566437175049652 } ], "team_2": [ { - "mu": 30.401850850539535, - "sigma": 9.055318751921908 + "mu": 23.90144528999749, + "sigma": 6.543886990267017 }, { - "mu": 30.401850850539535, - "sigma": 9.055318751921908 + "mu": 23.90144528999749, + "sigma": 6.543886990267017 } ] }, "limit_sigma": { "team_1": [ { - "mu": 33.10770982601209, - "sigma": 9.07275828538713 + "mu": 25.86048074100693, + "sigma": 6.554810683388137 } ], "team_2": [ { - "mu": 30.401850850539535, - "sigma": 9.055318751921908 + "mu": 23.90144528999749, + "sigma": 6.543886990267017 }, { - "mu": 30.401850850539535, - "sigma": 9.055318751921908 + "mu": 23.90144528999749, + "sigma": 6.543886990267017 } ], "team_3": [ { - "mu": 25.48380273049289, - "sigma": 9.150126866068854 + "mu": 20.51664158858426, + "sigma": 6.6005760670808815 }, { - "mu": 25.48380273049289, - "sigma": 9.150126866068854 + "mu": 20.51664158858426, + "sigma": 6.6005760670808815 }, { - "mu": 25.48380273049289, - "sigma": 9.150126866068854 + "mu": 20.51664158858426, + "sigma": 6.6005760670808815 } ] }, "ties": { "team_1": [ { - "mu": 31.658217757751363, - "sigma": 9.165491138313461 + "mu": 24.823573253695134, + "sigma": 6.60903031873173 } ], "team_2": [ { - "mu": 28.875812514572026, - "sigma": 9.103593000404183 + "mu": 22.912026931066997, + "sigma": 6.569326466933734 }, { - "mu": 28.875812514572026, - "sigma": 9.103593000404183 + "mu": 22.912026931066997, + "sigma": 6.569326466933734 } ], "team_3": [ { - "mu": 28.459333134721128, - "sigma": 9.0481518121229 + "mu": 22.54296743482655, + "sigma": 6.537579021716175 }, { - "mu": 28.459333134721128, - "sigma": 9.0481518121229 + "mu": 22.54296743482655, + "sigma": 6.537579021716175 }, { - "mu": 28.459333134721128, - "sigma": 9.0481518121229 + "mu": 22.54296743482655, + "sigma": 6.537579021716175 } ] } diff --git a/tests/models/data/plackettluce.json b/tests/models/data/plackettluce.json index f2f88c9..7afd62e 100644 --- a/tests/models/data/plackettluce.json +++ b/tests/models/data/plackettluce.json @@ -1,123 +1,123 @@ { "model": { - "mu": 32.54060109748322, - "sigma": 12.814128396961777 + "mu": 34.769193779029436, + "sigma": 6.201579611813977 }, "normal": { "team_1": [ { - "mu": 38.29598005912363, - "sigma": 12.638340562184162 + "mu": 37.735025845053656, + "sigma": 6.1810840601280885 } ], "team_2": [ { - "mu": 26.785222135842808, - "sigma": 12.564692081766962 + "mu": 31.80336171300522, + "sigma": 6.172341582637791 }, { - "mu": 26.785222135842808, - "sigma": 12.564692081766962 + "mu": 31.80336171300522, + "sigma": 6.172341582637791 } ] }, "ranks": { "team_1": [ { - "mu": 31.145296438653457, - "sigma": 12.638340562184162 + "mu": 34.59552112325378, + "sigma": 6.1810840601280885 } ], "team_2": [ { - "mu": 33.93590575631298, - "sigma": 12.564692081766962 + "mu": 34.94286643480509, + "sigma": 6.172341582637791 }, { - "mu": 33.93590575631298, - "sigma": 12.564692081766962 + "mu": 34.94286643480509, + "sigma": 6.172341582637791 } ] }, "scores": { "team_1": [ { - "mu": 31.145296438653457, - "sigma": 12.638340562184162 + "mu": 34.59552112325378, + "sigma": 6.1810840601280885 } ], "team_2": [ { - "mu": 33.93590575631298, - "sigma": 12.564692081766962 + "mu": 34.94286643480509, + "sigma": 6.172341582637791 }, { - "mu": 33.93590575631298, - "sigma": 12.564692081766962 + "mu": 34.94286643480509, + "sigma": 6.172341582637791 } ] }, "limit_sigma": { "team_1": [ { - "mu": 36.5906730051435, - "sigma": 12.73990042520867 + "mu": 36.98817598826861, + "sigma": 6.197577454406944 } ], "team_2": [ { - "mu": 36.3987265753055, - "sigma": 12.708906697720082 + "mu": 36.802978703338965, + "sigma": 6.18044438287098 }, { - "mu": 36.3987265753055, - "sigma": 12.708906697720082 + "mu": 36.802978703338965, + "sigma": 6.18044438287098 } ], "team_3": [ { - "mu": 24.63240371200065, - "sigma": 12.585139378204655 + "mu": 30.516426645480728, + "sigma": 6.168460776023396 }, { - "mu": 24.63240371200065, - "sigma": 12.585139378204655 + "mu": 30.516426645480728, + "sigma": 6.168460776023396 }, { - "mu": 24.63240371200065, - "sigma": 12.585139378204655 + "mu": 30.516426645480728, + "sigma": 6.168460776023396 } ] }, "ties": { "team_1": [ { - "mu": 34.638225768191475, - "sigma": 12.781780619585469 + "mu": 35.88068061230261, + "sigma": 6.199990584127615 } ], "team_2": [ { - "mu": 31.300293563030934, - "sigma": 12.708906697720082 + "mu": 34.515905909487216, + "sigma": 6.18044438287098 }, { - "mu": 31.300293563030934, - "sigma": 12.708906697720082 + "mu": 34.515905909487216, + "sigma": 6.18044438287098 } ], "team_3": [ { - "mu": 31.683283961227247, - "sigma": 12.658477033456156 + "mu": 33.91099481529849, + "sigma": 6.172659556888684 }, { - "mu": 31.683283961227247, - "sigma": 12.658477033456156 + "mu": 33.91099481529849, + "sigma": 6.172659556888684 }, { - "mu": 31.683283961227247, - "sigma": 12.658477033456156 + "mu": 33.91099481529849, + "sigma": 6.172659556888684 } ] } diff --git a/tests/models/data/thurstonemostellerfull.json b/tests/models/data/thurstonemostellerfull.json index 3b1f577..db1cd90 100644 --- a/tests/models/data/thurstonemostellerfull.json +++ b/tests/models/data/thurstonemostellerfull.json @@ -1,123 +1,123 @@ { "model": { - "mu": 28.735199043403306, - "sigma": 8.469110378092095 + "mu": 45.80576023612373, + "sigma": 10.119814840999156 }, "normal": { "team_1": [ { - "mu": 38.775546849589276, - "sigma": 7.879711967971078 + "mu": 61.32295448667373, + "sigma": 9.334981415942869 } ], "team_2": [ { - "mu": 18.694851237217335, - "sigma": 7.622049251788798 + "mu": 30.288565985573733, + "sigma": 8.989686764502482 }, { - "mu": 18.694851237217335, - "sigma": 7.622049251788798 + "mu": 30.288565985573733, + "sigma": 8.989686764502482 } ] }, "ranks": { "team_1": [ { - "mu": 28.3758027153732, - "sigma": 8.371113489208406 + "mu": 45.70227321717305, + "sigma": 10.081409510764281 } ], "team_2": [ { - "mu": 29.09459537143341, - "sigma": 8.330011539840953 + "mu": 45.90924725507441, + "sigma": 10.065315692461603 }, { - "mu": 29.09459537143341, - "sigma": 8.330011539840953 + "mu": 45.90924725507441, + "sigma": 10.065315692461603 } ] }, "scores": { "team_1": [ { - "mu": 28.3758027153732, - "sigma": 8.371113489208406 + "mu": 45.70227321717305, + "sigma": 10.081409510764281 } ], "team_2": [ { - "mu": 29.09459537143341, - "sigma": 8.330011539840953 + "mu": 45.90924725507441, + "sigma": 10.065315692461603 }, { - "mu": 29.09459537143341, - "sigma": 8.330011539840953 + "mu": 45.90924725507441, + "sigma": 10.065315692461603 } ] }, "limit_sigma": { "team_1": [ { - "mu": 42.269586381401375, - "sigma": 7.937771947236825 + "mu": 67.8382439021007, + "sigma": 9.527236687971314 } ], "team_2": [ { - "mu": 35.949033703247366, - "sigma": 7.9186778424704976 + "mu": 56.14412057619168, + "sigma": 9.536278276265291 }, { - "mu": 35.949033703247366, - "sigma": 7.9186778424704976 + "mu": 56.14412057619168, + "sigma": 9.536278276265291 } ], "team_3": [ { - "mu": 7.986977045561176, - "sigma": 7.162825987029471 + "mu": 13.434916230078812, + "sigma": 8.419949795487625 }, { - "mu": 7.986977045561176, - "sigma": 7.162825987029471 + "mu": 13.434916230078812, + "sigma": 8.419949795487625 }, { - "mu": 7.986977045561176, - "sigma": 7.162825987029471 + "mu": 13.434916230078812, + "sigma": 8.419949795487625 } ] }, "ties": { "team_1": [ { - "mu": 51.59215304415708, - "sigma": 7.384816933859696 + "mu": 82.43631534304387, + "sigma": 8.706944769860177 } ], "team_2": [ { - "mu": 18.149494819090684, - "sigma": 7.496023193149764 + "mu": 30.02543143660279, + "sigma": 8.91012758629402 }, { - "mu": 18.149494819090684, - "sigma": 7.496023193149764 + "mu": 30.02543143660279, + "sigma": 8.91012758629402 } ], "team_3": [ { - "mu": 16.463949266962157, - "sigma": 7.5043190317653625 + "mu": 24.955533928724524, + "sigma": 9.002643646004634 }, { - "mu": 16.463949266962157, - "sigma": 7.5043190317653625 + "mu": 24.955533928724524, + "sigma": 9.002643646004634 }, { - "mu": 16.463949266962157, - "sigma": 7.5043190317653625 + "mu": 24.955533928724524, + "sigma": 9.002643646004634 } ] } diff --git a/tests/models/data/thurstonemostellerpart.json b/tests/models/data/thurstonemostellerpart.json index dec5a03..ba018fe 100644 --- a/tests/models/data/thurstonemostellerpart.json +++ b/tests/models/data/thurstonemostellerpart.json @@ -1,123 +1,123 @@ { "model": { - "mu": 5.763587246460499, - "sigma": 10.328410776549841 + "mu": 17.712411553528373, + "sigma": 4.0516555328540695 }, "normal": { "team_1": [ { - "mu": 8.306064010993937, - "sigma": 10.257323599928604 + "mu": 19.05482890639545, + "sigma": 4.035022659165134 } ], "team_2": [ { - "mu": 3.221110481927061, - "sigma": 10.227592990963595 + "mu": 16.369994200661296, + "sigma": 4.027755914554947 }, { - "mu": 3.221110481927061, - "sigma": 10.227592990963595 + "mu": 16.369994200661296, + "sigma": 4.027755914554947 } ] }, "ranks": { "team_1": [ { - "mu": 3.772406859491051, - "sigma": 10.264471442726302 + "mu": 17.44340623089713, + "sigma": 4.044176299828259 } ], "team_2": [ { - "mu": 7.754767633429948, - "sigma": 10.237729461081452 + "mu": 17.981416876159617, + "sigma": 4.04071832425657 }, { - "mu": 7.754767633429948, - "sigma": 10.237729461081452 + "mu": 17.981416876159617, + "sigma": 4.04071832425657 } ] }, "scores": { "team_1": [ { - "mu": 3.772406859491051, - "sigma": 10.264471442726302 + "mu": 17.44340623089713, + "sigma": 4.044176299828259 } ], "team_2": [ { - "mu": 7.754767633429948, - "sigma": 10.237729461081452 + "mu": 17.981416876159617, + "sigma": 4.04071832425657 }, { - "mu": 7.754767633429948, - "sigma": 10.237729461081452 + "mu": 17.981416876159617, + "sigma": 4.04071832425657 } ] }, "limit_sigma": { "team_1": [ { - "mu": 6.196378842793209, - "sigma": 10.214453544639294 + "mu": 19.22084021482846, + "sigma": 4.0295313748931525 } ], "team_2": [ { - "mu": 7.754767633429948, - "sigma": 10.237729461081452 + "mu": 17.981416876159617, + "sigma": 4.04071832425657 }, { - "mu": 7.754767633429948, - "sigma": 10.237729461081452 + "mu": 17.981416876159617, + "sigma": 4.04071832425657 } ], "team_3": [ { - "mu": 3.339615263158341, - "sigma": 10.242502225075887 + "mu": 15.934977569597041, + "sigma": 4.027165419760776 }, { - "mu": 3.339615263158341, - "sigma": 10.242502225075887 + "mu": 15.934977569597041, + "sigma": 4.027165419760776 }, { - "mu": 3.339615263158341, - "sigma": 10.242502225075887 + "mu": 15.934977569597041, + "sigma": 4.027165419760776 } ] }, "ties": { "team_1": [ { - "mu": 6.429819583665084, - "sigma": 10.2567368272061 + "mu": 19.16085795643484, + "sigma": 4.035725121124812 } ], "team_2": [ { - "mu": 4.146613895965498, - "sigma": 10.283375644006199 + "mu": 17.43944206383774, + "sigma": 4.044509996311233 }, { - "mu": 4.146613895965498, - "sigma": 10.283375644006199 + "mu": 17.43944206383774, + "sigma": 4.044509996311233 } ], "team_3": [ { - "mu": 6.714328259750917, - "sigma": 10.147418635349544 + "mu": 16.53693464031254, + "sigma": 4.01351730328268 }, { - "mu": 6.714328259750917, - "sigma": 10.147418635349544 + "mu": 16.53693464031254, + "sigma": 4.01351730328268 }, { - "mu": 6.714328259750917, - "sigma": 10.147418635349544 + "mu": 16.53693464031254, + "sigma": 4.01351730328268 } ] } diff --git a/tests/models/test_common.py b/tests/models/test_common.py index 642d31e..706f2ec 100644 --- a/tests/models/test_common.py +++ b/tests/models/test_common.py @@ -1,6 +1,7 @@ """ Tests common for all models. """ +from openskill.models import MODELS from openskill.models.common import ( _arg_sort, _matrix_transpose, @@ -9,6 +10,23 @@ ) +def test_model_rating() -> None: + """ + Checks the cases where Falsy values are passed into rating methods. + """ + for model in MODELS: + model = model(sigma=21) + player = model.rating(mu=0) + assert player.sigma == 21 + assert player.mu == 0 + + for model in MODELS: + model = model(mu=22) + player = model.rating(sigma=0) + assert player.sigma == 0 + assert player.mu == 22 + + def test_unary_minus() -> None: """ Tests the :code:`_unary_minus` function. diff --git a/tox.ini b/tox.ini index 5c86c99..15a6109 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ -[gh] +[gh-actions] python = 3.12-dev: python3.12 - 3.11: lint, build, type, py3.11 + 3.11: py3.11, lint, build, type 3.10: py3.10 3.9: py3.9 3.8: py3.8 @@ -15,6 +15,7 @@ requires = env_list = lint build + type py{3.8,3.9,3.10,3.11} py{3.8,3.9,3.10,3.11}-win32 python3.12