Partial

Contents

Partial#

class brainpy.math.Partial(fun, *args, child_objs=None, dyn_vars=None, **keywords)[source]#

A picklable, object-aware partial application of a function.

Partial behaves like functools.partial(): it binds positional and keyword arguments to fun so that the remaining arguments can be supplied later when the instance is called. Unlike functools.partial(), it is a BrainPyObject, so any Variable instances and child BrainPyObject objects used by fun are registered and tracked.

Parameters:

See also

to_object

Transform a Python function into a BrainPyObject.

Examples

>>> import brainpy.math as bm
>>> add = bm.Partial(lambda x, y: x + y, 1)
>>> add(2)
3