def test_lst_with_nested_dict(self): base_props = {"a": 1, "b": 2, "c": {1: 3, 2: 4}} lst = {"a": [4, 1], "c": {1: [70, 50]}} expected_combinations = [{ "a": 1, "b": 2, "c": { 1: 50, 2: 4 } }, { "a": 1, "b": 2, "c": { 1: 70, 2: 4 } }, { "a": 4, "b": 2, "c": { 1: 50, 2: 4 } }, { "a": 4, "b": 2, "c": { 1: 70, 2: 4 } }] actual_combinations = list(get_next_props(base_props, lst)) self.assertEqual(expected_combinations, actual_combinations)
def test_no_lst(self): base_props = {"a": 1, "b": 2, "c": {1: 3, 2: 4}} lst = {} expected_combinations = [base_props] actual_combinations = list(get_next_props(base_props, lst)) self.assertEqual(expected_combinations, actual_combinations)
def test_simple_lst(self): base_props = {"a": 1, "b": 2, "c": {1: 3, 2: 4}} lst = {"a": [4, 1], "d": [7, 3]} expected_combinations = [{ "a": 1, "b": 2, "c": { 1: 3, 2: 4 }, "d": 3 }, { "a": 1, "b": 2, "c": { 1: 3, 2: 4 }, "d": 7 }, { "a": 4, "b": 2, "c": { 1: 3, 2: 4 }, "d": 3 }, { "a": 4, "b": 2, "c": { 1: 3, 2: 4 }, "d": 7 }] actual_combinations = list(get_next_props(base_props, lst)) self.assertEqual(expected_combinations, actual_combinations)
def get_props_to_evaluate(args): with open(args.props) as f: props_base = json.load(f) with open(args.lst) as f: props_list = json.load(f) return props_base, list(get_next_props(props_base, props_list))
def test_coref_manager(self): for props in get_next_props(self.base_props, self.experiment_props): with CorefTrainer(props) as trainer: trainer.train(self.docs, self.hook)
def test_lst_with_two_nested_dicts(self): base_props = { "a": { 100: 1000, 200: 2000 }, "b": 2, "c": { 1: 3, 2: 20, 3: 40 } } lst = {"a": {100: [0, 1]}, "c": {1: [1], 2: [3, 4], 3: [7, 8]}} expected_combinations = [ { "a": { 100: 0, 200: 2000 }, "b": 2, "c": { 1: 1, 2: 3, 3: 7 } }, { "a": { 100: 0, 200: 2000 }, "b": 2, "c": { 1: 1, 2: 3, 3: 8 } }, { "a": { 100: 0, 200: 2000 }, "b": 2, "c": { 1: 1, 2: 4, 3: 7 } }, { "a": { 100: 0, 200: 2000 }, "b": 2, "c": { 1: 1, 2: 4, 3: 8 } }, { "a": { 100: 1, 200: 2000 }, "b": 2, "c": { 1: 1, 2: 3, 3: 7 } }, { "a": { 100: 1, 200: 2000 }, "b": 2, "c": { 1: 1, 2: 3, 3: 8 } }, { "a": { 100: 1, 200: 2000 }, "b": 2, "c": { 1: 1, 2: 4, 3: 7 } }, { "a": { 100: 1, 200: 2000 }, "b": 2, "c": { 1: 1, 2: 4, 3: 8 } }, ] actual_combinations = list(get_next_props(base_props, lst)) self.assertEqual(expected_combinations, actual_combinations)