Skip to content

Commit

Permalink
👷 Fix tests, update README and add Github actions
Browse files Browse the repository at this point in the history
* ✔️ Add missing assertions to test_api.py.
* 📚 Update README badges and fix format.
* 👷 Add Github actions to run tests against Python versions 3.6 to 3.9 in different OS, and upload coverage to Codecov.
  • Loading branch information
alankan886 authored Jan 2, 2021
1 parent aa078ba commit 80d4db6
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 76 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
jobs:
run:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
PYTHONPATH: /home/runner/work/SuperMemo2/SuperMemo2
- name: Generate coverage report
run: |
python -m pip install --upgrade pip
pip install pytest-cov
pytest --cov=supermemo2 --cov-report=xml
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v1
25 changes: 0 additions & 25 deletions .github/workflows/codecov.yml

This file was deleted.

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ README.txt
.*

# pytest-cov
htmlcov
htmlcov

# Github workflows
!.github
80 changes: 40 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# SuperMemo2
![Python](https://img.shields.io/badge/Python-3.7+-blue.svg?logo=python&longCache=true&logoColor=white&colorB=5e81ac&style=flat-square&colorA=4c566a)
![Version](https://img.shields.io/badge/Version-1.0.0-light--blue.svg?style=flat-square&colorA=4c566a&colorB=90A2BC)
[![Download](https://img.shields.io/badge/Downloads-2.3k+-light--blue.svg?style=flat-square&colorA=4c566a&colorB=90A2BC)](https://pepy.tech/project/SuperMemo2)
[![Coverage](https://img.shields.io/badge/Coverage-100%25-light--green.svg?style=flat-square&colorA=4c566a&colorB=90BCA8)](#coverage)
![Python](https://img.shields.io/badge/python-3.6+-blue.svg?logo=python&longCache=true&logoColor=white&colorB=5e81ac&style=flat-square&colorA=4c566a)
[![Version](https://img.shields.io/pypi/v/supermemo2?logo=pypi&logoColor=white&style=flat-square&colorA=4c566a&colorB=90A2BC)](https://pypi.org/project/supermemo2/)
[![Build](https://img.shields.io/github/workflow/status/alankan886/SuperMemo2/CI?logo=github-actions&logoColor=white&style=flat-square&colorA=4c566a&colorB=90BCA8)](https://github.com/alankan886/SuperMemo2/actions?query=workflow%3ACI)
[![Coverage](https://img.shields.io/codecov/c/github/alankan886/SuperMemo2?logo=codecov&logoColor=white&style=flat-square&colorA=4c566a&colorB=90BCA8)](https://codecov.io/gh/alankan886/SuperMemo2)
[![Download](https://img.shields.io/badge/downloads-2k-light--blue.svg?style=flat-square&colorA=4c566a&colorB=90A2BC)](https://pepy.tech/project/SuperMemo2)

A package that implemented the spaced repetition algorithm SuperMemo-2/SM-2 for you to quickly calculate your next review date for whatever you are learning.

Expand All @@ -23,11 +24,13 @@ A package that implemented the spaced repetition algorithm SuperMemo-2/SM-2 for
- [Changelog](#changelog)
- [Credits](#credits)

<a name="motivation"> </br>
<a name="motivation">

## Motivation
The goal was to have an efficient way to calculate the next review date for studying/learning. Removes the burden of remembering the algorithm, equations, and math from the users.

<a name="install-versions"> </br>
<a name="install-versions">

## Installation and Supported Versions

### Package Install
Expand All @@ -37,7 +40,7 @@ Install and upate the package using [pip](https://pip.pypa.io/en/stable/quicksta
pip3 install -U supermemo2
```

<a name="download"> </br>
<a name="download">

### To Play Around with the Code
Download the code:
Expand All @@ -51,9 +54,10 @@ Install dependencies to run the code:
pip3 install -r requirements.txt
```

supermemo2 supports Python 3.7+.
supermemo2 supports Python 3.6+.

<a name="example">

<a name="example"> </br>
## A Simple Example

We start with a recall quality of 3, and the review date defaults to today (let's pretend it's 2021-01-01).
Expand All @@ -74,19 +78,22 @@ Grab the current values from the first review, and update the recall quality. Th
2021-01-08
```

<a name="features"> </br>
<a name="features">

## Features
:mega: Calculates the next review date of the task following the SuperMemo-2/SM-2 algorithm.
<br/> :mega: The first_review method to create a new instance at ease without having to know the initial values.
<br/> :mega: The modify method to modify existing instance values that recalculates the new values.
<br/> :mega: The json and dict methods to export the instance values and to help calculate the next review date.

<a name="potential"> </br>
<a name="potential">

### Potential Features
- Allow users to pass the review date as a string in many formats.
- Provide a modified option to configure the intervals for repetitions 1 and 2. And an option to reduce quality responses to 4, since 0 to 2 doesn't do much.

<a name="sm2"> </br>
<a name="sm2">

## What is SuperMemo-2?
:movie_camera: If you are curious of what spaced repetition is, check this [short video](https://youtu.be/-uMMRjrzPmE?t=94) out.

Expand All @@ -110,7 +117,8 @@ The values are the:

:pencil2: quality from 0 to 2 doesn't have much impact; it doesn't affect the easiness. If you are building a program on top of this package, you may group them as one response. So instead of 6 responses, you have 4 (5, 4, 3, and incorrect response).

<a name="api"> </br>
<a name="api">

## API Reference

<a name="main-interface">
Expand Down Expand Up @@ -169,13 +177,14 @@ supermemo2.**modify**(instance, quality=None, easiness=None, interval=None, repe
<a name="excep">

### Exceptions
exception supermemo2.exceptions.CalcNotCalledYet
exception supermemo2.exceptions.**CalcNotCalledYet**

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Other methods are called before the values are calculated.

<a name="classes">

### Lower-Level Classes
class supermemo2.SMTwo()
class supermemo2.**SMTwo()**

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Generates all the instances and contains the tools.

Expand Down Expand Up @@ -248,7 +257,7 @@ class supermemo2.SMTwo()
'{"quality": 3, "prev_easiness": 2.5, "prev_interval": 1, "prev_repetitions": 1, "prev_review_date": datetime.date(2021, 1, 1),"easiness": 2.36, "interval": 2, "repetitions": 1, "review_date": datetime.date(2021, 1, 2)}'
```

class supermemo2.SMTwo.Prev(easiness, interval, repetitions, review_date)
class supermemo2.SMTwo.**Prev**(easiness, interval, repetitions, review_date)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stores the previous values.

Expand All @@ -266,52 +275,43 @@ Assuming you [dowloaded the code and installed requirements](#download).

### Run the tests
```bash
pytest tests
pytest tests/
```

### Check test coverages
```bash
pytest --cov=supermemo2
```
<a name="coverage">

```bash
---------- coverage: platform darwin, python 3.7.6-final-0 -----------
Name Stmts Miss Cover
----------------------------------------------
supermemo2/__init__.py 1 0 100%
supermemo2/api.py 27 0 100%
supermemo2/exceptions.py 4 0 100%
supermemo2/model.py 94 0 100%
supermemo2/util.py 3 0 100%
----------------------------------------------
TOTAL 129 0 100%
```

Check coverage on [Codecov](https://codecov.io/gh/alankan886/SuperMemo2).

<a name="changelog">

## Changelog

1.0.0 2020-12-31 Complete rebuild, Update recommended
- Build new SMTwo class using the attrs package.
- Provie API methods to quickly access the SMTwo class.
1.0.1 (2021-01-02): Fix tests, update README and add Github actions, Update not required
- Add missing assertions to test_api.py.
- Update README badges and fix format.
- Add Github actions to run tests against Python versions 3.6 to 3.9 in different OS, and upload coverage to Codecov.

1.0.0 (2021-01-01): Complete rebuild, Update recommended
- Build a new SMTwo class using the attrs package.
- Provide API methods to quickly access the SMTwo class.
- Develop 100% coverage integration and unit tests in a TDD manner.
- Write new documentation.

0.1.0 2020-07-14 Add tests, Update not required
0.1.0 (2020-07-14): Add tests, Update not required
- Add passing unit tests with a coverage of 100%.

0.0.4 2020-07-10 Minor bug fix, Update recommended
0.0.4 (2020-07-10): Minor bug fix, Update recommended
- Fix interval calculation error when q < 3.

0.0.3 2020-07-06 Documentation Update, Update not required
0.0.3 (2020-07-06): Documentation Update, Update not required
- Add new section about SuperMemo-2 in documentation, and fix some formats in README.

0.0.2 2020-07-05 Refactor feature, Update recommended
0.0.2 (2020-07-05): Refactor feature, Update recommended
- Refactor the supermemo2 algorithm code into a simpler structure, and remove unnecessary methods in the class.

0.0.1 2020-07-02 Feature release
0.0.1 (2020-07-02): Feature release
- Initial Release

<a name="credits">
Expand Down
Empty file added tests/__init__.py
Empty file.
22 changes: 12 additions & 10 deletions tests/integration/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
@pytest.mark.parametrize("quality", (0, 1, 2, 3, 4, 5))
def test_first_review_default_review_date(quality):
smtwo = first_review(quality)
smtwo.quality == quality
smtwo.prev.easiness == 2.5
smtwo.prev.interval == 1
smtwo.prev.repetitions == 1
smtwo.prev.review_date == date.today()
assert smtwo.quality == quality
assert smtwo.prev.easiness == 2.5
assert smtwo.prev.interval == 1
assert smtwo.prev.repetitions == 1
assert smtwo.prev.review_date == date.today()
assert smtwo.review_date == date.today() + timedelta(days=1)


@pytest.mark.parametrize(
Expand All @@ -31,11 +32,12 @@ def test_first_review_default_review_date(quality):
)
def test_first_review(quality, review_date):
smtwo = first_review(quality, review_date)
smtwo.quality == quality
smtwo.prev.easiness == 2.5
smtwo.prev.interval == 1
smtwo.prev.repetitions == 1
smtwo.review_date == review_date
assert smtwo.quality == quality
assert smtwo.prev.easiness == 2.5
assert smtwo.prev.interval == 1
assert smtwo.prev.repetitions == 1
assert smtwo.prev.review_date == review_date
assert smtwo.review_date == review_date + timedelta(days=1)


@pytest.mark.parametrize("quality", (0, 1, 2, 3, 4, 5))
Expand Down

0 comments on commit 80d4db6

Please sign in to comment.