관리-도구
편집 파일: overrides.cpython-311.pyc
� �܋f� � �� � d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z m Z mZ e� � Z dZd� Z e ed � � e e d � � ej dd� � Zd � Z dd�Z dd�ZdS )z;Implementation of __array_function__ overrides from NEP-18.� N� )� set_module)� getargspec)� add_docstring�_get_implementing_args�_ArrayFunctionDispatcherar 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 �^ � | j �%| j � dt � � | _ | S )Nz${ARRAY_FUNCTION_LIKE})�__doc__�replace�array_function_like_doc)� public_apis �K/opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/core/overrides.py�set_array_function_like_docr s4 � ���%�'�/�7�7�$�#� � � �� �� 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 defaultsc � � t t | � � � }t t |� � � }|j |j k s{|j |j k sk|j |j k s[t |j � � t |j � � k s1|j �<t |j � � t |j � � k rt d| z � � �|j �/|j dt |j � � z k rt d� � �dS 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 �args�varargs�keywords�bool�defaults�len�RuntimeError)�implementation� dispatcher�implementation_spec�dispatcher_specs r �verify_matching_signaturesr S s" � �!�:�n�#=�#=�>���z�*�5�5�6�O�� �O�$8�8�8��'�?�+B�B�B��(�O�,D�D�D� �%�.� /� /� �/�*� +� +�,� ,� � )� 5� �$�-� .� .� ��)� *� *�+� +�� ;�=K�L� M� M� M� �#�/��#�w��_�5M�1N�1N�'N�N�N�� 9� :� :� :� 0�/�N�Nr TFc � � ���� � ���fd�}|S )ax Decorator 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. c � �� �r]��t | �� � nJ| j }|j |j z dz }|j | }|dk s|j dk rt d| � d�� � ��rt | �j � � t �| � � } t j | � � |� � }���|_ t � |� � |S )N� �liker zX__array_function__ expects `like=` to be the last argument and a keyword-only argument. z does not seem to comply.)r �__code__�co_argcount�co_kwonlyargcount�co_varnamesr r r r � functools�wraps� __module__�ARRAY_FUNCTIONS�add)r �co�last_argr r �docs_from_dispatcher�module�verifys ����r � decoratorz*array_function_dispatch.<locals>.decorator� s �� �� F��%�*�>�:�F�F�F�F� $�,���>�B�,@�@�1�D���>�(�3���v�%�%��)=��)B�)B�&�E�)�E� E� E�F� F� F� � >��.�*�*<�=�=�=�-�j�.�I�I� �4�Y�_�^�4�4�Z�@�@� ���$*�J�!����J�'�'�'��r � )r r/ r0 r. r1 s ```` r �array_function_dispatchr3 i s7 ����� �J� � � � � � � �8 �r c � � ���� �� ��fd�}|S )zDLike array_function_dispatcher, but with function arguments flipped.c �<