Exemple #1
0
    def test_no_missing_projections_if_projection_complete(self):
        projections = {
            ('b', ): 'foo',
            (
                'a',
                'b',
            ): 'foo',
            (
                'a',
                'b',
                'c',
            ): 'foo',
            (
                'a',
                'c',
            ): 'foo',
            ('c', ): 'bar'
        }

        label_list = LabelList(labels=[
            Label('b', 3.2, 4.5),
            Label('a', 4.0, 4.9),
            Label('c', 4.2, 5.1)
        ])

        unmapped_combinations = relabeling.find_missing_projections(
            label_list, projections)

        assert len(unmapped_combinations) == 0
Exemple #2
0
    def test_all_projections_missing_if_no_projections_defined(self):
        label_list = LabelList(labels=[
            Label('b', 3.2, 4.5),
            Label('a', 4.0, 4.9),
            Label('c', 4.2, 5.1)
        ])

        unmapped_combinations = relabeling.find_missing_projections(
            label_list, {})

        assert len(unmapped_combinations) == 5
        assert ('b', ) in unmapped_combinations
        assert (
            'a',
            'b',
        ) in unmapped_combinations
        assert (
            'a',
            'b',
            'c',
        ) in unmapped_combinations
        assert (
            'a',
            'c',
        ) in unmapped_combinations
        assert ('c', ) in unmapped_combinations
Exemple #3
0
    def test_missing_projections_are_naturally_sorted(self):
        label_list = LabelList(labels=[
            Label('b', 1.0, 2.0),
            Label('a', 1.5, 2.5),
        ])

        unmapped_combinations = relabeling.find_missing_projections(
            label_list, {})

        assert len(unmapped_combinations) == 3
        assert unmapped_combinations[0] == ('a', )
        assert unmapped_combinations[1] == (
            'a',
            'b',
        )
        assert unmapped_combinations[2] == ('b', )
Exemple #4
0
    def test_no_missing_projections_if_covered_by_catch_all_rule(self):
        projections = {
            ('b', ): 'new_label_b',
            ('**', ): 'new_label_all',
        }

        label_list = LabelList(labels=[
            Label('b', 3.2, 4.5),
            Label('a', 4.0, 4.9),
            Label('c', 4.2, 5.1)
        ])

        unmapped_combinations = relabeling.find_missing_projections(
            label_list, projections)

        assert len(unmapped_combinations) == 0
Exemple #5
0
    def test_no_duplicate_missing_projections_reported(self):
        label_list = LabelList(labels=[
            Label('b', 1.0, 2.0),
            Label('a', 1.5, 2.5),
            Label('b', 3.0, 4.0),
            Label('a', 3.5, 4.5),
        ])

        unmapped_combinations = relabeling.find_missing_projections(
            label_list, {})

        assert len(unmapped_combinations) == 3
        assert ('b', ) in unmapped_combinations
        assert (
            'a',
            'b',
        ) in unmapped_combinations
        assert ('a', ) in unmapped_combinations