8.2.4.4.35. __doc__ΒΆ

BlueDispatcher.__doc__ = "\n    Blueprint object is a blueprint of how to construct or extend a Dispatcher.\n\n    **------------------------------------------------------------------------**\n\n    **Example**:\n\n    Create a BlueDispatcher::\n    \n        >>> import schedula as sh\n        >>> blue = sh.BlueDispatcher(name='Dispatcher')\n\n    Add data/function/dispatcher nodes to the dispatcher map as usual::\n    \n        >>> blue.add_data(data_id='a', default_value=3)\n        <schedula.utils.blue.BlueDispatcher object at ...>\n        >>> @sh.add_function(blue, True, True, outputs=['c'])\n        ... def diff_function(a, b=2):\n        ...     return b - a\n        ...\n        >>> blue.add_function(function=max, inputs=['c', 'd'], outputs=['e'])\n        <schedula.utils.blue.BlueDispatcher object at ...>\n        >>> from math import log\n        >>> sub_blue = sh.BlueDispatcher(name='Sub-Dispatcher')\n        >>> sub_blue.add_data(data_id='a', default_value=2).add_function(\n        ...    function=log, inputs=['a'], outputs=['b']\n        ... )\n        <schedula.utils.blue.BlueDispatcher object at ...>\n        >>> blue.add_dispatcher(sub_blue, ('a',), {'b': 'f'})\n        <schedula.utils.blue.BlueDispatcher object at ...>\n\n    You can set the default values as usual::\n\n        >>> blue.set_default_value(data_id='c', value=1, initial_dist=6)\n        <schedula.utils.blue.BlueDispatcher object at ...>\n\n    You can also create a `Blueprint` out of `SubDispatchFunction` and add it to\n    the `Dispatcher` as follow::\n    \n        >>> func = sh.SubDispatchFunction(sub_blue, 'func', ['a'], ['b'])\n        >>> blue.add_from_lists(fun_list=[\n        ...    dict(function=func, inputs=['a'], outputs=['d']),\n        ...    dict(function=func, inputs=['c'], outputs=['g']),\n        ... ])\n        <schedula.utils.blue.BlueDispatcher object at ...>\n\n    Finally you can create the dispatcher object using the method `new`:\n    \n    .. dispatcher:: dsp\n       :opt: graph_attr={'ratio': '1'}\n       :code:\n\n        >>> dsp = blue.register(memo={}); dsp\n        <schedula.dispatcher.Dispatcher object at ...>\n\n    Or dispatch, calling the Blueprint object:\n\n    .. dispatcher:: sol\n       :opt: graph_attr={'ratio': '1'}\n       :code:\n\n        >>> sol = blue({'a': 1}); sol\n        Solution({'a': 1, 'b': 2, 'c': 1, 'd': 0.0,\n                  'f': 0.0, 'e': 1, 'g': 0.0})\n    "