'Create a FuncTickFormatter instance from a Python function. The
function is translated to JavaScript using PyScript. The variable
``tick`` will contain the unformatted tick value and can be expected to
be present in the function namespace at render time.
Example:
.. code-block:: python
code = """
def ticker():
return "{:.0f} + {:.2f}".format(tick, tick % 1)
The python function must have no positional arguments. It\'s
possible to pass Bokeh models (e.g. a ColumnDataSource) as keyword
arguments to the function.'

@classmethod
def from_py_func(cls, func):

    if (not isinstance(func, FunctionType)):
        raise ValueError('CustomJS.from_py_func    needs    function    object.')
    pyscript = import_required('flexx.pyscript', ('To    use    Python    functions    for    CustomJS,    you    need    Flexx    ' + '("conda    install    -c    bokeh    flexx"    or    "pip    install    flexx")'))
    sig = signature(func)
    (all_names, default_values) = get_param_info(sig)
    if ((len(all_names) - len(default_values)) != 0):
        raise ValueError('Function    `func`    may    only    contain    keyword    arguments.')
    if (default_values and (not any([isinstance(value, Model) for value in default_values]))):
        raise ValueError('Default    value    must    be    a    Bokeh    Model.')
    func_kwargs = dict(zip(all_names, default_values))
    code = (pyscript.py2js(func, 'formatter') + ('return    formatter(%s);\n' % ',    '.join(all_names)))
    return cls(code=code, args=func_kwargs)
