Example #1
0
 def test_two_subdict_keys(self):
     d = torchconfig.get_subdict({
         "G": 5,
         "H": 6
     }, ["G", "H"],
                                 ignore_cases=False)
     assert len(d) == 2
     assert d["G"] == 5
     assert d["H"] == 6
Example #2
0
 def test_two_subdict_keys_case_insensitive(self):
     d = torchconfig.get_subdict({
         "IJ": 5,
         "K": 6
     }, ["iJ", "k"],
                                 ignore_cases=True)
     assert len(d) == 2
     assert d["iJ"] == 5
     assert d["k"] == 6
     assert "IJ" not in d
     assert "K" not in d
Example #3
0
 def test_empty_dict_and_list_case_insensitive(self):
     assert len(torchconfig.get_subdict({}, [], ignore_cases=True)) == 0
Example #4
0
 def test_empty_dict_and_list(self):
     assert len(torchconfig.get_subdict({}, [], ignore_cases=False)) == 0
Example #5
0
 def test_subdict_key_not_in_original_dict_case_insensitive(self):
     d = torchconfig.get_subdict({"N": 8}, ["O"], ignore_cases=True)
     assert len(d) == 0
Example #6
0
 def test_subdict_key_not_in_original_dict(self):
     d = torchconfig.get_subdict({"L": 7}, ["M"], ignore_cases=False)
     assert len(d) == 0
Example #7
0
 def test_one_subdict_key_case_insensitive(self):
     d = torchconfig.get_subdict({"DEF": 4}, ["DeF"], ignore_cases=True)
     assert len(d) == 1
     assert d["DeF"] == 4
     assert "DEF" not in d
Example #8
0
 def test_one_subdict_key(self):
     d = torchconfig.get_subdict({"C": 3}, ["C"], ignore_cases=False)
     assert len(d) == 1
     assert d["C"] == 3