Skip to content

Commit

Permalink
Merge branch 'main' into Feat/post-lapse-stability-penalty
Browse files Browse the repository at this point in the history
  • Loading branch information
L-M-Sherlock committed Nov 26, 2024
2 parents 1189293 + ae7575c commit b236f73
Show file tree
Hide file tree
Showing 10 changed files with 1,796 additions and 798 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Ruff
on: [ push, pull_request ]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test Python

on: [push, pull_request]

jobs:
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install pytest
- name: Test with pytest
run: |
pytest
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# FSRS Optimizer

[![PyPi](https://img.shields.io/pypi/v/FSRS-Optimizer)](https://pypi.org/project/FSRS-Optimizer/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

The FSRS Optimizer is a Python library capable of utilizing personal spaced repetition review logs to refine the FSRS algorithm. Designed with the intent of delivering a standardized, universal optimizer to various FSRS implementations across numerous programming languages, this tool is set to establish a ubiquitous standard for spaced repetition review logs. By facilitating the uniformity of learning data among different spaced repetition softwares, it guarantees learners consistent review schedules across a multitude of platforms.

Delve into the underlying principles of the FSRS Optimizer's training process at: https://github.com/open-spaced-repetition/fsrs4anki/wiki/The-mechanism-of-optimization
Expand Down Expand Up @@ -62,3 +64,9 @@ python -m fsrs_optimizer "revlog.csv"
![image](https://github.com/open-spaced-repetition/fsrs-optimizer/assets/32575846/fad7154a-9667-4eea-b868-d94c94a50912)

![image](https://github.com/open-spaced-repetition/fsrs-optimizer/assets/32575846/f868aac4-2e9e-4101-b8ad-eccc1d9b1bd5)

---

## Alternative

Are you getting tired of installing torch? Try [fsrs-rs-python](https://github.com/open-spaced-repetition/fsrs-rs-python)!
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ build-backend = "setuptools.build_meta"

[project]
name = "FSRS-Optimizer"
version = "4.17.0"
version = "5.3.0"
readme = "README.md"
dependencies = [
"matplotlib>=3.7.0",
"numpy>=1.22.4",
"pandas>=1.5.3",
"pytz>=2022.7.1",
"scikit_learn>=1.2.2",
"scikit_learn>=1.4.0",
"torch>=1.13.1",
"tqdm>=4.64.1",
"statsmodels>=0.13.5",
"scipy<1.14.1"
]
requires-python = ">=3.9"

[project.urls]
Homepage = "https://github.com/open-spaced-repetition/fsrs-optimizer"
[tool.ruff.lint]
ignore = ["F405", "F403", "E712", "F541", "E722", "E741"]
18 changes: 13 additions & 5 deletions src/fsrs_optimizer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def prompt(msg: str, fallback):
return response


def process(filepath, filter_out_flags: list[str]):
def process(filepath, filter_out_flags: list[int]):
suffix = filepath.split("/")[-1].replace(".", "_").replace("@", "_")
proj_dir = Path(f"{suffix}")
proj_dir.mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -60,7 +60,8 @@ def remembered_fallback_prompt(key: str, pretty: str = None):

remembered_fallback_prompt("next_day", "used next day start hour")
remembered_fallback_prompt(
"revlog_start_date", "the date at which before reviews will be ignored"
"revlog_start_date",
"the date at which before reviews will be ignored | YYYY-MM-DD",
)
remembered_fallback_prompt(
"filter_out_suspended_cards", "filter out suspended cards? (y/n)"
Expand All @@ -72,6 +73,8 @@ def remembered_fallback_prompt(key: str, pretty: str = None):

if graphs_input.lower() != "y":
remembered_fallbacks["preview"] = "n"
else:
remembered_fallbacks["preview"] = "y"

with open(
config_save, "w+"
Expand All @@ -94,6 +97,7 @@ def remembered_fallback_prompt(key: str, pretty: str = None):
remembered_fallbacks["timezone"],
remembered_fallbacks["revlog_start_date"],
remembered_fallbacks["next_day"],
save_graphs,
)
print(analysis)

Expand All @@ -110,13 +114,17 @@ def remembered_fallback_prompt(key: str, pretty: str = None):
plt.close(f)

optimizer.predict_memory_states()
figures = optimizer.find_optimal_retention()
if save_graphs:
try:
figures = optimizer.find_optimal_retention(verbose=save_graphs)
for i, f in enumerate(figures):
f.savefig(f"find_optimal_retention_{i}.png")
plt.close(f)
except Exception as e:
print(e)
print("Failed to find optimal retention")
optimizer.optimal_retention = 0.9

optimizer.preview(optimizer.optimal_retention)
print(optimizer.preview(optimizer.optimal_retention))

profile = f"""{{
// Generated, Optimized anki deck settings
Expand Down
Loading

0 comments on commit b236f73

Please sign in to comment.