def test_get_params(self): def param(x): return core.ScopedBlobReference(x) def to_str_list(x): return sorted([str(p) for p in x]) model = ModelHelper(name="test_model") model.AddParameter(param("a")) model.AddParameter(param("b"), tags=ParameterTags.COMPUTED_PARAM) with scope.NameScope("c"): model.AddParameter(param("a")) model.AddParameter(param("d"), tags=ParameterTags.COMPUTED_PARAM) self.assertEqual(to_str_list(model.GetParams()), ['c/a']) self.assertEqual(to_str_list(model.GetComputedParams()), ['c/d']) self.assertEqual(to_str_list(model.GetAllParams()), ['c/a', 'c/d']) # Get AllParams from the global Scope self.assertEqual(to_str_list(model.GetAllParams('')), ['a', 'b', 'c/a', 'c/d']) self.assertEqual(to_str_list(model.GetParams()), ['a', 'c/a']) self.assertEqual(to_str_list(model.GetComputedParams()), ['b', 'c/d']) self.assertEqual(to_str_list(model.GetAllParams()), ['a', 'b', 'c/a', 'c/d']) self.assertEqual(to_str_list(model.GetAllParams('')), ['a', 'b', 'c/a', 'c/d']) # Get AllParams from the scope 'c' self.assertEqual(to_str_list(model.GetAllParams('c')), ['c/a', 'c/d']) self.assertEqual(to_str_list(model.GetAllParams('c/')), ['c/a', 'c/d'])