def test_should_handle_unexpected_case_2(self, cfg): # given p0 = Perception([.5, .5], oktypes=(float, )) p1 = Perception([.5, .5], oktypes=(float, )) # Effect is not specializable effect = Effect([UBR(0, 15), UBR(2, 4)], cfg=cfg) quality = random.random() time = random.randint(0, 1000) cl = Classifier(effect=effect, quality=quality, cfg=cfg) # when child = unexpected_case(cl, p0, p1, time) # then assert cl.q < quality assert cl.is_marked() is True # We cannot generate child from non specializable parent assert child is None
def test_should_handle_unexpected_case_3(self, cfg): # given p0 = Perception([.5, .5], oktypes=(float, )) p1 = Perception([.5, .8], oktypes=(float, )) # Second effect attribute is specializable effect = Effect([UBR(0, 15), UBR(10, 14)], cfg=cfg) quality = 0.4 time = random.randint(0, 1000) cl = Classifier(effect=effect, quality=quality, cfg=cfg) # when child = unexpected_case(cl, p0, p1, time) # then assert cl.q < quality assert cl.is_marked() is True assert child is not None assert child.is_marked() is False assert child.q == .5 assert child.condition == Condition([UBR(0, 15), UBR(0, 15)], cfg=cfg) assert child.effect == Effect([UBR(0, 15), UBR(10, 14)], cfg=cfg)
def test_should_handle_unexpected_case_1(self, cfg): # given p0 = Perception([.5, .5], oktypes=(float, )) p1 = Perception([.5, .5], oktypes=(float, )) # Effect is all pass-through. Can be specialized. effect = Effect([UBR(0, 15), UBR(0, 15)], cfg=cfg) quality = .4 time = random.randint(0, 1000) cl = Classifier(effect=effect, quality=quality, cfg=cfg) # when child = unexpected_case(cl, p0, p1, time) # then assert cl.q < quality assert cl.is_marked() is True assert child assert child.q == .5 assert child.talp == time # There is no change in perception so the child condition # and effect should stay the same. assert child.condition == Condition([UBR(0, 15), UBR(0, 15)], cfg=cfg) assert child.effect == Effect([UBR(0, 15), UBR(0, 15)], cfg=cfg)