Dispatcher.add_data(data_id=None, default_value=empty, initial_dist=0.0, wait_inputs=False, wildcard=None, function=None, callback=None, remote_links=None, description=None, filters=None, **kwargs)[source]

Add a single data node to the dispatcher.

  • data_id (str, optional) – Data node id. If None will be assigned automatically (‘unknown<%d>’) not in dmap.
  • default_value (T, optional) – Data node default value. This will be used as input if it is not specified as inputs in the ArciDispatch algorithm.
  • initial_dist (float, int, optional) – Initial distance in the ArciDispatch algorithm when the data node default value is used.
  • wait_inputs (bool, optional) – If True ArciDispatch algorithm stops on the node until it gets all input estimations.
  • wildcard (bool, optional) – If True, when the data node is used as input and target in the ArciDispatch algorithm, the input value will be used as input for the connected functions, but not as output.
  • function (function, optional) – Data node estimation function. This can be any function that takes only one dictionary (key=function node id, value=estimation of data node) as input and return one value that is the estimation of the data node.
  • callback (function, optional) – Callback function to be called after node estimation. This can be any function that takes only one argument that is the data node estimation output. It does not return anything.
  • remote_links (list[[str, Dispatcher]], optional) – List of parent or child dispatcher nodes e.g., [[dsp_id, dsp], ...].
  • description (str, optional) – Data node’s description.
  • filters (list[function], optional) – A list of functions that are invoked after the invocation of the main function.
  • kwargs (keyword arguments, optional) – Set additional node attributes using key=value.

Data node id.

Return type:




Add a data to be estimated or a possible input data node:

>>> dsp.add_data(data_id='a')

Add a data with a default value (i.e., input data node):

>>> dsp.add_data(data_id='b', default_value=1)

Create a data node with function estimation and a default value.

  • function estimation: estimate one unique output from multiple estimations.
  • default value: is a default estimation.
>>> def min_fun(kwargs):
...     '''
...     Returns the minimum value of node estimations.
...     :param kwargs:
...         Node estimations.
...     :type kwargs: dict
...     :return:
...         The minimum value of node estimations.
...     :rtype: float
...     '''
...     return min(kwargs.values())
>>> dsp.add_data(data_id='c', default_value=2, wait_inputs=True,
...              function=min_fun)

Create a data with an unknown id and return the generated id:

>>> dsp.add_data()