summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreeaRadoescu <randreea23@gmail.com>2024-10-23 19:24:53 +0200
committerAndreeaRadoescu <randreea23@gmail.com>2024-10-23 19:24:53 +0200
commite289af0c914058490949ace441aada8182de0126 (patch)
tree702f304f1158fb715505f2c3de360358e42f4400
parent875014ebcb8898e6161e7e2d09b127fc4fa595a2 (diff)
parent19aad3fdc3b10312743ff0399a5ad472e6573cad (diff)
Merge branch 'master' into feature/addGUI
-rw-r--r--Makefile17
-rwxr-xr-xbootstrap-venv.sh5
-rw-r--r--flashcards-project/src/flashcards/scheduler_brutal.py2
-rw-r--r--pre-commit4
-rw-r--r--tests/scheduler_brutal_unittest.py2
5 files changed, 23 insertions, 7 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0f277da
--- /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
+ rm -rf venv
+ python -m venv venv
+ ./venv/bin/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/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..9c577e5
--- /dev/null
+++ b/pre-commit
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+./venv/bin/pytest tests/*
+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)