
    riw                        U d Z ddlZddlZddlmZ ddlmZ ddlmZm	Z	 ddl
ZddlmZ ddlmZ ddlmc mc m
Z ddlmZmZ ddlmZ eZe	ed	<   eej4                  z  Ze	ed
<   ej6                  j9                  dd      Zeez  ed<   ej6                  j9                  dd      Z  G d dejB                        Z" ed      de#de"fd       Z$dedefdZ%y)z|
Override functions from array_api_compat, for use by array-api-extra
and internally.

See also _array_api_compat_vendor.py
    N)	lru_cache)
ModuleType)Any	TypeAlias)array_api_compat)is_array_api_objis_jax_array)	SparseABCArray	ArrayLikeSCIPY_ARRAY_APIFSCIPY_DEVICEcpuc                       e Zd ZdZdZdZdZy)_ArrayClsInfor            N)__name__
__module____qualname__skipnumpy
array_likeunknown     \/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/scipy/_lib/_array_api_override.pyr   r       s    DEJGr   r   d   clsreturnc           
      8   t        | t        t        f      rt        j                  S t        | t
              rd}t        |      t        | t        j                  j                        rt        d      t        | t        j                        rt        d      t        | t        j                  t        j                  f      rt        j                  S t        | t        t         t"        t$        t'        d       f      rt        j(                  S t        j*                  S )NzSparse arrays/matrices are not supported by this function. Perhaps one of the `scipy.sparse.linalg` functions would work instead.z8Inputs of type `numpy.ma.MaskedArray` are not supported.z0Inputs of type `numpy.matrix` are not supported.)
issubclasslisttupler   r   r
   
ValueErrornpmaMaskedArray	TypeErrormatrixndarraygenericr   intfloatcomplexbooltyper   r   )r    msgs     r   _validate_array_clsr4   '   s    #u~&''' #y!& o#ruu(()RSS#ryy!JKK#

BJJ/0"""
 #UGT4:>?!!!   r   arraysc                     t         st        S g }g }| D ]<  }t        t        |            }|t        j
                  u r+|t        j                  u ry|j                  j                  dv r|j                  |       g|j                  j                  dk(  rt        |      r|j                  |       t        d|j                  d      |t        j                  u rt        |      r|j                  |       	 t        j                  |      }|j                  j                  dvrt        d|j                  d      |j                  |       ? |st        S t!        j"                  g || S # t        $ r t        d      w xY w)al  Get the array API compatible namespace for the arrays xs.

    Parameters
    ----------
    *arrays : sequence of array_like
        Arrays used to infer the common namespace.

    Returns
    -------
    namespace : module
        Common namespace.

    Notes
    -----
    Wrapper around `array_api_compat.array_namespace`.

    1. Check for the global switch `SCIPY_ARRAY_API`. If disabled, just
       return array_api_compat.numpy namespace and skip all compliance checks.

    2. Check for known-bad array classes.
       The following subclasses are not supported and raise and error:

       - `numpy.ma.MaskedArray`
       - `numpy.matrix`
       - NumPy arrays which do not have a boolean or numerical dtype
       - `scipy.sparse` arrays

    3. Coerce array-likes to NumPy arrays and check their dtype.
       Note that non-scalar array-likes can't be mixed with non-NumPy Array
       API objects; e.g.

       - `array_namespace([1, 2])` returns NumPy namespace;
       - `array_namespace(np.asarray([1, 2], [3, 4])` returns NumPy namespace;
       - `array_namespace(cp.asarray([1, 2], [3, 4])` raises an error.
    iufcbVzAn argument has dtype `z3`; only boolean and numerical dtypes are supported.zCAn argument is neither array API compatible nor coercible by NumPy.)r   	np_compatr4   r2   r   r   r   dtypekindappendr	   r*   r   r   r'   
asanyarrayr   array_namespace)r5   numpy_arrays
api_arraysarrayarr_infos        r   r>   r>   E   s   H LJ '&tE{3}))),,,{{7*##E*!!S(\%-@ !!%("9%++ IS !S T T ...3CE3Je$7e, {{w."9%++ IS !S T T&;'B  ++G\GJGG  7 !6 7 77s   9E22F)&__doc__enumos	functoolsr   typesr   typingr   r   r   r'   numpy.typingnpt
scipy._libr   !scipy._lib.array_api_compat.numpy_libr9   scipy._lib.array_api_compatr   r	   scipy._lib._sparser
   r   __annotations__r   environgetr   strr1   r   Enumr   r2   r4   r>   r   r   r   <module>rU      s     	   !   ' 5 5 F ( y s}},	9 , !jjnn->Ft Fzz~~ne4DII  3!T !m ! !:QHU QHz QHr   