guidopetri / chess-pipeline

Pulling games from the Lichess API into a PostgreSQL database for data analysis.
GNU General Public License v3.0
20 stars 2 forks source link

WinRatioByColor fails when only one color played #65

Closed guidopetri closed 2 years ago

guidopetri commented 2 years ago

It's unclear whether this happens with 0 or 1 games being manipulated:

  File "chess-pipeline/src/newsletter.py", line 73, in run
    100 * color_stats.iloc[1][0],
IndexError: single positional indexer is out-of-bounds

Original reference is in #60 .

Fix steps are:

guidopetri commented 2 years ago

Correction: this error comes up if there's only one color being played (i.e. only played games as black/white). Since Lichess tries to make you play both sides equally this usually only happens with one game.

guidopetri commented 2 years ago

This should be closed with 6f004a2 . I extracted the text generation out of WinRatioByColor and added some tests for it. Eventually I might want to do the same with EloByWeekday, but there aren't any cases where it breaks right now (afaik) so I'll leave it as part of the class for now.