parameters: (dispatcher, module=None, verify=True,
                              docs_from_dispatcher=False)
return_statement: return decorator
docstring: Decorator for adding dispatch with the __array_function__ protocol.
  
      See NEP-18 for example usage.
  
      Parameters
      ----------
      dispatcher : callable
          Function that when called like ``dispatcher(*args, **kwargs)`` with
          arguments from the NumPy function call returns an iterable of
          array-like arguments to check for ``__array_function__``.
      module : str, optional
          __module__ attribute to set on new function, e.g., ``module='numpy'``.
          By default, module is copied from the decorated function.
      verify : bool, optional
          If True, verify the that the signature of the dispatcher and decorated
          function signatures match exactly: all required and optional arguments
          should appear in order with the same names, but the default values for
          all optional arguments should be ``None``. Only disable verification
          if the dispatcher's signature needs to deviate for some particular
          reason, e.g., because the function has a signature like
          ``func(*args, **kwargs)``.
      docs_from_dispatcher : bool, optional
          If True, copy docs from the dispatcher function onto the dispatched
          function, rather than from the implementation. This is useful for
          functions defined in C, which otherwise don't have docstrings.
  
      Returns
      -------
      Function suitable for decorating the implementation of a NumPy function.
docstring_summary: Decorator for adding dispatch with the __array_function__ protocol.
docstring_tokens: Decorator for adding dispatch with the __array_function__ protocol .
function: def array_function_dispatch(dispatcher, module=None, verify=True,
                              docs_from_dispatcher=False):
      """Decorator for adding dispatch with the __array_function__ protocol.
  
      See NEP-18 for example usage.
  
      Parameters
      ----------
      dispatcher : callable
          Function that when called like ``dispatcher(*args, **kwargs)`` with
          arguments from the NumPy function call returns an iterable of
          array-like arguments to check for ``__array_function__``.
      module : str, optional
          __module__ attribute to set on new function, e.g., ``module='numpy'``.
          By default, module is copied from the decorated function.
      verify : bool, optional
          If True, verify the that the signature of the dispatcher and decorated
          function signatures match exactly: all required and optional arguments
          should appear in order with the same names, but the default values for
          all optional arguments should be ``None``. Only disable verification
          if the dispatcher's signature needs to deviate for some particular
          reason, e.g., because the function has a signature like
          ``func(*args, **kwargs)``.
      docs_from_dispatcher : bool, optional
          If True, copy docs from the dispatcher function onto the dispatched
          function, rather than from the implementation. This is useful for
          functions defined in C, which otherwise don't have docstrings.
  
      Returns
      -------
      Function suitable for decorating the implementation of a NumPy function.
      """
  
      if not ARRAY_FUNCTION_ENABLED:
          def decorator(implementation):
              if docs_from_dispatcher:
                  add_docstring(implementation, dispatcher.__doc__)
              if module is not None:
                  implementation.__module__ = module
              return implementation
          return decorator
  
      def decorator(implementation):
          if verify:
              verify_matching_signatures(implementation, dispatcher)
  
          if docs_from_dispatcher:
              add_docstring(implementation, dispatcher.__doc__)
  
          # Equivalently, we could define this function directly instead of using
          # exec. This version has the advantage of giving the helper function a
          # more interpettable name. Otherwise, the original function does not
          # show up at all in many cases, e.g., if it's written in C or if the
          # dispatcher gets an invalid keyword argument.
          source = _wrapped_func_source.format(name=implementation.__name__)
  
          source_object = compile(
              source, filename='<__array_function__ internals>', mode='exec')
          scope = {
              'implementation': implementation,
              'dispatcher': dispatcher,
              'functools': functools,
              'implement_array_function': implement_array_function,
          }
          exec(source_object, scope)
  
          public_api = scope[implementation.__name__]
  
          if module is not None:
              public_api.__module__ = module
  
          public_api._implementation = implementation
  
          return public_api
  
      return decorator
function_tokens: def array_function_dispatch ( dispatcher , module = None , verify = True , docs_from_dispatcher = False ) : if not ARRAY_FUNCTION_ENABLED : def decorator ( implementation ) : if docs_from_dispatcher : add_docstring ( implementation , dispatcher . __doc__ ) if module is not None : implementation . __module__ = module return implementation return decorator def decorator ( implementation ) : if verify : verify_matching_signatures ( implementation , dispatcher ) if docs_from_dispatcher : add_docstring ( implementation , dispatcher . __doc__ ) # Equivalently, we could define this function directly instead of using # exec. This version has the advantage of giving the helper function a # more interpettable name. Otherwise, the original function does not # show up at all in many cases, e.g., if it's written in C or if the # dispatcher gets an invalid keyword argument. source = _wrapped_func_source . format ( name = implementation . __name__ ) source_object = compile ( source , filename = '<__array_function__ internals>' , mode = 'exec' ) scope = { 'implementation' : implementation , 'dispatcher' : dispatcher , 'functools' : functools , 'implement_array_function' : implement_array_function , } exec ( source_object , scope ) public_api = scope [ implementation . __name__ ] if module is not None : public_api . __module__ = module public_api . _implementation = implementation return public_api return decorator