def apply(p0: Perception, p1: Perception, cl: Classifier, population: ClassifiersList): if not _perception_changed(p0, p1): handle_useless_case(cl) elif cl.does_anticipate_correctly(p0, p1): handle_expected_case(cl) elif not cl.does_anticipate_correctly(p0, p1) and _perception_changed( p0, p1) and cl.can_be_corrected(p0, p1): handle_correctable_case(p0, p1, cl, population) else: handle_not_correctable_case(cl, p0) # Remove inadequate classifiers for cl in population: if cl.is_inadequate() and not cl.is_general(): population.remove(cl)
def test_distinguish_general_classifier(self, _c, _e, _result, cfg): cl = Classifier(condition=Condition(_c), effect=Effect(_e), cfg=cfg) assert cl.is_general() == _result