bgdZddlZddlZddlZddlmZddlmZddlm Z m Z m Z e Z dZdZe e d e e d ejd d Zd Z ddZ ddZdS)z;Implementation of __array_function__ overrides from NEP-18.N) set_module) getargspec) add_docstring_get_implementing_args_ArrayFunctionDispatcherarlike : array_like, optional Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as ``like`` supports the ``__array_function__`` protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument.c^|j%|jdt|_|S)Nz${ARRAY_FUNCTION_LIKE})__doc__replacearray_function_like_doc) public_apis K/opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/core/overrides.pyset_array_function_like_docrs4%'/77 $ #   a Class to wrap functions with checks for __array_function__ overrides. All arguments are required, and can only be passed by position. Parameters ---------- dispatcher : function or None The dispatcher function that returns a single sequence-like object of all arguments relevant. It must have the same signature (except the default values) as the actual implementation. If ``None``, this is a ``like=`` dispatcher and the ``_ArrayFunctionDispatcher`` must be called with ``like`` as the first (additional and positional) argument. implementation : function Function that implements the operation on NumPy arrays without overrides. Arguments passed calling the ``_ArrayFunctionDispatcher`` will be forwarded to this (and the ``dispatcher``) as if using ``*args, **kwargs``. Attributes ---------- _implementation : function The original implementation passed in. ar Collect arguments on which to call __array_function__. Parameters ---------- relevant_args : iterable of array-like Iterable of possibly array-like arguments to check for __array_function__ methods. Returns ------- Sequence of arguments with __array_function__ methods, in the order in which they should be called. ArgSpeczargs varargs keywords defaultsctt|}tt|}|j|jks{|j|jksk|j|jks[t |jt |jks1|jz*556O O$888  '?+B B B  (O,D D D %. / / /* + +,, ) 5 $- . . ) * *++;=KLMM M#/  #w_5M1N1N'N N N 9:: :0/ N NrTFcfd}|S)axDecorator for adding dispatch with the __array_function__ protocol. See NEP-18 for example usage. Parameters ---------- dispatcher : callable or None 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__``. If `None`, the first argument is used as the single `like=` argument and not passed on. A function implementing `like=` must call its dispatcher with `like` as the first non-keyword argument. 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. cr]t|nJ|j}|j|jzdz }|j|}|dks |jdkrt d|drt |jt|}tj ||}|_ t ||S)NlikerzX__array_function__ expects `like=` to be the last argument and a keyword-only argument. z does not seem to comply.)r__code__ co_argcountco_kwonlyargcount co_varnamesrrr r functoolswraps __module__ARRAY_FUNCTIONSadd)rcolast_argr rdocs_from_dispatchermoduleverifys r decoratorz*array_function_dispatch..decorators  F%*>:FFFF$,>B,@@1D>(3v%%)=)B)B&E)EEEFFF  > .**< = = =-j.II 4Y_^44Z@@  $*J !J'''r)rr/r0r.r1s```` rarray_function_dispatchr3is7J8 rcfd}|S)zDLike array_function_dispatcher, but with function arguments flipped.c<t|S)N)r0r.)r3)rr.rr/r0s rr1z1array_function_from_dispatcher..decorators97& v!57777EGG Grr2)rr/r0r.r1s```` rarray_function_from_dispatcherr6s>GGGGGGGG r)NNTF)NTT)r collectionsr'os_utilsr_utils._inspectrnumpy.core._multiarray_umathrrrsetr*r r namedtuplerrr3r6r2rrr>s\AA ((((((FFFFFFFFFF#%%=    <     $ !+ ,L M M:::,BF16AAAAJHLr