aleksejrs / anki-2.0-card-time-forecast

Card time forecast and ease warner add-on for Anki 2.0's card info UI. Shows how much review time may be needed to retain the memory for 5, 10, 15 years. Highlights low ease. Used by some related addons.
https://ankiweb.net/shared/info/2189699505
0 stars 1 forks source link

TypeError: unsupported operand type(s) for *: 'NoneType' and 'float' #1

Open aleksejrs opened 7 years ago

aleksejrs commented 7 years ago

https://anki.tenderapp.com/discussions/add-ons/8386-a-bug-of-card-time-forecast

An error occurred in an add-on.
Please post on the add-on forum:
https://anki.tenderapp.com/discussions/add-ons

Traceback (most recent call last):
  File "aqt\webview.py", line 152, in _linkHandler
  File "aqt\deckbrowser.py", line 41, in _linkHandler
  File "aqt\deckbrowser.py", line 71, in _selDeck
  File "aqt\main.py", line 726, in onOverview
  File "aqt\main.py", line 388, in moveToState
  File "aqt\main.py", line 413, in _overviewState
  File "anki\hooks.py", line 55, in repl
  File "anki\hooks.py", line 55, in repl
  File "anki\hooks.py", line 55, in repl
  File "aqt\overview.py", line 24, in show
  File "aqt\overview.py", line 28, in refresh
  File "aqt\overview.py", line 98, in _renderPage
  File "anki\hooks.py", line 61, in repl
  File "C:\Users\Sergio\Documents\Anki\addons\Study_screen_time_forecast.py", line 82, in myTable
    gr = makeForecastStrings(self.mw)
  File "C:\Users\Sergio\Documents\Anki\addons\Study_screen_time_forecast.py", line 67, in makeForecastStrings
    total = getTotalForIds(mw, ids, forecast_days)
  File "C:\Users\Sergio\Documents\Anki\addons\Study_screen_time_forecast.py", line 44, in getTotalForIds
    f = getForecast(mw, the_card, forecast_days)
  File "C:\Users\Sergio\Documents\Anki\addons\Card_time_forecast.py", line 352, in getForecast
    forecast = repstime_this(forecast_days)
  File "C:\Users\Sergio\Documents\Anki\addons\Card_time_forecast.py", line 345, in repstime_this
    factor=c.factor)
  File "C:\Users\Sergio\Documents\Anki\addons\Card_time_forecast.py", line 274, in repstime
    return reps * time_avg
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'
aleksejrs commented 7 years ago
  1. The problem shows up in “return reps * time_avg”. I guess the problem is that reps is NoneType.
  2. reps is returned by “reps_for_total_ivl”.
  3. reps_for_total_ivl returns either zero or the result of a “for” loop.
  4. To return a proper value, the loop must find total_ivl that is greater than max_total_ivl. Else it will supposedly return NoneType.
aleksejrs commented 7 years ago

In your Study_screen_time_forecast.py file (in Anki/addons/), what does the line with years = say? https://github.com/aleksejrs/anki-2.0-study-screen-time-forecast/blob/master/Study_screen_time_forecast.py#L86

aleksejrs commented 7 years ago

Maybe related https://anki.tenderapp.com/discussions/add-ons/6726-card-info-during-review-add-on-keeps-crashing ? "Some of the cards in your collection have an invalid creation date thousands of years into the future."

aleksejrs commented 5 years ago

Probably found the reason: https://github.com/aleksejrs/anki-2.0-study-screen-time-forecast/issues/2