示例#1
0
 def get_default_parameters(
     self,
 ) -> tp.Tuple[tp.Optional[types.Parameters], types.ParameterCollection]:
     param_tree = self._get_parameters(defaults=True)
     collections = utils.split_into_collections(param_tree)
     parameters = collections.pop("parameters", None)
     return parameters, collections
示例#2
0
 def get_parameters_internal(
     self, defaults: bool = False
 ) -> tp.Tuple[tp.Optional[types.Parameters], types.ParameterCollection]:
     param_tree = self._get_parameters(defaults=defaults)
     collections = utils.split_into_collections(param_tree)
     parameters = collections.pop("parameters", None)
     return parameters, collections
示例#3
0
    def set_default_parameters(
        self,
        parameters: tp.Optional[types.Parameters],
        collections: types.ParameterCollection,
    ):

        if parameters is not None:
            collections = collections.copy()
            collections["parameters"] = parameters

        old_colletions = self._get_parameters(defaults=True)
        old_colletions = utils.split_into_collections(old_colletions)

        try:
            self._set_parameters_internal(
                collections=collections,
                set_default_params=True,
            )
        except:
            self._set_parameters_internal(
                collections=old_colletions,
                set_default_params=True,
            )
            raise
示例#4
0
文件: module.py 项目: sooheon/elegy
 def get_parameters_internal(self,
                             defaults: bool = False
                             ) -> types.ParameterCollection:
     parameters = self._get_parameters(defaults=defaults)
     return utils.split_into_collections(parameters)
示例#5
0
文件: module.py 项目: sooheon/elegy
 def get_default_parameters(self) -> types.ParameterCollection:
     parameters = self._get_parameters(defaults=True)
     return utils.split_into_collections(parameters)