brownbat / autoEaseFactor

Adjust ease factors in Anki based off of performance in order to hit a target success rate.
GNU General Public License v3.0
37 stars 8 forks source link

Initial ease factor update not working for filtered decks #5

Closed BenjaminTran closed 4 years ago

BenjaminTran commented 4 years ago

First, sorry, I have never reported a bug on GitHub before so not sure if this is the proper place to put it. Also, thanks for your work with this addon.

Bug description

Ever since the update where the initial ease factor is taken from the deck options, I have been getting an error (see below) when I open any filtered deck for the first time after starting up Anki.

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-on support site.
Debug info:
Anki 2.1.22 (0ecc189a) Python 3.8.1 Qt 5.14.1 PyQt 5.14.1
Platform: Linux
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2020-08-04 10:38:14
Add-ons possibly involved: ⁨Experimental Card Ease Factor⁩

Caught exception:
Traceback (most recent call last):
  File "aqt/webview.py", line 31, in cmd
  File "aqt/webview.py", line 97, in _onCmd
  File "aqt/webview.py", line 500, in _onBridgeCmd
  File "aqt/overview.py", line 67, in _linkHandler
  File "</usr/local/share/anki/bin/decorator.pyc:decorator-gen-18>", line 2, in moveToState
  File "anki/hooks.py", line 666, in decorator_wrapper
  File "anki/hooks.py", line 657, in repl
  File "aqt/main.py", line 588, in moveToState
  File "aqt/main.py", line 619, in _reviewState
  File "aqt/reviewer.py", line 55, in show
  File "aqt/reviewer.py", line 108, in nextCard
  File "aqt/reviewer.py", line 210, in _showQuestion
  File "aqt/gui_hooks.py", line 1409, in __call__
  File "anki/hooks.py", line 611, in runHook
  File "/home/benjamin/.local/share/Anki2/addons21/1672712021/experimentalCardEaseFactor.py", line 116, in adjust_ease
    calculated_ease = self.calculate_ease(card_id)
  File "/home/benjamin/.local/share/Anki2/addons21/1672712021/experimentalCardEaseFactor.py", line 87, in calculate_ease
    deck_starting_ease = mw.col.decks.confForDid(
KeyError: 'new'

This error only appears when I begin to review from a filtered deck and it is not card dependent as I get the same results with different cards. If I review from a non-filtered deck then I don't get an error and the add-on calculates the ease factor as it should.

Debugging attempts

In the two images below, the top row is the most relevant row (date is 08/05). In this example I used the same card. The relevant steps are below.

  1. Started up Anki
  2. Answered the card once in a filtered deck (after having gotten that error message when I opened the filter deck to review). This is the left image.
  3. I reverted the review back to prior state
  4. Restarted Anki
  5. I moved the card from filtered deck into a non-filtered deck and did the review there. This is the right image.
Filtered Deck Non-filtered deck
Filtered deck image

For the non-filtered deck image, the ease appears to be calculated appropriately as far as I can tell and any subsequent cards are calculated correctly as well.

In the filtered deck image the ease is set to 250% and any subsequent card after that is set to 250% regardless of past answer history. This is also the case if I subsequently go to a non-filtered deck and begin to do reviews there without restarting Anki first. As far as I can tell, the ease factor that it sets the cards is either

  1. 250%: if the first review you do is from a filtered deck after starting up Anki (I'm not sure where it gets the 250 from; it's not from the initial ease factor in deck options because if I change that and repeat the process it still sets to 250%)
  2. Whatever ease factor was calculated from the last card before you get the error message: i.e. I start up Anki and do one review in a non-filtered deck. Then, switch to a filtered deck and get the error message and after answering a card the ease is set to the calculated ease from the review I just did in the non-filtered deck.

I have reverted back to the version (95c42b2) right before the commit to the update and everything is working as expected. Hopefully all of this info here is clear and is helpful.

brownbat commented 4 years ago

This is great, very detailed info.

Basically it's trying to figure out the deck settings for initial ease factor. Filtered decks don't have any settings, so it gets confused, and fails back to 250, the default ease if you don't change anything for a new deck.

The good news is as soon as you study outside the filtered deck, it should calculate the ease off of the total history, and ignore that it was at 250 for a minute.

I just pushed a new version that will fix the error message, but... still trying to confirm it's rescheduling correctly.

This looks right to me: image

It's not calling the last review "filtered," but it really was a filtered review with rescheduling enabled. Does v2 scheduler not distinguish reviews from filtered reviews?

Also note, if you're testing this, the algorithm only looks at previous reviews, so ease factors are really off by one row.

brownbat commented 4 years ago

Here's one I failed during filter. 가볍다 (to be light)

image

Ease is static that last round, which is surprising. But I'm not sure what will happen after I have another regularly scheduled review with that card, I need to hit the normal relearning step to double check.

And weirdly it used to call out filtered reviews explicitly for me, but doesn't anymore. The two most recent reviews on that image are actually from a filtered session.

Still testing this one, thanks for the info.

galantra commented 4 years ago

Ease is static that last round, which is surprising.

Please see my "edit 2" here. I am not quite sure if we mean the same thing. I think that you expect that the review on 2020-08-06 at 10:36 should have lowered the ease?

Intuitively, I would expect an ease decrease, too – but with the review at 10:01.

brownbat commented 4 years ago

The latest patch should address this.

Here it correctly calculates and applies a new ease factor on graduation from a filtered deck (but the factor decreases because it hits the ceiling specified by the leash, which prior reviews weren't bound by): image

Here's one that's pretty close to target, so it gets a slight adjustment: image

Keep an eye out and let me know how it works. Thanks for all the help so far.