diff --git a/chess/engine.py b/chess/engine.py index 270e31e7..64a3926b 100644 --- a/chess/engine.py +++ b/chess/engine.py @@ -720,16 +720,11 @@ def __str__(self) -> str: MateGiven = MateGivenType() +@dataclasses.dataclass class PovWdl: """ Relative :class:`win/draw/loss statistics ` and the point of view. - - .. deprecated:: 1.2 - Behaves like a tuple - ``(wdl.relative.wins, wdl.relative.draws, wdl.relative.losses)`` - for backwards compatibility. But it is recommended to use the provided - fields and methods instead. """ relative: Wdl @@ -738,10 +733,6 @@ class PovWdl: turn: Color """The point of view (``chess.WHITE`` or ``chess.BLACK``).""" - def __init__(self, relative: Wdl, turn: Color) -> None: - self.relative = relative - self.turn = turn - def white(self) -> Wdl: """Gets the :class:`~chess.engine.Wdl` from White's point of view.""" return self.pov(chess.WHITE) @@ -763,30 +754,6 @@ def __bool__(self) -> bool: def __repr__(self) -> str: return "PovWdl({!r}, {})".format(self.relative, "WHITE" if self.turn else "BLACK") - # Unfortunately in python-chess v1.1.0, info["wdl"] was a simple tuple - # of the relative permille values, so we have to support __iter__, - # __len__, __getitem__, and equality comparisons with other tuples. - # Never mind the ordering, because that's not a sensible operation, anyway. - - def __iter__(self) -> Iterator[int]: - yield self.relative.wins - yield self.relative.draws - yield self.relative.losses - - def __len__(self) -> int: - return 3 - - def __getitem__(self, idx: int) -> int: - return (self.relative.wins, self.relative.draws, self.relative.losses)[idx] - - def __eq__(self, other: object) -> bool: - if isinstance(other, PovWdl): - return self.white() == other.white() - elif isinstance(other, tuple): - return (self.relative.wins, self.relative.draws, self.relative.losses) == other - else: - return NotImplemented - @dataclasses.dataclass class Wdl: @@ -830,16 +797,6 @@ def expectation(self) -> float: def __bool__(self) -> bool: return bool(self.total()) - def __iter__(self) -> Iterator[int]: - yield self.wins - yield self.draws - yield self.losses - - def __reversed__(self) -> Iterator[int]: - yield self.losses - yield self.draws - yield self.wins - def __pos__(self) -> Wdl: return self diff --git a/test.py b/test.py index e490daa9..68904a50 100755 --- a/test.py +++ b/test.py @@ -3540,7 +3540,7 @@ def test_uci_info(self): # WDL (activated with UCI_ShowWDL). info = chess.engine._parse_uci_info("depth 1 seldepth 2 time 16 nodes 1 score cp 72 wdl 249 747 4 hashfull 0 nps 400 tbhits 0 multipv 1", board) - self.assertEqual(info["wdl"], (249, 747, 4)) + self.assertEqual(info["wdl"].white(), chess.engine.Wdl(249, 747, 4)) def test_uci_result(self): async def main():