Build the estimator method or function.

        Returns
        -------
        :return : string
            The built method as string.
357640
def create_method(self):
        
        n_indents = 1 if self.target_language in ['java', 'js',
                                                  'php', 'ruby'] else 0
        return self.temp('separated.method', n_indents=n_indents,
                         skipping=True).format(**self.__dict__)
530238
def build_api_struct(self):
        
        self.clean()
        data = {"type": self.measurement_type}

        # add all options
        for option in self.used_options:
            option_key, option_value = self.v2_translator(option)
            data.update({option_key: option_value})

        return data
191498
def create_class(self, method):
        
        temp_type = self.temp('type')
        temp_arr = self.temp('arr')
        temp_arr_ = self.temp('arr[]')
        temp_arr__ = self.temp('arr[][]')

        # Samples:
        temps = []
        for atts in enumerate(self.estimator._fit_X):  # pylint: disable=W0212
            tmp = [temp_type.format(self.repr(a)) for a in atts[1]]
            tmp = temp_arr.format(', '.join(tmp))
            temps.append(tmp)
        temps = ', '.join(temps)
        temps = temp_arr__.format(type='double', name='X', values=temps,
                                  n=self.n_templates, m=self.n_features)

        # Classes:
        classes = self.estimator._y  # pylint: disable=W0212
        classes = [temp_type.format(int(c)) for c in classes]
        classes = ', '.join(classes)
        classes = temp_arr_.format(type='int', name='y', values=classes,
                                   n=self.n_templates)

        temp_class = self.temp('separated.class')
        return temp_class.format(class_name=self.class_name,
                                 method_name=self.method_name, method=method,
                                 n_features=self.n_features, X=temps, y=classes,
                                 n_neighbors=self.n_neighbors,
                                 n_templates=self.n_templates,
                                 n_classes=self.n_classes,
                                 power=self.power_param)
155437
def method_descriptor(descriptor: str) -> MethodDescriptor:
    
    end_para = descriptor.find(')')
    returns = descriptor[end_para + 1:]
    args = descriptor[1:end_para]

    return MethodDescriptor(
        parse_descriptor(returns)[0],
        parse_descriptor(args),
        returns,
        args,
        descriptor
    )
1080507
def _prepare_method(self, pandas_func, **kwargs):
        
        if self._is_transposed:

            def helper(df, internal_indices=[]):
                if len(internal_indices) > 0:
                    return pandas_func(
                        df.T, internal_indices=internal_indices, **kwargs
                    )
                return pandas_func(df.T, **kwargs)

        else:

            def helper(df, internal_indices=[]):
                if len(internal_indices) > 0:
                    return pandas_func(df, internal_indices=internal_indices, **kwargs)
                return pandas_func(df, **kwargs)

        return helper
391990
def _get_method(name, func):
    ""
    def method(self, *args, **kw):
        return func(self, *args, **kw)
    method.__name__ = name
    return method
102699
def _class_defining_method(meth):  # pragma: no cover
    '''
    '''
    if inspect.ismethod(meth):
        for cls in inspect.getmro(meth.__self__.__class__):
            if cls.__dict__.get(meth.__name__) is meth:
                return '{}.{}'.format(cls.__module__, cls.__name__)
        meth = meth.__func__
    if inspect.isfunction(meth):
        module = meth.__qualname__.split('.<locals>', 1)[0]
        cls = getattr(inspect.getmodule(meth), module.rsplit('.', 1)[0])
        if isinstance(cls, type):
            return '{}.{}'.format(cls.__module__, cls.__name__)
1138788
def return_estimator(self):
        
        estimator = self.base_learner_origin.return_estimator()
        estimator = estimator.set_params(**self.hyperparameters)
        return estimator
1134010
def get_output(self):
        
        # generate the JS function string
        template_function = TEMPLATE_WRAPPER.format(
            function_name=self.js_function_name,
            template_code=self.output.getvalue()
        ).strip()

        # get the correct module format template
        module_format = JS_MODULE_FORMATS[self.js_module_format]

        # generate the module code
        return module_format(self.dependencies, template_function)
1137295
def build_map(function: Callable[[Any], Any] = None,
              unpack: bool = False):
    
    def _build_map(function: Callable[[Any], Any]):
        @wraps(function)
        def _wrapper(*args, **kwargs) -> Map:
            if 'unpack' in kwargs:
                raise TypeError('"unpack" has to be defined by decorator')
            return Map(function, *args, unpack=unpack, **kwargs)
        return _wrapper

    if function:
        return _build_map(function)

    return _build_map
561012
def build_call(func, *args, **kwargs):
    

    func = get_wrapped_func(func)
    named, vargs, _, defs, kwonly, kwonlydefs, _ = getfullargspec(func)

    nonce = object()
    actual = dict((name, nonce) for name in named)

    defs = defs or ()
    kwonlydefs = kwonlydefs or {}

    actual.update(kwonlydefs)
    actual.update(dict(zip(reversed(named), reversed(defs))))
    actual.update(dict(zip(named, args)))

    if vargs:
        actual[vargs] = tuple(args[len(named):])

    actual.update(kwargs)

    for name, value in actual.items():
        if value is nonce:
            raise TypeError("%s missing required positional argument: '%s'" % (func.__name__, name))

    return tuple_of_dict(actual)
645685
def _init_methods(self):
        
        for name_group in self._METHOD_GROUPS:
            functions = getattr(self, name_group, ())
            uniques = {}
            for func in functions:
                name_func = func.__name__
                method = types.MethodType(func, self)
                setattr(self, name_func, method)
                shortname = '_'.join(name_func.split('_')[:-1])
                if shortname in uniques:
                    uniques[shortname] = None
                else:
                    uniques[shortname] = method
            for (shortname, method) in uniques.items():
                if method is not None:
                    setattr(self, shortname, method)
1031970
def string(self, *pattern, **kwargs):
        
        self.pattern(self.build_string(*pattern, **kwargs))
        return self
1368610
def _get_method_doc(self):
        
        ret = {}
        for method_name in self.methods:
            method = getattr(self, method_name, None)
            if method:
                ret[method_name] = method.__doc__
        return ret
247509
def create_method(self):
        
        n_indents = 0 if self.target_language in ['c', 'go'] else 1
        method_type = 'separated.{}.method'.format(self.prefix)
        method_temp = self.temp(method_type, n_indents=n_indents,
                                skipping=True)
        return method_temp.format(**self.__dict__)
1260933
def create_method(self, func):
    """"""
    # pylint: disable=missing-docstring
    @functools.wraps(func)
    def method(input_layer, *args, **kwargs):
      return func(input_layer, *args, **self.fill_kwargs(input_layer, kwargs))

    return method
254881
def GetMethodConfig(self, method):
        """"""
        method_config = self._method_configs.get(method)
        if method_config:
            return method_config
        func = getattr(self, method, None)
        if func is None:
            raise KeyError(method)
        method_config = getattr(func, 'method_config', None)
        if method_config is None:
            raise KeyError(method)
        self._method_configs[method] = config = method_config()
        return config