?????????? ????????? - ??????????????? - /usr/lib64/python3.9/site-packages/numpy/core/__pycache__/overrides.cpython-39.pyc
???????
a z[yc� � @ s� d Z ddlZddlZddlZddlmZmZmZ ddlm Z e eej� dd���ZdZdd � Zeed � eed� e�dd �Zdd� Zdd� Zddd�Zddd�ZdS )z;Implementation of __array_function__ overrides from NEP-18.� N)� add_docstring�implement_array_function�_get_implementing_args)� getargspecZ!NUMPY_EXPERIMENTAL_ARRAY_FUNCTION� ar like : 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 C s | j d ur| j �dt�| _ | S )Nz${ARRAY_FUNCTION_LIKE})�__doc__�replace�array_function_like_doc)� public_api� r �:/usr/lib64/python3.9/site-packages/numpy/core/overrides.py�set_array_function_like_doc s �r a� Implement a function with checks for __array_function__ overrides. All arguments are required, and can only be passed by position. Parameters ---------- implementation : function Function that implements the operation on NumPy array without overrides when called like ``implementation(*args, **kwargs)``. public_api : function Function exposed by NumPy's public API originally called like ``public_api(*args, **kwargs)`` on which arguments are now being checked. relevant_args : iterable Iterable of arguments to check for __array_function__ methods. args : tuple Arbitrary positional arguments originally passed into ``public_api``. kwargs : dict Arbitrary keyword arguments originally passed into ``public_api``. Returns ------- Result from calling ``implementation()`` or an ``__array_function__`` method, as appropriate. Raises ------ TypeError : if no implementation is found. 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 defaultsc C s� t t| �� }t t|�� }|j|jksn|j|jksn|j|jksnt|j�t|j�ksn|jdurzt|j�t|j�krztd| ��|jdur�|jdt|j� kr�td��dS )z:Verify that a dispatcher function has the right signature.NzGimplementation and dispatcher for %s have different function signatures�NzBdispatcher functions can only use None for default argument values) r r �argsZvarargs�keywords�bool�defaults�len�RuntimeError)�implementation� dispatcherZimplementation_specZdispatcher_specr r r �verify_matching_signaturesX s. � ������� r c s � fdd�}|S )z�Decorator for overriding __module__ on a function or class. Example usage:: @set_module('numpy') def example(): pass assert example.__module__ == 'numpy' c s � d ur� | _ | S r )� __module__)�func��moduler r � decoratory s zset_module.<locals>.decoratorr )r r r r r � set_modulen s r TFc s. t s� ��fdd�}|S � ���fdd�}|S )a� 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. c s"