Param API reference#
Reactive API#
|
Given a function, returns a wrapper function that binds the values of some or all arguments to Parameter values and expresses Param dependencies on those values, so that the function can be invoked whenever the underlying values change and the output will reflect those updated values. |
|
rx allows wrapping objects and then operating on them interactively while recording any operations applied to them. |
These methods and properties are available under the .rx
namespace
of reactive expressions (rx
).
|
__bool__ cannot be implemented so it is provided as a method. |
|
Replacement for the |
|
Replacement for the |
|
Replacement for the |
|
__len__ cannot be implemented so it is provided as a method. |
|
Apply chainable functions. |
|
Returns a new expression that is True while the expression is updating. |
|
Returns a reactive expression that emits the contents of this expression only when the dependencies change. |
|
Returns either x or y depending on the current state of the expression, i.e. replaces a ternary if statement. |
Returns the current state of the reactive expression by evaluating the pipeline. |
|
|
Adds a callable that observes the output of the pipeline. |
Parameterized objects#
Base class for named objects that support Parameters and message formatting. |
|
Acts like a Python function, but with arguments that are Parameters. |
Parameterized helpers#
|
Object representing an event that triggers a Watcher. |
|
Object declaring a callback function to invoke when an Event is triggered on a watched item. |
|
|
Context manager to batch events to provide to Watchers on a parameterized object. |
|
|
Return a dictionary containing all subclasses of the specified parentclass, including the parentclass. |
|
Annotates a function or Parameterized method to express its dependencies. |
|
Context manager that discards any events within its scope triggered on the supplied parameterized object. |
|
Temporarily set parameters on Parameterized object to constant=False to allow editing them. |
|
output allows annotating a method on a Parameterized class to declare that it returns an output of a specific type. |
Appends a transform to extract potential parameter dependencies from an object. |
|
|
Resolves all parameters a dynamic reference depends on. |
|
Resolves the current value of a dynamic reference. |
|
Variant of pprint() designed for generating a (nearly) runnable script. |
Parameters#
An attribute descriptor for declaring parameters. |
|
A String Parameter, with a default value and optional regular expression (regex) matching. |
|
A Bytes Parameter, with a default value and optional regular expression (regex) matching. |
|
Color parameter defined as a hex RGB string with an optional # prefix or (optionally) as a CSS3 color name. |
|
Binary or tristate Boolean Parameter. |
|
An Event Parameter is one whose value is intimately linked to the triggering of events for watchers to consume. |
|
Parameter whose value can be generated dynamically by a callable object. |
|
A numeric Dynamic Parameter, with a default value and optional bounds. |
|
Numeric Parameter required to be an Integer |
|
Numeric Parameter required to be in the range [0.0-1.0]. |
|
A tuple Parameter (e.g. |
|
A numeric tuple Parameter (e.g. |
|
A NumericTuple for an X,Y coordinate. |
|
A numeric range with optional bounds and softbounds. |
|
Date parameter of datetime or date type. |
|
A datetime or date range specified as (start, end). |
|
Parameter specifically allowing dates (not datetimes). |
|
A date range specified as (start_date, end_date). |
|
Parameter whose value is a list of objects, usually of a specified type. |
|
Parameter whose value is a list of callable objects. |
|
Parameter that can be set to a string specifying the path of a file or folder. |
|
Parameter that can be set to a string specifying the path of a file. |
|
Parameter that can be set to a string specifying the path of a folder. |
|
Parameter whose value must be one object from a list of possible objects. |
|
Given a path glob, allows one file to be selected from those matching. |
|
Variant of Selector where the value can be multiple objects from a list of possible objects. |
|
Given a path glob, allows multiple files to be selected from the list of matches. |
|
Parameter allowing selection of either a subclass or an instance of a class or tuple of classes. |
|
Parameter whose value is a dictionary. |
|
Parameter whose value is a numpy array. |
|
Parameter whose value is a pandas Series. |
|
Parameter whose value is a pandas DataFrame. |
|
Parameter holding a value that is a callable object, such as a function. |
|
A user-provided function that can be invoked like a class or object method using (). |
|
A Parameter that is a composite of a set of other attributes of the class. |
Parameter helpers#
|
For each soft bound (upper and lower), if there is a defined bound (not equal to None) and does not exceed the hard bound, then it is returned. |
|
Given a dictionary of Parameter instances, return a corresponding set of copies with the bounds appropriately set. |
|
Given a set of keyword literals, promote to the appropriate parameter type based on some simple heuristics. |
|
Given a set of Parameterized objects, returns a dictionary with the union of all param name,value pairs across them. |
|
A dictionary that returns the attribute of a specified object if that attribute is not present in itself. |
.param
namespace#
These methods and properties are available under the .param
namespace
of Parameterized
classes and instances.
|
Add a new Parameter object into this object's class. |
|
Print msg merged with args as a debugging statement. |
|
Return {parameter_name:parameter.default} for all non-constant Parameters. |
|
|
|
|
|
Force a new value to be generated for the dynamic attribute name, and return it. |
|
Return a list of name,value pairs for all Parameters of this object. |
|
Return the value or value-generating object of the named attribute. |
|
Return the current value of the named attribute without modifying it. |
|
Print msg merged with args as a message at the indicated logging level. |
|
Print msg merged with args as a message. |
|
Given the name of a method, returns a PInfo object for each dependency of this method. |
|
Returns the Parameters of this instance or class |
|
Returns a mapping between any declared outputs and a tuple of the declared Parameter type, the output method, and the index into the output if multiple outputs are returned. |
|
Return the Parameters of this class as the dictionary {name: parameter_object} |
|
Given the name of a method, returns a PInfo object for each dependency of this method. |
|
(Experimental) Pretty printed representation that may be evaluated with eval. |
Print the default values of all cls's Parameters. |
|
Print the values of all this object's Parameters. |
|
|
Returns a schema for the parameters on this Parameterized object. |
|
Set the default value of param_name. |
|
Set time_fn for all Dynamic Parameters of this class or instance object that are currently being dynamically generated. |
|
For each param=value keyword argument, sets the corresponding parameter of this object or class to the given value. |
|
|
|
|
|
Trigger watchers for the given set of parameter names. |
|
Remove the given Watcher object (from watch or watch_values) from this object's list. |
|
For the given dictionary or iterable or set of param=value keyword arguments, sets the corresponding parameter of this object or class to the given value. |
|
Return a dictionary of name,value pairs for the Parameters of this object. |
|
Print msg merged with args as a verbose message. |
|
Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments. |
|
Register the given callback function fn to be invoked for events on the indicated parameters. |
|
Easier-to-use version of watch specific to watching for changes in parameter values. |
Dictionary of instance watchers. |
Logging#
|
|
Temporarily modify param's logging level. |
Serialization#
Classes used to support string serialization of Parameters and Parameterized objects.
- param.serializer.JSONNullable(json_type)[source]#
Express a JSON schema type as nullable to easily support Parameters that allow_None
- class param.serializer.JSONSerialization[source]#
Class responsible for specifying JSON serialization, deserialization and JSON schemas for Parameters and Parameterized classes and objects.
- classmethod declare_numeric_bounds(schema, bounds, inclusive_bounds)[source]#
Given an applicable numeric schema, augment with bounds information
- classmethod deserialize_parameter_value(pobj, pname, value)[source]#
Deserialize a single parameter value.
- classmethod deserialize_parameters(pobj, serialization, subset=None)[source]#
Deserialize a serialized object representing one or more Parameters into a dictionary of parameter values.
- json_schema_literal_types = {<class 'int'>: 'integer', <class 'float'>: 'number', <class 'str'>: 'string', <class 'NoneType'>: 'null'}#
- classmethod serialize_parameters(pobj, subset=None)[source]#
Serialize the parameters on a Parameterized object into a single serialized object, e.g. a JSON string.
- unserializable_parameter_types = ['Callable']#
- class param.serializer.Serialization[source]#
Base class used to implement different types of serialization.
- classmethod deserialize_parameter_value(pobj, pname, value)[source]#
Deserialize a single parameter value.