Example #1
0
    def test_should_detect_correctable_classifier(self, _c, _e, _p0, _p1,
                                                  _result, cfg):

        cl = Classifier(condition=_c, effect=_e, cfg=cfg)
        p0 = Perception(_p0)
        p1 = Perception(_p1)

        assert cl.can_be_corrected(p0, p1) is _result
Example #2
0
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)