Turn a FrameFunction into an Animation.

    Args:
        frame_function: A function that returns a FrameGenerator.

    Returns:
        an Animation decorator function.
165519
def animation(frame_function: types.FrameFunction) -> types.Animation:
    
    animation_ = core.Animation(frame_function)

    @functools.wraps(frame_function)
    def wrapper(*args, **kwargs):
        return animation_(*args, **kwargs)

    return wrapper
348633
def decorator(self, func):
        
        if inspect.isfunction(func):
            func._methodview = self
        elif inspect.ismethod(func):
            func.__func__._methodview = self
        else:
            raise AssertionError('Can only decorate function and methods, {} given'.format(func))
        return func
946682
def thread(function):
    
    @wraps(function)
    def wrapper(*args, **kwargs):
        future = Future()

        launch_thread(_function_handler, function, args, kwargs, future)

        return future

    return wrapper
1170204
def wrap_function(self, func):
        

        def f(*args, **kwds):
            self.enable_by_count()
            try:
                result = func(*args, **kwds)
            finally:
                self.disable_by_count()
            return result
        return f
636863
def _make_function(instr, queue, stack, body, context):
    
    assert stack, "Empty stack before MAKE_FUNCTION."
    prev = stack[-1]
    expect(prev, instrs.LOAD_CONST, "before MAKE_FUNCTION")

    stack.append(instr)

    if is_lambda_name(prev.arg):
        return

    return context.update(
        make_function_context=MakeFunctionContext(
            closure=isinstance(instr, instrs.MAKE_CLOSURE),
        )
    )
1299024
def scalarize(function):
    
    def decorated(self, X, *args, **kwargs):
        scalar = not isinstance(X, np.ndarray)

        if scalar:
            X = np.array([X])

        result = function(self, X, *args, **kwargs)
        if scalar:
            result = result[0]

        return result

    decorated.__doc__ = function.__doc__
    return decorated
114937
def auto_update(cls, function):
        

        def wrapper(self, *args, **kwargs):
            f = function(self, *args, **kwargs)
            self.update()
            return f
        return wrapper
648566
function Animation(duration, timingFunction, frames) {
    var defer;

    var frameQueue = getFrameQueue(duration, frames);
    var framePercent = 1 / (duration / INTERVAL);
    var frameIndex = 0;

    var bezier = getBezier(timingFunction);

    if (!bezier) {
        throw new Error('unexcept timing function');
    }

    var currentFrame;

    var isPlaying = false;
    /**
     * 播放动画
     * @method play
     * @return {lib.animation~Animation} this 当前实例
     * @instance
     * @memberOf lib.animation~Animation
     */
    this.play = function() {
        if (isPlaying) return;
        isPlaying = true;

        if (!defer) {
            defer = PromiseDefer();
            PromiseMixin(defer.promise, this);
        }

        function request() {
            var percent = framePercent * (frameIndex + 1).toFixed(10);
            var currentFrame = frameQueue[frameIndex];

            currentFrame
                .request(percent.toFixed(10), timingFunction(percent).toFixed(10))
                .then(function() {
                    if (!isPlaying) return;

                    if (frameIndex === frameQueue.length - 1) {
                        isPlaying = false;
                        defer && defer.resolve('FINISH');
                        defer = null;
                    } else {
                        frameIndex++;
                        request();
                    }
                }, function() {
                    // CANCEL
                });
        }

        request();
        return this;
    }

    /**
     * 暂停动画
     * @method stop
     * @return {lib.animation~Animation} this 当前实例
     * @instance 
     * @memberOf lib.animation~Animation
     */
    this.stop = function() {
        if (!isPlaying) return;
        isPlaying = false;

        if (frameQueue[frameIndex]) {
            frameQueue[frameIndex].cancel();
        }

        return this;
    }
}
940495
function frame(frameTime) {
		// Steal the current execution queue, and switch it with
		// a new one so that calls from handlers will be queued.
		var handlers = nextBatch; nextBatch = {};
		// Calculate time since last frame.
		var elapsed = frameTime - lastFrameTime;
		// We are taking care of this frame, so allow another
		// frame to be requested from inside the handlers.
		pendingFrame = false;
		// Replay each call with its own context and arguments.
		for (var k in handlers) {
			handlers[k](elapsed);
		}
		// Keep track of updated frame time.
		lastFrameTime = frameTime;
	}
976870
def add_function(self, func):
        
        for block in func.blocks:
            self.add_obj(block.addr, block)
955324
def from_frame_summary(cls, f):
        
        return cls(filename=f.filename, lineno=f.lineno, name=f.name, f_locals=f.locals)
