Example #1
0
    def test_should_get_differences_4(self, cfg):
        # given
        p0 = Perception(['1', '1', '1', '1', '1', '0', '1', '0'])
        mark = PMark(cfg)
        mark[0].update(['0', '1'])
        mark[1].update(['0', '1'])
        mark[3].update(['0', '1'])
        mark[4].update(['0', '1'])
        mark[6].update(['0', '1'])
        mark[7].update(['0'])

        # when
        diff = mark.get_differences(p0)

        # then
        assert diff is not None
        assert 5 == diff.specificity
        assert '1' == diff[0]
        assert '1' == diff[1]
        assert '#' == diff[2]
        assert '1' == diff[3]
        assert '1' == diff[4]
        assert '#' == diff[5]
        assert '1' == diff[6]
        assert '#' == diff[7]
Example #2
0
    def test_should_get_differences_3(self, cfg):
        # Given
        p0 = Perception(['0', '1', '1', '0', '0', '0', '0', '0'])
        mark = PMark(cfg)
        mark[0].update(['0', '1'])
        mark[1].update(['1'])
        mark[2].update(['0', '1'])
        mark[3].update(['1'])
        mark[4].update(['0', '1'])
        mark[5].update(['1'])
        mark[6].update(['0', '1'])
        mark[7].update(['1'])

        for _ in range(100):
            # When
            diff = mark.get_differences(p0)

            # Then
            assert diff is not None
            assert '#' == diff[0]
            assert '#' == diff[1]
            assert '#' == diff[2]
            assert '#' == diff[4]
            assert '#' == diff[6]
            assert 1 == diff.specificity
Example #3
0
    def test_should_get_differences_1(self, _p0, cfg):
        # given
        generic_condition = Condition.empty(length=cfg.classifier_length)
        p0 = Perception(_p0)
        mark = PMark(cfg)

        # when
        diff = mark.get_differences(p0)

        # then
        assert diff == generic_condition
Example #4
0
    def test_should_get_differences_5(self, cfg):
        # Given
        p0 = Perception(['0', '0', '2', '1', '1', '0', '1', '0'])
        mark = PMark(cfg)
        mark[3].add('0')
        mark[6].add('0')

        for _ in range(100):
            # When
            diff = mark.get_differences(p0)

            # Then
            assert diff is not None
            assert 1 == diff.specificity