File: //lib/python3/dist-packages/numpy/core/__pycache__/overrides.cpython-310.pyc
o
6��a� � @ s� d Z ddlZddlZddlZddlZddlmZmZmZ ddl m
Z
eeej
�dd���ZdZdd � Zeed
� eed� e�dd
�Zdd� Zdd� Ze�d�Z ddd�Z ddd�ZdS )z;Implementation of __array_function__ overrides from NEP-18.� N)�
add_docstring�implement_array_function�_get_implementing_args)�
getargspec�!NUMPY_EXPERIMENTAL_ARRAY_FUNCTION� ah like : array_like
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 �6/usr/lib/python3/dist-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|jks7|j|jks7|j|jks7t|j�t|j�ks7|jdur=t|j�t|j�kr=td| ��|jdurP|jdt|j� krRtd��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_specr r r
�verify_matching_signaturesY 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
� decoratorz s zset_module.<locals>.decoratorr )r r! r r r
�
set_moduleo s r"