Skip to content

Commit

Permalink
Fix/columns not found for two-button user (#126)
Browse files Browse the repository at this point in the history
* Fix/Columns not found for two-button users

* format

* bump version
  • Loading branch information
L-M-Sherlock authored Jul 27, 2024
1 parent 66d4695 commit 11d11f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "FSRS-Optimizer"
version = "5.0.3"
version = "5.0.4"
readme = "README.md"
dependencies = [
"matplotlib>=3.7.0",
Expand Down
11 changes: 8 additions & 3 deletions src/fsrs_optimizer/fsrs_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,8 @@ def flags2str(flags: List[int]) -> str:

def extract_simulation_config(self, df):
def rating_counts(x):
tmp = defaultdict(int, x.value_counts().to_dict())
tmp = {1: 0, 2: 0, 3: 0, 4: 0}
tmp.update(x.value_counts().to_dict())
first = x.iloc[0]
tmp[first] -= 1
return tmp
Expand Down Expand Up @@ -628,8 +629,12 @@ def rating_counts(x):
.to_dict()
),
)
self.learn_buttons = np.array([button_usage_dict[(1, i)] for i in range(1, 5)])
self.review_buttons = np.array([button_usage_dict[(2, i)] for i in range(1, 5)])
self.learn_buttons = (
np.array([button_usage_dict[(1, i)] for i in range(1, 5)]) + 1
)
self.review_buttons = (
np.array([button_usage_dict[(2, i)] for i in range(1, 5)]) + 1
)
self.first_rating_prob = self.learn_buttons / self.learn_buttons.sum()
self.review_rating_prob = (
self.review_buttons[1:] / self.review_buttons[1:].sum()
Expand Down

0 comments on commit 11d11f9

Please sign in to comment.