Esempio n. 1
0
 def test_star_dotdict(self):
     params = star_dotdict(flatten_nested_dict(self.PARAM_DICT), sep=".")
     self.assertTrue(isinstance(params, star_dotdict))
     # try get params by star
     self.assertDictEqual(params["*a"], self.PARAMS_ALL_A)
     # change params by star
     params["*a"] = 0.7
     self.assertDictEqual(params["*a"], self.PARAMS_ALL_A_CHANGED)
     # delete params
     del params["*a"]
     self.assertFalse(params["*a"])
Esempio n. 2
0
 def test_star_dotdict_minus(self):
     params = star_dotdict(flatten_nested_dict(self.PARAM_DICT), sep=".")
     self.assertTrue(isinstance(params, star_dotdict))
     # get params by star
     self.assertDictEqual(params["*b"], self.PARAMS_ALL_B)
     # get params by star and minus
     self.assertDictEqual(params["*b|noise"], self.PARAMS_ALL_B_MINUS)
     # change params by star and minus
     params["*b|noise"] = 2.7
     self.assertDictEqual(params["*b|noise"],
                          self.PARAMS_ALL_B_MINUS_CHANGED)
     # delete params by star and minus
     del params["*b|noise"]
     self.assertFalse(params["*b|noise"])
     # check whether the `b` with noise stayed
     self.assertEqual(len(params["*b"]), 1)