5f6b5d3851d0b719f401eafbfc569420405d1ef3,bokeh/models/formatters.py,FuncTickFormatter,from_py_func,#Any#Any#,215
Before Change
"("conda install -c bokeh flexx" or "pip install flexx")")
argspec = inspect.getargspec(func)
if (len(argspec[0]) - len(argspec[3] or [])) != 1:
raise ValueError("Function `func` must have exactly one positional argument, but %d were supplied." % (len(argspec[0]) - len(argspec[3] or [])))
all_args = argspec[0][:]
func_arg = argspec[0].pop(0)
func_kwargs = dict(zip(argspec[0], argspec[3] or []))
// Set the transpiled functions as `formatter` so that we can call it
code = pyscript.py2js(func, "formatter")
// We wrap the transpiled function into an anonymous function with a single
// arg that matches that of func and all args inside `formatter`
wrapped_code = "function (%s) {%sreturn formatter(%s)};" % (func_arg, code, ", ".join(all_args))
return cls(code=wrapped_code, args=func_kwargs)
@classmethod
After Change
argspec = inspect.getargspec(func)
default_names = argspec.args
default_values = argspec.defaults or []
if len(default_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 plot object.")
func_kwargs = dict(zip(default_names, default_values))
// Wrap the code attr in a function named `formatter` and call it
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 9
Instances
Project Name: bokeh/bokeh
Commit Name: 5f6b5d3851d0b719f401eafbfc569420405d1ef3
Time: 2016-08-16
Author: canavandl@gmail.com
File Name: bokeh/models/formatters.py
Class Name: FuncTickFormatter
Method Name: from_py_func
Project Name: elfi-dev/elfi
Commit Name: 08f049c9fc5fc0f3da5a830de72a583007cdec66
Time: 2017-03-31
Author: jarno.lintusaari@aalto.fi
File Name: elfi/methods/methods.py
Class Name: BayesianOptimization
Method Name: __init__
Project Name: bethgelab/foolbox
Commit Name: 91e12bf45cc3246241b32e7e4702f2bf72f3894e
Time: 2018-10-20
Author: jonasrauber@users.noreply.github.com
File Name: foolbox/attacks/spatial.py
Class Name: SpatialAttack
Method Name: __call__