示例#1
0
文件: generic.py 项目: konodyuk/kts
 def call(self, *args, **kwargs):
     instance_kwargs = copy(self.kwargs)
     for k, v in zip(self.arg_names, args):
         instance_kwargs[k] = v
         if k in kwargs:
             raise TypeError(
                 f"{self.name}() got multiple values for argument {repr(k)}"
             )
     for k, v in kwargs.items():
         if k not in self.kwargs:
             raise ValueError(f"Unexpected arg: {k}")
         instance_kwargs[k] = v
     res = FeatureConstructor(self.modify(self.func, instance_kwargs),
                              internal=True)
     res.name = f"{self.name}__" + "_".join(
         map(str, instance_kwargs.values()))
     res.description = f"An instance of generic feature constructor <tt>{self.name}</tt>"
     res.source = f"{self.name}({', '.join(f'{repr(instance_kwargs[k])}' for k in self.arg_names)})"
     res.additional_source = self.source
     # res.source = f"{self.name}({', '.join(f'{k}={repr(v)}' for k, v in instance_kwargs.items())})"
     res.requirements = self.requirements
     res.dependencies = dict()
     res.parallel = self.parallel
     res.cache = self.cache
     res.verbose = self.verbose
     return res
示例#2
0
 def register(function):
     if not isinstance(function, GenericFeatureConstructor):
         feature_constructor = FeatureConstructor(function)
     else:
         feature_constructor = function
     feature_constructor.cache = cache
     feature_constructor.parallel = parallel
     feature_constructor.verbose = verbose
     feature_list.register(feature_constructor)
     update_dashboard()
     return feature_constructor