fsrs 2.2.0__tar.gz → 2.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fsrs
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: Free Spaced Repetition Scheduler
5
5
  Author-email: Jarrett Ye <jarrett.ye@outlook.com>
6
6
  License: MIT License
@@ -36,7 +36,11 @@ License-File: LICENSE
36
36
  <div align="center">
37
37
  <img src="https://avatars.githubusercontent.com/u/96821265?s=200&v=4" height="100" alt="Open Spaced Repetition logo"/>
38
38
  </div>
39
- <br />
39
+ <div align="center">
40
+
41
+ # Py-FSRS
42
+
43
+ </div>
40
44
  <div align="center">
41
45
  <em>🧠🔄 Build your own Spaced Repetition System in Python 🧠🔄 </em>
42
46
  </div>
@@ -56,7 +60,7 @@ License-File: LICENSE
56
60
 
57
61
 
58
62
  ## Installation
59
- You can install the `fsrs` python package from PyPI using pip:
63
+ You can install the `fsrs` python package from [PyPI](https://pypi.org/project/fsrs/) using pip:
60
64
  ```
61
65
  pip install fsrs
62
66
  ```
@@ -143,6 +147,10 @@ Get the schdeduled days after rating a card
143
147
  scheduled_days = card_object.scheduled_days
144
148
  ```
145
149
 
150
+ ## Contribute
151
+
152
+ Checkout [CONTRIBUTING](CONTRIBUTING.md) to help improve Py-FSRS!
153
+
146
154
  ## License
147
155
 
148
- Distributed under the MIT License. See `LICENSE` for more information.
156
+ Distributed under the MIT License. See [LICENSE](LICENSE) for more information.
@@ -1,7 +1,11 @@
1
1
  <div align="center">
2
2
  <img src="https://avatars.githubusercontent.com/u/96821265?s=200&v=4" height="100" alt="Open Spaced Repetition logo"/>
3
3
  </div>
4
- <br />
4
+ <div align="center">
5
+
6
+ # Py-FSRS
7
+
8
+ </div>
5
9
  <div align="center">
6
10
  <em>🧠🔄 Build your own Spaced Repetition System in Python 🧠🔄 </em>
7
11
  </div>
@@ -21,7 +25,7 @@
21
25
 
22
26
 
23
27
  ## Installation
24
- You can install the `fsrs` python package from PyPI using pip:
28
+ You can install the `fsrs` python package from [PyPI](https://pypi.org/project/fsrs/) using pip:
25
29
  ```
26
30
  pip install fsrs
27
31
  ```
@@ -108,6 +112,10 @@ Get the schdeduled days after rating a card
108
112
  scheduled_days = card_object.scheduled_days
109
113
  ```
110
114
 
115
+ ## Contribute
116
+
117
+ Checkout [CONTRIBUTING](CONTRIBUTING.md) to help improve Py-FSRS!
118
+
111
119
  ## License
112
120
 
113
- Distributed under the MIT License. See `LICENSE` for more information.
121
+ Distributed under the MIT License. See [LICENSE](LICENSE) for more information.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fsrs"
7
- version = "2.2.0"
7
+ version = "2.3.0"
8
8
  description = "Free Spaced Repetition Scheduler"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Jarrett Ye", email = "jarrett.ye@outlook.com" }]
@@ -0,0 +1,3 @@
1
+ __version__ = "2.3.0"
2
+
3
+ from .fsrs import FSRS, Card, ReviewLog, State, Rating
@@ -39,6 +39,35 @@ class ReviewLog:
39
39
  self.review = review
40
40
  self.state = state
41
41
 
42
+ def to_dict(self):
43
+
44
+ return_dict = {
45
+ "rating": self.rating,
46
+ "scheduled_days": self.scheduled_days,
47
+ "elapsed_days": self.elapsed_days,
48
+ "review": self.review.isoformat(),
49
+ "state": self.state,
50
+ }
51
+
52
+ return return_dict
53
+
54
+ @staticmethod
55
+ def from_dict(source_dict):
56
+
57
+ rating = source_dict["rating"]
58
+ scheduled_days = source_dict["scheduled_days"]
59
+ elapsed_days = source_dict["elapsed_days"]
60
+ review = datetime.fromisoformat(source_dict["review"])
61
+ state = source_dict["state"]
62
+
63
+ return ReviewLog(
64
+ rating,
65
+ scheduled_days,
66
+ elapsed_days,
67
+ review,
68
+ state,
69
+ )
70
+
42
71
 
43
72
  class Card:
44
73
  due: datetime
@@ -250,21 +279,21 @@ class Parameters:
250
279
  self.request_retention = 0.9
251
280
  self.maximum_interval = 36500
252
281
  self.w = (
253
- 0.4,
254
- 0.6,
255
- 2.4,
256
- 5.8,
257
- 4.93,
258
- 0.94,
259
- 0.86,
260
- 0.01,
261
- 1.49,
262
- 0.14,
263
- 0.94,
264
- 2.18,
265
- 0.05,
266
- 0.34,
267
- 1.26,
268
- 0.29,
269
- 2.61,
282
+ 0.4872,
283
+ 1.4003,
284
+ 3.7145,
285
+ 13.8206,
286
+ 5.1618,
287
+ 1.2298,
288
+ 0.8975,
289
+ 0.031,
290
+ 1.6474,
291
+ 0.1367,
292
+ 1.0461,
293
+ 2.1072,
294
+ 0.0793,
295
+ 0.3246,
296
+ 1.587,
297
+ 0.2272,
298
+ 2.8755,
270
299
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fsrs
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: Free Spaced Repetition Scheduler
5
5
  Author-email: Jarrett Ye <jarrett.ye@outlook.com>
6
6
  License: MIT License
@@ -36,7 +36,11 @@ License-File: LICENSE
36
36
  <div align="center">
37
37
  <img src="https://avatars.githubusercontent.com/u/96821265?s=200&v=4" height="100" alt="Open Spaced Repetition logo"/>
38
38
  </div>
39
- <br />
39
+ <div align="center">
40
+
41
+ # Py-FSRS
42
+
43
+ </div>
40
44
  <div align="center">
41
45
  <em>🧠🔄 Build your own Spaced Repetition System in Python 🧠🔄 </em>
42
46
  </div>
@@ -56,7 +60,7 @@ License-File: LICENSE
56
60
 
57
61
 
58
62
  ## Installation
59
- You can install the `fsrs` python package from PyPI using pip:
63
+ You can install the `fsrs` python package from [PyPI](https://pypi.org/project/fsrs/) using pip:
60
64
  ```
61
65
  pip install fsrs
62
66
  ```
@@ -143,6 +147,10 @@ Get the schdeduled days after rating a card
143
147
  scheduled_days = card_object.scheduled_days
144
148
  ```
145
149
 
150
+ ## Contribute
151
+
152
+ Checkout [CONTRIBUTING](CONTRIBUTING.md) to help improve Py-FSRS!
153
+
146
154
  ## License
147
155
 
148
- Distributed under the MIT License. See `LICENSE` for more information.
156
+ Distributed under the MIT License. See [LICENSE](LICENSE) for more information.
@@ -117,7 +117,7 @@ class TestPyFSRS:
117
117
  # card object's due datetime should be later than its last review
118
118
  assert card.due >= card.last_review
119
119
 
120
- def test_serialize(self):
120
+ def test_Card_serialize(self):
121
121
 
122
122
  f = FSRS()
123
123
 
@@ -156,3 +156,49 @@ class TestPyFSRS:
156
156
  # original card and repeated card are different
157
157
  assert vars(card) != vars(repeated_card)
158
158
  assert card.to_dict() != repeated_card.to_dict()
159
+
160
+ def test_ReviewLog_serialize(self):
161
+
162
+ f = FSRS()
163
+
164
+ card = Card()
165
+
166
+ # repeat a card to get the review_log
167
+ scheduling_cards = f.repeat(card)
168
+ rating = Rating.Again
169
+ card = scheduling_cards[rating].card
170
+ review_log = scheduling_cards[rating].review_log
171
+
172
+ # ReviewLog object is not naturally JSON serializable
173
+ with pytest.raises(TypeError):
174
+ json.dumps(review_log.__dict__)
175
+
176
+ # review_log object's to_dict() method makes it JSON serializable
177
+ assert type(json.dumps(review_log.to_dict())) == str
178
+
179
+ # we can reconstruct a copy of the review_log object equivalent to the original
180
+ review_log_dict = review_log.to_dict()
181
+ copied_review_log = ReviewLog.from_dict(review_log_dict)
182
+ assert vars(review_log) == vars(copied_review_log)
183
+ assert review_log.to_dict() == copied_review_log.to_dict()
184
+
185
+ # (x2) perform the above tests once more with a review_log from a repeated card
186
+ scheduling_cards = f.repeat(card, datetime.now(timezone.utc))
187
+ rating = Rating.Good
188
+ card = scheduling_cards[rating].card
189
+ next_review_log = scheduling_cards[rating].review_log
190
+
191
+ with pytest.raises(TypeError):
192
+ json.dumps(next_review_log.__dict__)
193
+
194
+ assert type(json.dumps(next_review_log.to_dict())) == str
195
+
196
+ next_review_log_dict = next_review_log.to_dict()
197
+ copied_next_review_log = ReviewLog.from_dict(next_review_log_dict)
198
+
199
+ assert vars(next_review_log) == vars(copied_next_review_log)
200
+ assert next_review_log.to_dict() == copied_next_review_log.to_dict()
201
+
202
+ # original review log and next review log are different
203
+ assert vars(review_log) != vars(next_review_log)
204
+ assert review_log.to_dict() != next_review_log.to_dict()
@@ -1,5 +0,0 @@
1
- __version__ = "2.2.0"
2
-
3
- from .fsrs import FSRS, Card
4
-
5
- from .fsrs import State, Rating
File without changes
File without changes
File without changes
File without changes
File without changes