From 40d860120cce7d0ab8ccbf4fe19357962e1892ff Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Mon, 25 Mar 2024 16:19:55 +0800 Subject: [PATCH] Fix/skip group if it is empty (#98) --- pyproject.toml | 2 +- src/fsrs_optimizer/fsrs_optimizer.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 990ec98..88be9e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "FSRS-Optimizer" -version = "4.27.0" +version = "4.27.1" readme = "README.md" dependencies = [ "matplotlib>=3.7.0", diff --git a/src/fsrs_optimizer/fsrs_optimizer.py b/src/fsrs_optimizer/fsrs_optimizer.py index 6526825..fd2f908 100644 --- a/src/fsrs_optimizer/fsrs_optimizer.py +++ b/src/fsrs_optimizer/fsrs_optimizer.py @@ -814,10 +814,11 @@ def pretrain(self, dataset=None, verbose=True): group = self.S0_dataset_group[ self.S0_dataset_group["r_history"] == first_rating ] - if group.empty and verbose: - tqdm.write( - f"Not enough data for first rating {first_rating}. Expected at least 1, got 0." - ) + if group.empty: + if verbose: + tqdm.write( + f"Not enough data for first rating {first_rating}. Expected at least 1, got 0." + ) continue delta_t = group["delta_t"] recall = (group["y"]["mean"] * group["y"]["count"] + average_recall * 1) / (