JarrettYe commited on
Commit
f15ccc9
1 Parent(s): d36cd6f

Fix/index 0 is out of bounds when all duration is 0 (#2)

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -84,11 +84,15 @@ def optimizer(
84
  difficulty_distribution = optimizer.difficulty_distribution.to_string().replace(
85
  "\n", "\n\n"
86
  )
87
- plot_output = optimizer.find_optimal_retention(
88
- learn_span=365, # days to learn
89
- max_ivl=36500, # days
90
- loss_aversion=2.5, # forget cost is multiplied by this factor to simulate loss aversion
91
- )[0]
 
 
 
 
92
  suggested_retention_markdown = (
93
  f"""# Suggested Retention: `{optimizer.optimal_retention:.2f}`"""
94
  )
 
84
  difficulty_distribution = optimizer.difficulty_distribution.to_string().replace(
85
  "\n", "\n\n"
86
  )
87
+ try:
88
+ plot_output = optimizer.find_optimal_retention(
89
+ learn_span=365, # days to learn
90
+ max_ivl=36500, # days
91
+ loss_aversion=2.5, # forget cost is multiplied by this factor to simulate loss aversion
92
+ )[0]
93
+ except:
94
+ print("Failed to find optimal retention")
95
+ optimizer.optimal_retention = 0.9
96
  suggested_retention_markdown = (
97
  f"""# Suggested Retention: `{optimizer.optimal_retention:.2f}`"""
98
  )