def unexpected_case(cl: Classifier, p0: Perception, p1: Perception, time: int) -> Optional[Classifier]: """ Controls the unexpected case of the classifier. :param cl: :param p0: :param p1: :param time: :return: specialized classifier if generation was possible, None otherwise """ cl.decrease_quality() cl.set_mark(p0) # Return if the effect is not specializable 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 < 0.5: child.q = 0.5 return child
def unexpected_case(cl: Classifier, p0: Perception, p1: Perception, time: int) -> Optional[Classifier]: """ Controls the unexpected case of the classifier. :param cl: :param p0: :param p1: :param time: :return: specialized classifier if generation was possible, None otherwise """ cl.decrease_quality() cl.set_mark(p0) # Return if the effect is not specializable if not cl.effect.is_specializable(p0, p1): return None child = cl.copy_from(cl, time) if cl.cfg.do_pee: # Probability-Enhanced attributes cannot appear in the effect part # if we leave already specialized attributes unchanged. # Therefore don't leave specialized. child.specialize(p0, p1, leave_specialized=False) else: child.specialize(p0, p1, leave_specialized=True) if child.q < 0.5: child.q = 0.5 return child
def test_should_decrease_quality(self, cfg): # given cls = Classifier(quality=0.47, cfg=cfg) # when cls.decrease_quality() # then assert abs(0.45 - cls.q) < 0.01