Conversation
|
Do you have tested this version? |
…ghTime.py into refactor/format-type-improvements
|
Thank you for your comment! I realized that the tests were actually failing early on, and I mistakenly thought they had all passed. I’ve now gone back and rerun the full test suite. (Regarding import trueskillthroughtime2, it seems the 2 is not needed, so I removed it and ran the tests again.) As mentioned in the “Refactored GameType usage” section, the Game class now expects GameType instead of a str. Because of that, I updated the test code accordingly so that it matches the new, type-safe interface. After making those adjustments, all tests passed except for test_game_discrete_1vs1. This single test still fails, but the rest of the suite runs successfully. If I’m not mistaken, test_game_discrete_1vs1 was already failing even with the original (pre-refactor) code — could you confirm if that’s correct? If there’s anything else you’d like me to adjust, please let me know. |
|
I found other problems of my own in the v2. See the learning curves that we estimate in the examples/generic_plot.py dataset. They must be centered around 0, but we get a drift on time. I will return to version v1 until I could solve this drift. |
|
Hi, thanks again for taking the time to look into this and for pointing out the drift issue in v2. I took a closer look at the failing test, and it seems the error originates inside To address this, I removed the call to With this change applied, I also checked Thanks again! |
This PR focuses on improving code quality, consistency, and type safety in
TrueskillThroughTime.py.All existing tests pass, and no behavioral changes to the external API or core logic are introduced.
Summary of Changes
Applied code formatting with ruff
The entire file has been formatted using
ruffto ensure consistent coding style.Added type annotations (verified with mypy)
Type hints have been added across major classes and methods, and the code now passes
mypychecks.Refactored
GameTypeusage and locationMoved
GameTypeto a more appropriate location and replaced previousstr-based comparisons withGameTypeenum values for improved type safety.Removed redundant
ordenattribute from theGameclassThe attribute duplicated the behavior of the existing method, so it has been removed for clarity.
Eliminated aliasing such as
g = selfRemoved unnecessary aliases to improve readability and enhance IntelliSense support.
Renamed methods to avoid name conflicts with member variables
Game.margin→Game.get_marginGame.likelihoods→Game.get_likelihoodsFixed a potential bug in
History.add_historyCorrected an issue where
self.batcheswas referenced instead ofself.btimes.Renamed classes to follow PEP 8 naming conventions
team_variable→TeamVariablediff_messages→DiffMessagesNotes