858494
function scheduleFrame(context, method) {
	method = context[method];

	return requestAnimationFrame(method.bind(context));
}
1281226
def settings_view_decorator(function):
    

    dec = settings.CLOUD_BROWSER_VIEW_DECORATOR

    # Trade-up string to real decorator.
    if isinstance(dec, str):
        # Split into module and decorator strings.
        mod_str, _, dec_str = dec.rpartition('.')
        if not (mod_str and dec_str):
            raise ImportError("Unable to import module: %s" % mod_str)

        # Import and try to get decorator function.
        mod = import_module(mod_str)
        if not hasattr(mod, dec_str):
            raise ImportError("Unable to import decorator: %s" % dec)

        dec = getattr(mod, dec_str)

    if dec and callable(dec):
        return dec(function)

    return function
106777
def decorator(caller, _func=None):
    """"""
    if _func is not None:  # return a decorated function
        # this is obsolete behavior; you should use decorate instead
        return decorate(_func, caller)
    # else return a decorator function
    if inspect.isclass(caller):
        name = caller.__name__.lower()
        doc = 'decorator(%s) converts functions/generators into ' \
              'factories of %s objects' % (caller.__name__, caller.__name__)
    elif inspect.isfunction(caller):
        if caller.__name__ == '<lambda>':
            name = '_lambda_'
        else:
            name = caller.__name__
        doc = caller.__doc__
    else:  # assume caller is an object with a __call__ method
        name = caller.__class__.__name__.lower()
        doc = caller.__call__.__doc__
    evaldict = dict(_call_=caller, _decorate_=decorate)
    return FunctionMaker.create(
        '%s(func)' % name, 'return _decorate_(func, _call_)',
        evaldict, doc=doc, module=caller.__module__,
        __wrapped__=caller)
1026561
def transform(function):
        
        def transform_fn(_, result):
            if isinstance(result, Nothing):
                return result

            lgr.debug("Transforming %r with %r", result, function)
            try:
                return function(result)
            except:
                exctype, value, tb = sys.exc_info()
                try:
                    new_exc = StyleFunctionError(function, exctype, value)
                    # Remove the "During handling ..." since we're
                    # reraising with the traceback.
                    new_exc.__cause__ = None
                    six.reraise(StyleFunctionError, new_exc, tb)
                finally:
                    # Remove circular reference.
                    # https://docs.python.org/2/library/sys.html#sys.exc_info
                    del tb
        return transform_fn
1031346
def getFrameTiming(self, unFramesAgo):
        

        fn = self.function_table.getFrameTiming
        pTiming = Compositor_FrameTiming()
        result = fn(byref(pTiming), unFramesAgo)
        return result, pTiming
312448
def _trace(self, frame, event, arg):
        

        # Return if this is not a function call
        if event != 'call':
            return

        # Filter calling and called functions by module names
        src_mod = current_module_name(frame.f_back)
        dst_mod = current_module_name(frame)

        # Avoid tracing the tracer (specifically, call from
        # ContextCallTracer.__exit__ to CallTracer.stop)
        if src_mod == __modulename__ or dst_mod == __modulename__:
            return

        # Apply source and destination module filters
        if not self.srcmodflt.match(src_mod):
            return
        if not self.dstmodflt.match(dst_mod):
            return

        # Get calling and called functions
        src_func = current_function(frame.f_back)
        dst_func = current_function(frame)

        # Filter calling and called functions by qnames
        if not self.srcqnmflt.match(function_qname(src_func)):
            return
        if not self.dstqnmflt.match(function_qname(dst_func)):
            return

        # Get calling and called function full names
        src_name = function_fqname(src_func)
        dst_name = function_fqname(dst_func)

        # Modify full function names if necessary
        if self.fnmsub is not None:
            src_name = re.sub(self.fnmsub[0], self.fnmsub[1], src_name)
            dst_name = re.sub(self.fnmsub[0], self.fnmsub[1], dst_name)

        # Update calling function count
        if src_func is not None:
            if src_name in self.fncts:
                self.fncts[src_name][0] += 1
            else:
                self.fncts[src_name] = [1, 0]

        # Update called function count
        if dst_func is not None and src_func is not None:
            if dst_name in self.fncts:
                self.fncts[dst_name][1] += 1
            else:
                self.fncts[dst_name] = [0, 1]

        # Update caller/calling pair count
        if dst_func is not None and src_func is not None:
            key = (src_name, dst_name)
            if key in self.calls:
                self.calls[key] += 1
            else:
                self.calls[key] = 1