diff options
-rw-r--r-- | Makefile | 17 | ||||
-rwxr-xr-x | bootstrap-venv.sh | 5 | ||||
-rw-r--r-- | cli-project/flashcard_cli.py | 8 | ||||
-rw-r--r-- | flashcards-project/src/flashcards/scheduler_brutal.py | 2 | ||||
-rw-r--r-- | pre-commit | 4 | ||||
-rw-r--r-- | tests/scheduler_brutal_unittest.py | 2 | ||||
-rw-r--r-- | tests/session_integrationtest.py | 2 |
7 files changed, 28 insertions, 12 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3b93bba --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +test: all + ./.venv/bin/pytest tests/* + +all: .venv .git/hooks/pre-commit + +clean: + rm -rf .venv + +.git/hooks/pre-commit: pre-commit + install -m 755 pre-commit .git/hooks/pre-commit + +.venv: requirements.txt cli-project/pyproject.toml flashcards-project/pyproject.toml + rm -rf .venv + uv venv + uv pip install -r requirements.txt + +.PHONY: all test clean diff --git a/bootstrap-venv.sh b/bootstrap-venv.sh deleted file mode 100755 index f3c5580..0000000 --- a/bootstrap-venv.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/zsh - -rm -r venv -python -m venv venv -./venv/bin/pip install -r requirements.txt diff --git a/cli-project/flashcard_cli.py b/cli-project/flashcard_cli.py index 64a26b2..bb2847f 100644 --- a/cli-project/flashcard_cli.py +++ b/cli-project/flashcard_cli.py @@ -7,8 +7,8 @@ from flashcards import Session, SCHEDULERS def cli(): pass -def displayCard(card, index: int, prompt_mode: str) -> None: - click.echo(click.style(f"{index + 1} ===========================================================", fg="blue")) +def displayCard(card, index: int, count: int, prompt_mode: str) -> None: + click.echo(click.style(f"{index + 1}/{count} ===========================================================", fg="blue")) match prompt_mode: case "front": @@ -38,7 +38,7 @@ def practice(state_file, card_files, scheduler_name, count, prompt): session = Session(scheduler_name, card_files, state_file) for i, card in enumerate(session.practice(count)): - displayCard(card, i, prompt) + displayCard(card, i, count, prompt) @cli.command() @click.argument("state_file", nargs=1, type=click.Path()) @@ -53,7 +53,7 @@ def test(state_file, card_files, scheduler_name, count, prompt): session = Session(scheduler_name, card_files, state_file) for i, (card, correct) in enumerate(session.test(count)): - displayCard(card, i, prompt) + displayCard(card, i, count, prompt) correct(click.confirm(click.style("Correct?", bold=True))) if __name__ == '__main__': diff --git a/flashcards-project/src/flashcards/scheduler_brutal.py b/flashcards-project/src/flashcards/scheduler_brutal.py index f2a00c2..f98729c 100644 --- a/flashcards-project/src/flashcards/scheduler_brutal.py +++ b/flashcards-project/src/flashcards/scheduler_brutal.py @@ -59,7 +59,7 @@ class SchedulerBrutal(Scheduler): """ Exposure index is a measure of how much and how recently a card has been shown """ - return sum([i + 1 for i, h in enumerate(history) if h is not None]) + return sum([pow(i + 1, 2) for i, h in enumerate(history) if h is not None]) def _schedule(self, size: int) -> list[str]: weights = range(10, 10 + HISTORY_DEPTH) diff --git a/pre-commit b/pre-commit new file mode 100644 index 0000000..668071c --- /dev/null +++ b/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh + +make test +exit $? diff --git a/tests/scheduler_brutal_unittest.py b/tests/scheduler_brutal_unittest.py index a87e5e9..4790016 100644 --- a/tests/scheduler_brutal_unittest.py +++ b/tests/scheduler_brutal_unittest.py @@ -26,7 +26,7 @@ def test_scheduling(): "9": [None, None, None], } - expected_priority = ["9", "6", "5", "7", "8", "4", "1", "3", "2", "0"] + expected_priority = ["9", "6", "5", "8", "7", "4", "1", "3", "2", "0"] uut = UUT(cards, state) diff --git a/tests/session_integrationtest.py b/tests/session_integrationtest.py index ddabff9..267e374 100644 --- a/tests/session_integrationtest.py +++ b/tests/session_integrationtest.py @@ -1,7 +1,7 @@ import pytest import json -from flashcards.session import Session +from flashcards import Session @pytest.fixture def cardFiles(tmp_path): |