Esempio n. 1
0
 def test_list_difference_1d_binary_not_normalized(self):
     diff = utils.list_difference_1d(
         a=self.first_bins,
         b=self.second_bins,
         function=utils.DiffFuncConst.BINARY.value,
         normalized=False,
         inverse=False)
     self.assertEqual(4, diff)
Esempio n. 2
0
 def test_list_difference_1d_single_normalized(self):
     diff = utils.list_difference_1d(
         a=self.first_bins,
         b=self.second_bins,
         function=utils.DiffFuncConst.SINGLE.value,
         normalized=True,
         inverse=False)
     # (10 (val of list entry) * 4 (number of different bins)) / 60 (number of values in total)
     expected = (10 * 4) / 60
     self.assertEqual(expected, diff)
Esempio n. 3
0
    def test_list_difference_1d_binary_normalized(self):
        diff = utils.list_difference_1d(
            a=self.first_bins,
            b=self.second_bins,
            function=utils.DiffFuncConst.BINARY.value,
            normalized=True,
            inverse=False)

        expected = (4 / coverage_evaluator.NUM_BINS)
        self.assertEqual(expected, diff)
Esempio n. 4
0
 def test_list_difference_1d_single_normalized_unequal(self):
     diff = utils.list_difference_1d(
         a=self.first_bins_halved,
         b=self.second_bins,
         function=utils.DiffFuncConst.SINGLE.value,
         normalized=True,
         inverse=False)
     # 5 (val of list entry) * 2 (number of different bins) + 10 * 2 + 5
     expected = 2 / 3
     self.assertEqual(expected, diff,
                      "Unequal element count causes problems")
    def road_compare_1d(self, road_to_compare: str, measure: str):
        """ compares the coverage of a single-dimensional feature of a road to all others in the suite

        :param road_to_compare: the baseline road which is compared to all others
        :param measure: the feature which is compare, has to be present for each road in the suite dict
        :return: None
        """
        road_similarities = {}
        main_bin = self.test_dict.get(road_to_compare).get(measure)
        assert main_bin is not None, "The bin " + measure + " has not been added or spelling is incorrect"
        # print(main_bin)
        for i in range(self.start, self.end + 1):
            road_similarities[str(i)] = utils.list_difference_1d(
                main_bin,
                self.test_dict.get(str(i)).get(measure),
                function='binary',
                normalized=True)
        # print(road_similarities)
        self.test_dict.get(road_to_compare)[road_to_compare + ' ' +
                                            measure] = road_similarities