8.2.8.19.39. __dict__ΒΆ

MapDispatch.__dict__ = mappingproxy({'__module__': 'schedula.utils.dsp', '__doc__': "\n    It dynamically builds a :class:`~schedula.dispatcher.Dispatcher` that is\n    used to invoke recursivelly a *dispatching function* that is defined\n    by a constructor function that takes a `dsp` base model as input.\n\n    The created function takes a list of dictionaries as input that are used to\n    invoke the mapping function and returns a list of outputs.\n\n    :return:\n        A function that executes the dispatch of the given\n        :class:`~schedula.dispatcher.Dispatcher`.\n    :rtype: callable\n\n    .. seealso:: :func:`~schedula.utils.dsp.SubDispatch`\n\n    Example:\n\n    A simple example on how to use the :func:`~schedula.utils.dsp.MapDispatch`:\n\n    .. dispatcher:: map_func\n       :opt: graph_attr={'ratio': '1'}, depth=-1, workflow=True\n       :code:\n\n        >>> from schedula import Dispatcher, MapDispatch\n        >>> dsp = Dispatcher(name='model')\n        ...\n        >>> def fun(a, b):\n        ...     return a + b, a - b\n        ...\n        >>> dsp.add_func(fun, ['c', 'd'], inputs_kwargs=True)\n        'fun'\n        >>> map_func = MapDispatch(dsp, constructor_kwargs={\n        ...     'outputs': ['c', 'd'], 'output_type': 'list'\n        ... })\n        >>> map_func([{'a': 1, 'b': 2}, {'a': 2, 'b': 2}, {'a': 3, 'b': 2}])\n        [[3, -1], [4, 0], [5, 1]]\n\n    The execution model is created dynamically according to the length of the\n    provided inputs. Moreover, the :func:`~schedula.utils.dsp.MapDispatch` has\n    the possibility to define default values, that are recursively merged with\n    the input provided to the *dispatching function* as follow:\n\n    .. dispatcher:: map_func\n       :opt: graph_attr={'ratio': '1'}, depth=-1, workflow=True\n       :code:\n\n        >>> map_func([{'a': 1}, {'a': 3, 'b': 3}], defaults={'b': 2})\n        [[3, -1], [6, 0]]\n\n    The :func:`~schedula.utils.dsp.MapDispatch` can also be used as a partial\n    reducing function, i.e., part of the outpus of the previous step are used as\n    input for the successive execution of the *dispatching function*. For\n    example:\n\n    .. dispatcher:: map_func\n       :opt: graph_attr={'ratio': '1'}, depth=-1, workflow=True\n       :code:\n\n        >>> map_func = MapDispatch(dsp, recursive_inputs={'c': 'b'})\n        >>> map_func([{'a': 1, 'b': 1}, {'a': 2}, {'a': 3}])\n        [Solution({'a': 1, 'b': 1, 'c': 2, 'd': 0}),\n         Solution({'a': 2, 'b': 2, 'c': 4, 'd': 0}),\n         Solution({'a': 3, 'b': 4, 'c': 7, 'd': -1})]\n    ", '__init__': <function MapDispatch.__init__>, 'prepare_inputs': <staticmethod(<function MapDispatch.prepare_inputs>)>, 'recursive_data': <staticmethod(<function MapDispatch.recursive_data>)>, 'format_labels': <staticmethod(<function MapDispatch.format_labels>)>, 'format_clusters': <staticmethod(<function MapDispatch.format_clusters>)>, '_init_dsp': <function MapDispatch._init_dsp>, '__call__': <function MapDispatch.__call__>, '__annotations__': {}})