예제 #1
0
 def GenerateNumInclusionsForFilterFunction(self, key_filter_function):
     keys = [
         k for k in self.including_file_dict.keys()
         if key_filter_function(k)
     ]
     output_dict = {}
     for key in keys:
         output_dict[key] = self.including_file_dict[key]
     output_dict = common_utils.DictListValuesToSums(output_dict)
     output_dict = common_utils.DictWithTotal(output_dict)
     return output_dict
예제 #2
0
    def GenerateGroupSizesForFilters(self,
                                     key_partition_function,
                                     filters=None):
        if filters is None:
            filters = []
        including_file_dict = common_utils.DictFilterKeysMatchingRegex(
            self.including_file_dict, filters)

        feature_groups = common_utils.DictPartitionKeys(
            including_file_dict, key_partition_function)

        feature_dict = {}
        for feature, including_files in feature_groups.items():
            feature_dict[feature] = len(including_files)

        feature_dict = common_utils.DictWithTotal(feature_dict)
        return feature_dict
예제 #3
0
    def GenerateGroupNumInclusionsForFilters(self,
                                             key_partition_function,
                                             filters=None):
        if filters is None:
            filters = []
        including_file_dict = common_utils.DictFilterKeysMatchingRegex(
            self.including_file_dict, filters)

        feature_groups = common_utils.DictPartitionKeys(
            including_file_dict, key_partition_function)

        feature_dict = {}
        including_file_dict = common_utils.DictListValuesToSums(
            including_file_dict)
        for feature, including_files in feature_groups.items():
            feature_dict[feature] = 0
            for including_file in including_files:
                feature_dict[feature] += including_file_dict[including_file]

        feature_dict = common_utils.DictWithTotal(feature_dict)
        return feature_dict
예제 #4
0
 def test_DictWithTotal(self):
     test_dict = {"key1": 2, "key2": 0, "key3": 4}
     expected_output = {"key1": 2, "key2": 0, "key3": 4, "total": 6}
     output = common_utils.DictWithTotal(test_dict)
     self.assertEqual(expected_output, output)
예제 #5
0
 def GenerateAnalysis(self):
     output_dict = common_utils.DictListValuesToSums(
         self.included_file_dict)
     output_dict = common_utils.DictWithTotal(output_dict)
     return output_dict