o
    Yi                     @   s(   d Z ddlmZ ddlmZ dd ZdS )z
Internal helpers
    )wraps)	signaturec                    s    fdd}|S )a2  
    Decorator to automatically replace xp with the corresponding array module.

    Use like

    import numpy as np

    @get_xp(np)
    def func(x, /, xp, kwarg=None):
        return xp.func(x, kwarg=kwarg)

    Note that xp must be a keyword argument and come after all non-keyword
    arguments.

    c                    s^   t   fdd}t jfddjD d}|jd u r*d j d|_||_|S )Nc                     s    | di|S )Nxp )argskwargs)fr   r   L/tmp/pip-target-1s0edx8b/lib/python/scipy/_lib/array_api_compat/_internal.py	wrapped_f   s   z(get_xp.<locals>.inner.<locals>.wrapped_fc                    s   g | ]}|d kr j | qS r   
parameters).0i)sigr   r	   
<listcomp>    s    z)get_xp.<locals>.inner.<locals>.<listcomp>r   z$Array API compatibility wrapper for zk.

See the corresponding documentation in NumPy/CuPy and/or the array API
specification for more details.

)r   r   replacer   __doc____name____signature__)r   r
   new_sigr   )r   r   r	   inner   s   

zget_xp.<locals>.innerr   )r   r   r   r   r	   get_xp   s   r   N)r   	functoolsr   inspectr   r   r   r   r   r	   <module>   s    