← Back
Editing: overrides.cpython-311.pyc
� ���cr � � � d Z ddlZddlZddlZddlmZmZmZ ddlm Z e eej � dd� � � � � � ZdZd� Z eed � � eed � � ej dd� � Zd � Zd� Z dd�Z dd�ZdS )z;Implementation of __array_function__ overrides from NEP-18.� N)� add_docstring�implement_array_function�_get_implementing_args)� getargspec�!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 �^ � | j �%| j � dt � � | _ | S )Nz${ARRAY_FUNCTION_LIKE})�__doc__�replace�array_function_like_doc)� public_apis �6/usr/lib/python3/dist-packages/numpy/core/overrides.py�set_array_function_like_docr s4 � ���%�'�/�7�7�$�#� � � �� �� 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 � � 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 X 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 c � � � � fd�}|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 r )� __module__)�func�modules �r � decoratorzset_module.<locals>.decoratory s �� ���$�D�O��r � )r$ r% s ` r � set_moduler'