A decorator that annotates a function to append the version of Spark the function was added.
978238
def since(version):
    
    import re
    indent_p = re.compile(r'\n( +)')

    def deco(f):
        indents = indent_p.findall(f.__doc__)
        indent = ' ' * (min(len(m) for m in indents) if indents else 0)
        f.__doc__ = f.__doc__.rstrip() + "\n\n%s.. versionadded:: %s" % (indent, version)
        return f
    return deco
1018679
def wrap(func, with_func):
  
  """
  func.__name__ = with_func.__name__
  func.__doc__ = with_func.__doc__
  func.__dict__.update(with_func.__dict__)

  return func
235392
def _create_binary_mathfunction(name, doc=""):
    
    def _(col1, col2):
        sc = SparkContext._active_spark_context
        # For legacy reasons, the arguments here can be implicitly converted into floats,
        # if they are not columns or strings.
        if isinstance(col1, Column):
            arg1 = col1._jc
        elif isinstance(col1, basestring):
            arg1 = _create_column_from_name(col1)
        else:
            arg1 = float(col1)

        if isinstance(col2, Column):
            arg2 = col2._jc
        elif isinstance(col2, basestring):
            arg2 = _create_column_from_name(col2)
        else:
            arg2 = float(col2)

        jc = getattr(sc._jvm.functions, name)(arg1, arg2)
        return Column(jc)
    _.__name__ = name
    _.__doc__ = doc
    return _
618646
def registerFunction(self, name, f, returnType=None):
        
        warnings.warn(
            "Deprecated in 2.3.0. Use spark.udf.register instead.",
            DeprecationWarning)
        return self.sparkSession.udf.register(name, f, returnType)
903631
def _gdecorator(generate_func):
        
        def dostuff(self):
            for func in self._pregenerate_functions:
                self.current_params = func(self.current_params)
            res = generate_func(self) # pylint:disable=not-callable
            return self._postgenerate(res)
        return dostuff
376806
def callJavaFunc(sc, func, *args):
    
    args = [_py2java(sc, a) for a in args]
    return _java2py(sc, func(*args))
950502
def decorator(f):
    """"""
    @functools.wraps(f)
    def decoratored_function(*args, **kwargs):
        if args and len(args) == 1:
            return f(*args, **kwargs)

        if args:
            raise TypeError(
                "This decorator only accepts extra keyword arguments.")

        return lambda g: f(g, **kwargs)

    return decoratored_function
1024780
def add_returning_function(self, func_addr):
        

        self._returning_functions.add(func_addr)
        self._updated_functions.add(func_addr)
1204913
def transform(self, func):
        
        if func.__code__.co_argcount == 1:
            oldfunc = func
            func = lambda t, rdd: oldfunc(rdd)
        assert func.__code__.co_argcount == 2, "func should take one or two arguments"
        return TransformedDStream(self, func)
1311919
def ensure_obj(f):
    
    @click.pass_context
    def new_func(ctx, *args, **kwargs):
        if ctx.obj is None:
            ctx.obj = {}
        return ctx.invoke(f, *args, **kwargs)
    return update_wrapper(new_func, f)
468004
def deprecated(func):
    ''''''

    import warnings

    @functools.wraps(func)
    def new_func(*args, **kwargs):
        if is_python_3:
            code = func.__code__
        else:
            code = func.func_code
        warnings.warn_explicit(
            "Call to deprecated function {}.".format(func.__name__),
            category=Warning,
            filename=code.co_filename,
            lineno=code.co_firstlineno + 1
        )
        return func(*args, **kwargs)
    return new_func
979021
def _wrap_define_function(original_function):
    """"""

    def wrapper(*args, **kwargs):
        """Wrapper function that turns old keyword names to new ones."""
        has_old_names = False
        for old_name, new_name in _six.iteritems(_RENAMED_ARGUMENTS):
            if old_name in kwargs:
                has_old_names = True
                value = kwargs.pop(old_name)
                kwargs[new_name] = value
        if has_old_names:
            _logging.warning(
                "Use of the keyword argument names (flag_name, default_value, "
                "docstring) is deprecated, please use (name, default, help) instead."
            )
        return original_function(*args, **kwargs)

    return wrapper
1226894
function decorateFunctions(node) {
    var i;
    var funcNode = getCommentedFunctionNode(node);
    if (!funcNode || !funcNode.jsdoc) {
        return;
    }

    // Pair up the function params with the JSDoc params (if they exist)
    funcNode.node.params.forEach(function(param) {
        for (i = 0; i < funcNode.jsdoc.params.length; i++) {
            if (!funcNode.jsdoc.params[i].type) {
                continue;
            }

            // If default options are set keep the assignment in flow
            if (param.type === 'AssignmentPattern') {
                if (funcNode.jsdoc.params[i].name === param.left.name) {
                    // Remove ? if default value is set
                    var type = funcNode.jsdoc.params[i].type.replace(/^\?/, '');

                    param.update(
                        param.left.source() + ": " + type + ' = ' + param.right.source()
                    );
                }
            } else {
                if (funcNode.jsdoc.params[i].name === param.name) {
                    param.update(
                        param.source() + ": " + funcNode.jsdoc.params[i].type
                    );
                }
            }
        }
    });

    // Pair up the return value if possible
    // we only support 1 return type currently
    var returnDoc = funcNode.jsdoc.returns[0];
    if (returnDoc && returnDoc.type && funcNode.node.body) {
        if (funcNode.node.type === "ArrowFunctionExpression") {
            // we can't just add this to the end as it will then appear AFTER the =>
            // whereas we actually want it BEFORE the =>
            // Sadly, there isn't a nice way to access the bit before the =>. We do
            // however know that the node source is the entire function, and the node
            // body is the stuff between the { }. We can therefore grab the function
            // header portion and find/replace on the fat arrow.
            var funcHeader = funcNode.node.source().replace(funcNode.node.body.source(), "");
            var arrowIndex = funcHeader.lastIndexOf("=>");
            if (arrowIndex === -1) {
                // well this was unexpected...
                return;
            }
            // inject annotation before the arrow
            funcHeader = (
                funcHeader.slice(0, arrowIndex) + ": " + returnDoc.type + " " + funcHeader.slice(arrowIndex)
            );
            // replace the entire function to replace the header portion
            funcNode.node.update(
                funcHeader + funcNode.node.body.source()
            );
        }
        else {
            funcNode.node.body.update(
                ": " + returnDoc.type + " " + funcNode.node.body.source()
            );
        }
    }
}
180970
def updater(f):
    ""
    @functools.wraps(f)
    def wrapped_updater(keys, values):
        result = f(*values)
        return (keys[:len(result)], result)
    return wrapped_updater
807093
def callMLlibFunc(name, *args):
    
    sc = SparkContext.getOrCreate()
    api = getattr(sc._jvm.PythonMLLibAPI(), name)
    return callJavaFunc(sc, api, *args)
1297085
def append_annotation(self, annotation: str, values: Set[str]) -> 'Seeding':
        
        return self._append_seed(SEED_TYPE_ANNOTATION, {
            'annotations': {
                annotation: values,
            }
        })
637293
def _add_version_info(func):
		
		pattern = r'v(?P<source>\d+)_to_(?P<target>\d+)$'
		match = re.match(pattern, func.__name__)
		if not match:
			raise ValueError("migration function name must match " + pattern)
		func.source, func.target = map(int, match.groups())