def test_should_decrease_quality(self, cfg): # given cl = Classifier(cfg=cfg) assert cl.q == 0.5 # when cl.decrease_quality() # then assert cl.q == 0.475
def unexpected_case(cl: Classifier, p0: Perception, p1: Perception, time: int) -> Optional[Classifier]: """ The classifier does not anticipate the resulting state correctly. In this case the classifier is marked by the `previous_perception` and it's quality is decreased. If it is possible to specialize an offspring (change pass-through symbols to correct values then new classifier is returned. Parameters ---------- cl: Classifier Classifier object p0: Perception previous situation p1: Perception current situation time: current epoch Returns ------- Optional[Classifier] If possible to specialize parent, None otherwise """ cl.decrease_quality() cl.set_mark(p0) # TODO: think if not cl.effect.is_specializable(p0, p1): return None child = cl.copy_from(cl, time) child.specialize(p0, p1, leave_specialized=True) if child.q < .5: child.q = .5 return child