Skip to content

Commit

Permalink
Feat/format time & remove delay limit (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
L-M-Sherlock authored Nov 11, 2024
1 parent f9a1f45 commit cb34bec
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ def get_steps_stats(self: CollectionStats):
<tr>
<td class="trl"><span class="{style}"><b>{style.title()}</b></span></td>
<td class="trr">{stats['r1']}</td>
<td class="trr">{stats['delay_q1'] / 60:.2f} min</td>
<td class="trr">{format_time(stats['delay_q1'])}</td>
<td class="trr">{stats['r2']}</td>
<td class="trr">{stats['delay_q2'] / 60:.2f} min</td>
<td class="trr">{format_time(stats['delay_q2'])}</td>
<td class="trr">{stats['r3']}</td>
<td class="trr">{stats['delay_q3'] / 60:.2f} min</td>
<td class="trr">{format_time(stats['delay_q3'])}</td>
<td class="trr">{stats['r4']}</td>
<td class="trr">{stats['retention']}</td>
<td class="trr">{results['stability'][rating] / 60:.2f} min</td>
<td class="trr">{format_time(results['stability'][rating])}</td>
<td class="trr">{stats['count']}</td>
</tr>"""

Expand Down
6 changes: 2 additions & 4 deletions steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def total_loss(points, stability):
return sum(log_loss(y, power_forgetting_curve(x, stability)) for x, y in points)


def binary_search(points, low=1, high=86400, tolerance=1e-6):
def binary_search(points, low=1, high=86400 * 30, tolerance=1e-6):
while high - low > tolerance:
mid = (low + high) / 2
left = mid - tolerance
Expand Down Expand Up @@ -43,8 +43,7 @@ def steps_stats(lim):
ROW_NUMBER() OVER (PARTITION BY r.cid ORDER BY r.id) AS review_order
FROM revlog r
JOIN first_review fr ON r.cid = fr.cid AND r.id > fr.first_id
WHERE (r.id - fr.first_id) <= 43200000
AND r.ease BETWEEN 1 AND 4
WHERE r.ease BETWEEN 1 AND 4
),
review_stats AS (
SELECT fr.first_rating,
Expand Down Expand Up @@ -86,7 +85,6 @@ def steps_stats(lim):
(nr.next_id - nr.first_id) / 1000.0 AS delta_t,
nr.recall
FROM next_review nr
WHERE (nr.next_id - nr.first_id) <= 43200000
)
SELECT
delta_t,
Expand Down
11 changes: 11 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,14 @@ def ask_one_way_sync():
+ "and not synced them to this device yet, please do so before you proceed.\n"
+ "Do you want to proceed?"
)


def format_time(x, pos=None):
if x < 60:
return f"{x:.0f}s"
elif x < 3600:
return f"{x/60:.2f}m"
elif x < 86400:
return f"{x/3600:.2f}h"
else:
return f"{x/86400:.2f}d"

0 comments on commit cb34bec

Please sign in to comment.