From 3b5f8fec4cfc85d80afed1845c878275b7e2920f Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 6 Dec 2019 18:37:39 +1000 Subject: [PATCH] default to v2 scheduler on new installs, remove warning --- anki/collection.py | 4 ++-- aqt/preferences.py | 14 ++++++-------- designer/preferences.ui | 2 +- tests/shared.py | 5 +---- tests/test_exporting.py | 2 +- tests/test_schedv1.py | 6 +++++- tests/test_schedv2.py | 8 +++----- tests/test_undo.py | 2 +- 8 files changed, 20 insertions(+), 23 deletions(-) diff --git a/anki/collection.py b/anki/collection.py index badf27f9f..b46982639 100644 --- a/anki/collection.py +++ b/anki/collection.py @@ -47,6 +47,7 @@ defaultConf = { 'sortBackwards': False, 'addToCur': True, # add new to currently selected deck? 'dayLearnFirst': False, + 'schedVer': 2, } # this is initialized by storage.Collection @@ -84,11 +85,10 @@ class _Collection: # Scheduler ########################################################################## - defaultSchedulerVersion = 1 supportedSchedulerVersions = (1, 2) def schedVer(self): - ver = self.conf.get("schedVer", self.defaultSchedulerVersion) + ver = self.conf.get("schedVer", 1) if ver in self.supportedSchedulerVersions: return ver else: diff --git a/aqt/preferences.py b/aqt/preferences.py index 108d4a29d..5bdd7d033 100644 --- a/aqt/preferences.py +++ b/aqt/preferences.py @@ -128,16 +128,14 @@ class Preferences(QDialog): if haveNew == wantNew: return - if haveNew and not wantNew: - if not askUser(_("This will reset any cards in learning, clear filtered decks, and change the scheduler version. Proceed?")): - return + if not askUser(_("This will reset any cards in learning, clear filtered decks, and change the scheduler version. Proceed?")): + return + + if wantNew: + self.mw.col.changeSchedulerVer(2) + else: self.mw.col.changeSchedulerVer(1) - return - if not askUser(_("The experimental scheduler could cause incorrect scheduling. Please ensure you have read the documentation first. Proceed?")): - return - - self.mw.col.changeSchedulerVer(2) # Day cutoff ###################################################################### diff --git a/designer/preferences.ui b/designer/preferences.ui index 019ce5dc5..35f29f974 100644 --- a/designer/preferences.ui +++ b/designer/preferences.ui @@ -111,7 +111,7 @@ - Experimental V2 scheduler + New (V2) scheduler diff --git a/tests/shared.py b/tests/shared.py index fef6c29de..70acfe4c0 100644 --- a/tests/shared.py +++ b/tests/shared.py @@ -12,7 +12,7 @@ def assertException(exception, func): # Creating new decks is expensive. Just do it once, and then spin off # copies from the master. -def getEmptyCol(schedVer=1): +def getEmptyCol(): if len(getEmptyCol.master) == 0: (fd, nam) = tempfile.mkstemp(suffix=".anki2") os.close(fd) @@ -22,10 +22,7 @@ def getEmptyCol(schedVer=1): getEmptyCol.master = nam (fd, nam) = tempfile.mkstemp(suffix=".anki2") shutil.copy(getEmptyCol.master, nam) - from anki.collection import _Collection - _Collection.defaultSchedulerVersion = schedVer col = aopen(nam) - _Collection.defaultSchedulerVersion = 1 return col getEmptyCol.master = "" diff --git a/tests/test_exporting.py b/tests/test_exporting.py index e5b6b28b7..005bdd011 100644 --- a/tests/test_exporting.py +++ b/tests/test_exporting.py @@ -82,7 +82,7 @@ def test_export_ankipkg(): @nose.with_setup(setup1) def test_export_anki_due(): - deck = getEmptyCol(schedVer=2) + deck = getEmptyCol() f = deck.newNote() f['Front'] = "foo" deck.addNote(f) diff --git a/tests/test_schedv1.py b/tests/test_schedv1.py index 669fa8a03..4a2c00b3b 100644 --- a/tests/test_schedv1.py +++ b/tests/test_schedv1.py @@ -4,10 +4,14 @@ import time import copy from anki.consts import STARTING_FACTOR -from tests.shared import getEmptyCol +from tests.shared import getEmptyCol as getEmptyColOrig from anki.utils import intTime from anki.hooks import addHook +def getEmptyCol(): + col = getEmptyColOrig() + col.changeSchedulerVer(1) + return col def test_clock(): d = getEmptyCol() diff --git a/tests/test_schedv2.py b/tests/test_schedv2.py index 7e217334c..407326169 100644 --- a/tests/test_schedv2.py +++ b/tests/test_schedv2.py @@ -4,13 +4,10 @@ import time import copy from anki.consts import STARTING_FACTOR -from tests.shared import getEmptyCol as _getEmptyCol +from tests.shared import getEmptyCol from anki.utils import intTime from anki.hooks import addHook -def getEmptyCol(): - return _getEmptyCol(schedVer=2) - def test_clock(): d = getEmptyCol() if (d.sched.dayCutoff - intTime()) < 10*60: @@ -1129,7 +1126,8 @@ def test_failmult(): assert c.ivl == 25 def test_moveVersions(): - col = _getEmptyCol(schedVer=1) + col = getEmptyCol() + col.changeSchedulerVer(1) n = col.newNote() n['Front'] = "one" diff --git a/tests/test_undo.py b/tests/test_undo.py index 68c43e983..457112987 100644 --- a/tests/test_undo.py +++ b/tests/test_undo.py @@ -36,7 +36,7 @@ def test_op(): assert d.undoName() == "Review" def test_review(): - d = getEmptyCol(schedVer=2) + d = getEmptyCol() d.conf['counts'] = COUNT_REMAINING f = d.newNote() f['Front'] = "one"