def reload_widgets(): """Reload the default classifiers and widgets.""" Classifier.delete_all_classifiers() Classifier.load_default_classifiers() Widget.delete_all_widgets() InteractiveWidget.load_default_widgets() NonInteractiveWidget.load_default_widgets()
def reload_demos(): """Reload default classifiers, widgets, and explorations (in that order).""" Classifier.delete_all_classifiers() Classifier.load_default_classifiers() Widget.delete_all_widgets() InteractiveWidget.load_default_widgets() NonInteractiveWidget.load_default_widgets() Exploration.delete_demo_explorations() Exploration.load_demo_explorations()
def test_loading_and_deletion_of_classifiers(self): """Test loading and deletion of the default classifiers.""" self.assertEqual(Classifier.query().count(), 0) Classifier.load_default_classifiers() classifiers = Classifier.query() classifier_ids = [classifier.id for classifier in classifiers] self.assertIn('Coord2DClassifier', classifier_ids) self.assertEqual(classifiers.count(), 7) Classifier.delete_all_classifiers() self.assertEqual(Classifier.query().count(), 0)
def rules(self): if not self.classifier: return [] return Classifier.get_by_id(self.classifier).rules