param.Parameter.schema#

Parameter.schema(safe: bool = False, subset: Iterable[str] | None = None, mode: str = 'json') dict[str, Any][source]#

Generate a schema for the parameters of the Parameterized object.

This method returns a schema representation of the object’s parameters, including metadata such as types, default values, and documentation. The schema format is determined by the specified serialization mode.

Parameters:
  • safe (bool, optional) – If True, only includes parameters marked as safe for serialization. Default is False.

  • subset (iterable of str or None, optional) – A list of parameter names to include in the schema. If None, all parameters are included. Default is None.

  • mode (str, optional) – The serialization format to use. Must be one of the available serialization formats registered in _serializers. Default is 'json'.

Returns:

A schema dictionary representing the parameters of the object and their associated metadata.

Return type:

dict[str, Any]

Examples

>>> import param
>>> class MyClass(param.Parameterized):
...     a = param.Number(default=1, bounds=(0, 10), doc="A numeric parameter.")
...     b = param.String(default="hello", doc="A string parameter.")
>>> instance = MyClass()

Get the schema in JSON format:

>>> instance.param.a.schema()
{'type': 'number', 'minimum': 0, 'maximum': 10}