8.1.1.47. __dict__ΒΆ

Dispatcher.__dict__ = mappingproxy({'__module__': 'schedula.dispatcher', '__doc__': "\n    It provides a data structure to process a complex system of functions.\n\n    The scope of this data structure is to compute the shortest workflow between\n    input and output data nodes.\n\n    A workflow is a sequence of function calls.\n\n    **------------------------------------------------------------------------**\n\n    **Example**:\n\n    As an example, here is a system of equations:\n\n    :math:`b - a = c`\n\n    :math:`log(c) = d_{from-log}`\n\n    :math:`d = (d_{from-log} + d_{initial-guess}) / 2`\n\n    that will be solved assuming that :math:`a = 0`, :math:`b = 1`, and\n    :math:`d_{initial-guess} = 4`.\n\n    **Steps**\n\n    Create an empty dispatcher::\n\n        >>> dsp = Dispatcher(name='Dispatcher')\n\n    Add data nodes to the dispatcher map::\n\n        >>> dsp.add_data(data_id='a')\n        'a'\n        >>> dsp.add_data(data_id='c')\n        'c'\n\n    Add a data node with a default value to the dispatcher map::\n\n        >>> dsp.add_data(data_id='b', default_value=1)\n        'b'\n\n    Add a function node::\n\n        >>> def diff_function(a, b):\n        ...     return b - a\n        ...\n        >>> dsp.add_function('diff_function', function=diff_function,\n        ...                  inputs=['a', 'b'], outputs=['c'])\n        'diff_function'\n\n    Add a function node with domain::\n\n        >>> from math import log\n        ...\n        >>> def log_domain(x):\n        ...     return x > 0\n        ...\n        >>> dsp.add_function('log', function=log, inputs=['c'], outputs=['d'],\n        ...                  input_domain=log_domain)\n        'log'\n\n    Add a data node with function estimation and callback function.\n\n        - function estimation: estimate one unique output from multiple\n          estimations.\n        - callback function: is invoked after computing the output.\n\n        >>> def average_fun(kwargs):\n        ...     '''\n        ...     Returns the average of node estimations.\n        ...\n        ...     :param kwargs:\n        ...         Node estimations.\n        ...     :type kwargs: dict\n        ...\n        ...     :return:\n        ...         The average of node estimations.\n        ...     :rtype: float\n        ...     '''\n        ...\n        ...     x = kwargs.values()\n        ...     return sum(x) / len(x)\n        ...\n        >>> def callback_fun(x):\n        ...     print('(log(1) + 4) / 2 = %.1f' % x)\n        ...\n        >>> dsp.add_data(data_id='d', default_value=4, wait_inputs=True,\n        ...              function=average_fun, callback=callback_fun)\n        'd'\n\n    .. dispatcher:: dsp\n       :opt: graph_attr={'ratio': '1'}\n\n        >>> dsp\n        <...>\n\n    Dispatch the function calls to achieve the desired output data node `d`:\n\n    .. dispatcher:: outputs\n       :opt: graph_attr={'ratio': '1'}\n       :code:\n\n        >>> outputs = dsp.dispatch(inputs={'a': 0}, outputs=['d'])\n        (log(1) + 4) / 2 = 2.0\n        >>> outputs\n        Solution({'a': 0, 'b': 1, 'c': 1, 'd': 2.0})\n    ", '__getstate__': <function Dispatcher.__getstate__>, '__init__': <function Dispatcher.__init__>, 'copy_structure': <function Dispatcher.copy_structure>, 'add_data': <function Dispatcher.add_data>, 'add_function': <function Dispatcher.add_function>, 'add_func': <function Dispatcher.add_func>, 'add_dispatcher': <function Dispatcher.add_dispatcher>, 'add_from_lists': <function Dispatcher.add_from_lists>, 'set_default_value': <function Dispatcher.set_default_value>, 'get_sub_dsp': <function Dispatcher.get_sub_dsp>, 'get_sub_dsp_from_workflow': <function Dispatcher.get_sub_dsp_from_workflow>, 'data_nodes': <property object>, 'function_nodes': <property object>, 'sub_dsp_nodes': <property object>, 'copy': <function Dispatcher.copy>, 'blue': <function Dispatcher.blue>, 'extend': <function Dispatcher.extend>, 'dispatch': <function Dispatcher.dispatch>, '__call__': <function Dispatcher.__call__>, 'shrink_dsp': <function Dispatcher.shrink_dsp>, '_get_dsp_from_bfs': <function Dispatcher._get_dsp_from_bfs>, '_edge_length': <staticmethod(<function Dispatcher._edge_length>)>, '_get_wait_in': <function Dispatcher._get_wait_in>, '__annotations__': {}})