def test_typed_ordered_dict(self): self.uut = Setting('key', '1, 2: t, 3') self.assertEqual(typed_ordered_dict(int, str, None)(self.uut), OrderedDict([(1, None), (2, 't'), (3, None)])) with self.assertRaises(ValueError): self.uut = Setting('key', '1, a, 3') typed_ordered_dict(int, str, '')(self.uut)
def test_typed_ordered_dict(self): self.uut = Setting("key", "1, 2: t, 3") self.assertEqual(typed_ordered_dict(int, str, None)(self.uut), OrderedDict([(1, None), (2, "t"), (3, None)])) with self.assertRaises(ValueError): self.uut = Setting("key", "1, a, 3") typed_ordered_dict(int, str, "")(self.uut)
def test_typed_ordered_dict(self): self.uut = Setting('key', '1, 2: t, 3') self.assertEqual( typed_ordered_dict(int, str, None)(self.uut), OrderedDict([(1, None), (2, 't'), (3, None)])) with self.assertRaises(ValueError): self.uut = Setting('key', '1, a, 3') typed_ordered_dict(int, str, '')(self.uut) self.assertRegex( repr(typed_ordered_dict(int, str, None)), # Start ignoring LineLengthBear, PyCodeStyleBear 'typed_ordered_dict\\(int, str, default=None\\) at \\(0x[a-fA-F0-9]+\\)' # Stop ignoring )
from bears.c_languages.codeclone_detection.ClangCountVectorCreator import ( ClangCountVectorCreator) from bears.c_languages.codeclone_detection.CloneDetectionRoutines import ( compare_functions, get_count_matrices) from coalib.bears.GlobalBear import GlobalBear from coalib.collecting.Collectors import collect_dirs from coalib.misc.StringConverter import StringConverter from coalib.results.HiddenResult import HiddenResult from coalib.settings.Setting import path_list, typed_ordered_dict # counting_condition_dict is a function object generated by typed_dict. This # function takes a setting and creates a dictionary out of it while it # converts all keys to counting condition function objects (via the # condition_dict) and all values to floats while unset values default to 1. counting_condition_dict = typed_ordered_dict( lambda setting: condition_dict[str(setting).lower()], float, 1) default_cc_dict = counting_condition_dict(StringConverter( """ used: 0, returned: 1.4, is_condition: 0, in_condition: 1.4, in_second_level_condition: 1.4, in_third_level_condition: 1.0, is_assignee: 0, is_assigner: 0.6, loop_content: 0, second_level_loop_content, third_level_loop_content,
condition_dict) from bears.c_languages.codeclone_detection.ClangCountVectorCreator import ( ClangCountVectorCreator) from bears.c_languages.codeclone_detection.CloneDetectionRoutines import ( compare_functions, get_count_matrices) from coalib.bears.GlobalBear import GlobalBear from coalib.collecting.Collectors import collect_dirs from coalib.misc.StringConverter import StringConverter from coalib.results.HiddenResult import HiddenResult from coalib.settings.Setting import path_list, typed_ordered_dict # counting_condition_dict is a function object generated by typed_dict. This # function takes a setting and creates a dictionary out of it while it # converts all keys to counting condition function objects (via the # condition_dict) and all values to floats while unset values default to 1. counting_condition_dict = typed_ordered_dict( lambda setting: condition_dict[str(setting).lower()], float, 1) default_cc_dict = counting_condition_dict( StringConverter(""" used: 0, returned: 1.4, is_condition: 0, in_condition: 1.4, in_second_level_condition: 1.4, in_third_level_condition: 1.0, is_assignee: 0, is_assigner: 0.6, loop_content: 0, second_level_loop_content, third_level_loop_content, is_param: 2,