
    9i"                        % S r SSKrSSKrSSKrSSKrSSKrSSKJrJrJ	r	  SSKJ
r
  SSKJr  SSKJr  SSKJrJrJr  SSKrSSKJr  SSKJr  SS	KJrJrJrJrJr J!r"J#r$J%r&J'r(J)r*J+r,  SS
K-J.r.  SSK/J0r0  / SQr1\Rd                  Rg                  SS5      r4\5\6-  \7S'   \Rd                  Rg                  SS5      r8\4\8S.r9\r:\\7S'   \:\Rv                  -  r;\\7S'   S\\;   S\	\:   4S jr<S\:S\SS4S jr=S\:S\4S jr>   S(SSSS.S\;S\S\S   S-  S\6S-  S\S-  S \6S!\6S\:4S" jjjr?SS#.S$\:S\S-  S\:4S% jjr@\" S&5      rA\\   \7S''   \
S\S\S(   4S) j5       rBSYS* jrCS+S+S+S+S,.S- jrDS. rES+S+S+S+S/SS0.S1 jrFSSS+S+S+S+S/SS2.S3 jrGS+S+S+S+S/S+SS4.S5 jrHSZS6 jrIS[S7 jrJS8\S\54S9 jrKS$\:S\S\64S: jrLS\S\S-  4S; jrMSSS<SS=.S$\:S>\N\O\N   -  S-  S?\6S@\N\P-  S\S-  S\:4SA jjrQSS#.S$\:S\S-  S\:4SB jjrRSYSC jrSSSD.SE jrTSSSF.SG jrUSYSH\:S\S-  S\:4SI jjrVSJ rWSK rXSL rY\R                  " SSM9 " SN SO5      5       r[     S\SQ jr\SR r]SSPSPSSSSPSPSS+SS.
ST jr^SSU.SV jr_SSU.SW jr`SSU.SX jra0 rbg)]a6  Utility functions to use Python Array API compatible libraries.

For the context about the Array API see:
https://data-apis.org/array-api/latest/purpose_and_scope.html

The SciPy use case of the Array API is described on the following page:
https://data-apis.org/array-api/latest/use_cases.html#use-case-scipy
    N)	GeneratorIterableIterator)contextmanager)
ContextVar)
ModuleType)AnyLiteral	TypeAlias)array_api_compat)is_array_api_objis_lazy_arraysizenumpydeviceis_numpy_namespaceis_cupy_namespaceis_torch_namespaceis_jax_namespaceis_dask_namespaceis_array_api_strict_namespace)issparse)FunctionDoc)_asarrayarray_namespaceassert_almost_equalassert_array_almost_equal
default_xpeager_warnsr   	is_marrayis_array_api_strict
is_complexis_cupyis_jaxis_numpyis_torchSCIPY_ARRAY_APISCIPY_DEVICEscipy_namespace_forxp_assert_closexp_assert_equalxp_assert_lessxp_copy	xp_devicexp_ravelxp_sizexp_unsupported_param_msgxp_vector_normxp_capabilitiesxp_result_type
xp_promoter'   Fr(   cpu)r'   r(   Array	ArrayLikearraysreturnc              #     #    U  GH  nUc  M	  [        U5      (       a  Sn[        U5      e[        U[        R                  R
                  5      (       a  [        S5      e[        U[        R                  5      (       a  [        S5      e[        U[        R                  [        R                  -  5      (       ap  UR                  n[        R                  " U[        R                  5      (       d:  [        R                  " U[        R                  5      (       d  [        SU< S35      e[        U5      (       a  Uv   GM;   [        R                  " U5      nUR                  n[        R                  " U[        R                  5      (       d<  [        R                  " U[        R                  5      (       d  SU< S3n[        U5      eUR                   (       d  GM  Uv   GM     g! [         a    [        S5      ef = f7f)	a  Raise exceptions on known-bad subclasses. Discard 0-dimensional ArrayLikes
and convert 1+-dimensional ArrayLikes to numpy.

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
- Any array-like which is neither array API compatible nor coercible by NumPy
- Any array-like which is coerced by NumPy to an unsupported dtype
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.zAn argument has dtype `z3`; only boolean and numerical dtypes are supported.zCAn argument is neither array API compatible nor coercible by NumPy.z1An argument was coerced to an unsupported dtype `)r   
ValueError
isinstancenpmaMaskedArray	TypeErrormatrixndarraygenericdtype
issubdtypenumberbool_r   
asanyarrayndim)r9   arraymsgrE   messages        U/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/scipy/_lib/_array_api.py_compliance_scipyrO   D   s     = E??)C S/!eRUU..//VWWeRYY''NOOeRZZ"**455KKEMM%33r}}UBHH7U7U"9% CS !T U U E""K7e, KKEMM%33r}}UBHH7U7UGy QG H   (( zzzU 8  7 !6 7 77s%   D>H G'BH 
H 'G==H rK   xpc                 h    UR                  UR                  U 5      5      (       d  Sn[        U5      eg)zCheck for NaNs or Infs.z#array must not contain infs or NaNsN)allisfiniter<   )rK   rP   rL   s      rN   _check_finiterT   |   s.    66"++e$%%3o &    c                      [         S   (       d  [        $ [        [        U 5      5      nU(       a  [        R
                  " U6 $ [        $ )a  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
-----
Thin wrapper around `array_api_compat.array_namespace`.

1. Check for the global switch: SCIPY_ARRAY_API. This can also be accessed
   dynamically through ``_GLOBAL_CONFIG['SCIPY_ARRAY_API']``.
2. `_compliance_scipy` raise exceptions on known-bad subclasses. See
   its definition for more details.

When the global switch is False, it defaults to the `numpy` namespace.
In that case, there is no compliance check. This is a convenience to
ease the adoption. Otherwise, arrays must comply with the new rules.
r'   )_GLOBAL_CONFIG	np_compatlistrO   r   r   )r9   
api_arrayss     rN   r   r      s?    4 +,'/0J //<<rU   )rP   check_finitesubokrE   order)KACFcopyr[   r\   c                   Uc  [        U 5      n[        U5      (       aN  USL a  [        R                  " XXS9n ODU(       a  [        R                  " XUS9n O'[        R
                  " XUS9n O UR                  XUS9n U(       a  [        X5        U $ ! [         a-    [        UR                  S5      5      nUR                  XUS9n  NJf = f)a8  SciPy-specific replacement for `np.asarray` with `order`, `check_finite`, and
`subok`.

Memory layout parameter `order` is not exposed in the Array API standard.
`order` is only enforced if the input array implementation
is NumPy based, otherwise `order` is just silently ignored.

`check_finite` is also not a keyword in the array API standard; included
here for convenience rather than that having to be a separate function
call inside SciPy functions.

`subok` is included to allow this function to preserve the behaviour of
`np.asanyarray` for NumPy based inputs.
T)r]   rE   r\   )r]   rE   )rE   rb      )r   r%   r>   rK   rI   asarrayrA   rT   )rK   rE   r]   rb   rP   r[   r\   
coerced_xps           rN   r   r      s    0 
zU#||4<HHUuJEMM%EBEJJu?E	FJJuJ=E
 e L  	F(A7J&&u&EE	Fs   .B 4C	C	rP   xc                4    Uc  [        U 5      n[        U SUS9$ )z
Copies an array.

Parameters
----------
x : array

xp : array_namespace

Returns
-------
copy : array
    Copied array

Notes
-----
This copy function does not offer all the semantics of `np.copy`, i.e. the
`subok` and `order` keywords are not used.
T)rb   rP   )r   r   rh   rP   s     rN   r-   r-      s"    , 
zQADR((rU   _default_xp_default_xp_ctxvar)NNNc              #      #    [         R                  U 5      n Sv   [         R                  U5        g! [         R                  U5        f = f7f)a  In all ``xp_assert_*`` and ``assert_*`` function calls executed within this
context manager, test by default that the array namespace is
the provided across all arrays, unless one explicitly passes the ``xp=``
parameter or ``check_namespace=False``.

Without this context manager, the default value for `xp` is the namespace
for the desired array (the second parameter of the tests).
N)rl   setreset)rP   tokens     rN   r   r      s<      ""2&E(  '  's   A3 AA

Ac                 v    SSK nSn[        U 5      (       a  [        R                  " 5       $ UR	                  XS9$ )z@pytest.warns context manager, but only if x is not a lazy array.r   NF)match)pytestr   
contextlibnullcontextwarns)rh   warning_typerr   rs   __thread_safe__s        rN   r   r     s7     OQ%%''<<<22rU   Tcheck_namespacecheck_dtypecheck_shapecheck_0dc                   SnUc   [         R                  5       nU(       a  [	        XU5        [        U5      (       a  U(       ay  S[        U 5       S[        U5       3nUR                  U 5      (       a  UR                  U5      (       d3  UR                  U 5      (       d  UR                  U5      (       a   U5       eUR                  U 5      n UR                  U5      nU(       a=  SU R                   SUR                   3nU R                  UR                  :X  d   U5       eU(       am  [        U5      (       a   U R                  5         UR                  5         SU R                   SUR                   3nU R                  UR                  :X  d   U5       eUR                  XR                  5      nXU4$ ! [         a    [        U5      n GNf = f)NTz$Array-ness does not match:
 Actual: z
 Desired: zdtypes do not match.
Actual: 

Desired: zShapes do not match.
Actual: )rl   getLookupErrorr   _assert_matching_namespacer%   typeisscalarre   rE   is_daskcompute_chunk_sizesshapebroadcast_to)	actualdesiredrP   rz   r{   r|   r}   __tracebackhide___msgs	            rN   _strict_checkr     s    	z	*#'')B "6B7 ||7<.T']O=V$$W)=)=F++BKK4H4H	QLP	Q J ZZFjj!G/~[X||w}},2d2,2;;&&('')/~[X||w}},2d2,oog||4GB;  	* )B	*s   F7 7GGc                     Sn[        U5      nSUR                   SUR                   3nXB:X  d   U5       e[        U 5      nSUR                   SUR                   3nXb:X  d   U5       eg )NTzNamespace of desired array does not match expectations set by the `default_xp` context manager or by the `xp`pytest fixture.
Desired array's space: z
Expected namespace: z=Namespace of actual and desired arrays do not match.
Actual: r   )r   __name__)r   r   rP   r   desired_arr_spacer   actual_arr_spaces          rN   r   r   ;  s    '0& '8&@&@%A B##%;;-	1D
 "(D("&v.'001 2}&D !'4'!rU    )rz   r{   r|   r}   err_msgrP   c          
      $   Sn[        XXrX4US9u  pn[        U5      (       a  UR                  R                  XUS9$ [	        U5      (       a(  US:X  a  S OUnUR                  R                  XSSSSUS9$ [        R                  R                  XUS9$ )NTry   )r   r   r   Frtolatol	equal_nanr{   rL   )r   r#   testingassert_array_equalr&   assert_closer>   )	r   r   rz   r{   r|   r}   r   rP   r   s	            rN   r+   r+   M  s    'FR r{{zz,,Vg,NN	" "R-$Wzz&&vQQRV38g ' G 	G ::(('(JJrU   )r   r   rz   r{   r|   r}   r   rP   c          
         Sn
[        XU	XEXgS9u  pn	U	R                  U R                  S5      nUc3  U(       a,  U	R                  U R                  5      R                  S-  S-  nOUc  Sn[        U	5      (       a  U	R                  R                  XUX8S9$ [        U	5      (       a'  US:X  a  S OUnU	R                  R                  XX#SS	US
9$ [        R                  R                  XUX8S9$ )NTry   real floatingcomplex floating      ?   gHz>)r   r   r   r   Fr   )r   isdtyperE   finfoepsr#   r   assert_allcloser&   r   r>   )r   r   r   r   rz   r{   r|   r}   r   rP   r   floatings               rN   r*   r*   c  s    ''FR zz&,,(MNH| xx%))3.2	r{{zz))&/3 * F 	F	"!R-$Wzz&&vT155g ' W 	W ::%%fD+/ & B BrU   )rz   r{   r|   r}   r   verboserP   c          
      |   Sn	[        XXX4US9u  pn[        U5      (       a  UR                  R                  XXgS9$ [	        U5      (       aT  U R
                  R                  S:w  a  U R                  5       n UR
                  R                  S:w  a  UR                  5       n[        R                  R                  XXgS9$ )NTry   )r   r   r6   )	r   r#   r   assert_array_lessr&   r   r   r6   r>   )
r   r   rz   r{   r|   r}   r   r   rP   r   s
             rN   r,   r,     s    'FR r{{zz++F4; , N 	N	"==&ZZ\F>>%'kkmG::''07 ( J JrU   c                 <    SSSU* -  -  pe[        X/UQ7XeSSS.UD6$ zPBackwards compatible replacement. In new code, use xp_assert_close instead.
    r   g      ?
   F)r   r   r{   r|   r*   r   r   decimalargskwdsr   r   s          rN   r   r     B     CgX&$6 * * $UPU*$(* *rU   c                 <    SSSU* -  -  pe[        X/UQ7XeSSS.UD6$ r   r   r   s          rN   r   r     r   rU   paramc                     SU < S3$ )Nz
Providing z$ is only supported for numpy arrays. )r   s    rN   r1   r1     s    y DEErU   c                 :    UR                  U R                  S5      $ )Nr   )r   rE   rj   s     rN   r"   r"     s    ::agg122rU   c                     [        U 5      (       a  SSKnUR                  $ [        U 5      (       a  SSKnUR                  $ [        U 5      (       a  U $ g)a   Return the `scipy`-like namespace of a non-NumPy backend

That is, return the namespace corresponding with backend `xp` that contains
`scipy` sub-namespaces like `linalg` and `special`. If no such namespace
exists, return ``None``. Useful for dispatching.
r   N)r#   cupyxscipyr$   jaxr&   )rP   r   r   s      rN   r)   r)     sA     r{{{{bzzyy||	rU      )axiskeepdimsordrP   r   r   r   c               6   Uc  [        U 5      OUn[        (       aa  [        US5      (       a  UR                  R	                  XX#S9$ US:w  a  [        S5      eUR                  UR                  U 5      U -  XS9S-  $ [        R                  R                  XXS9$ )Nlinalg)r   r   r   r   zonly the Euclidean norm (`ord=2`) is currently supported in `xp_vector_norm` for backends not implementing the `linalg` extension.)r   r   r   )r   r   r   )
r   r'   hasattrr   vector_normr<   sumconjr>   norm)rh   r   r   r   rP   s        rN   r2   r2     s    
  "z	rB2x  99(((RRax !  66"''!*q.t6GLL yy~~at~GGrU   c               F    Uc  [        U 5      OUnUR                  U S5      $ )N))r   reshaperj   s     rN   r/   r/     s%      "z	rB::arU   c                     Uc  [        U 5      OUn[        [        U R                  5      5      nXB   XA   sXA'   XB'   UR	                  X5      n U $ N)r   rY   rangerJ   permute_dims)aaxis1axis2rP   axess        rN   xp_swapaxesr     sK    !z	rBaffD#{DKDK
 AHrU   )force_floatingc           	         U Vs/ s H+  n[         R                  " U5      (       a  [        USUS9OUPM-     nnU Vs/ s H	  o3c  M  UPM     nnU (       a  UR                  S5        [	        U5      (       aN  UR
                  S:  a>  U Vs/ s H"  n[        USS5      S:X  a  UR                  OUPM$     nnUR                  " U6 $  UR                  " U6 $ s  snf s  snf s  snf ! [         a    U (       d  e / nU Hh  n[         R                  " U5      (       a  UR                  U5      OUn[        USU5      nUR                  US	5      (       d  MW  UR                  U5        Mj     UR                  " / UQ[        U5      P76 s $ f = f)
a  
Returns the dtype that results from applying type promotion rules
(see Array API Standard Type Promotion Rules) to the arguments. Augments
standard `result_type` in a few ways:

- There is a `force_floating` argument that ensures that the result type
  is floating point, even when all args are integer.
- When a TypeError is raised (e.g. due to an unsupported promotion)
  and `force_floating=True`, we define a custom rule: use the result type
  of the default float and any other floats passed. See
  https://github.com/scipy/scipy/pull/22695/files#r1997905891
  for rationale.
- This function accepts array-like iterables, which are immediately converted
  to the namespace's arrays before result type calculation. Consequently, the
  result dtype may be different when an argument is `1.` vs `[1.]`.

Typically, this function will be called shortly after `array_namespace`
on a subset of the arguments passed to `array_namespace`.
Tr\   rP   g      ?z2.0r   r      rE   r   )r>   iterabler   appendr%   __version__getattrrE   result_typerA   r   re   r   xp_default_dtype)r   rP   r   argargs_not_none
float_args	arg_arrayrE   s           rN   r4   r4     sy   *  24S1A1AXc"-sJ 	 $(<DSSDM<S!||. %23$1S '.c61&=&BK$1 	 3~~}--A~~}--<3  A
 
 C+-;;s+;+;

3IIw4Ezz%!FGG!!#&	 !
 ~~@z@+;B+?@@As/   2CCC)CC$ $A)F2FF)	broadcastr   c           
         U Vs/ s H+  n[         R                  " U5      (       a  [        USUS9OUPM-     nn[        X1US.6nU Vs/ s H  nUb  [        XESUS9OUPM     nnU (       d  [	        U5      S:X  a  US   $ [        U5      $ U Vs/ s H	  oDc  M  UPM     nnU Vs1 s H  oDR                  iM     nn [	        U5      S:w  a  [         R                  " U6 OUS   R                  n/ nU H  nUc  UR                  U5        M  UR                  U:w  a)  [        U5      (       a  S	S0O0 nUR                  " XH40 UD6nUR                  U:w  a  UR                  XE5      nUR                  U5        M     [	        U5      S:X  a  US   $ [        U5      $ s  snf s  snf s  snf s  snf ! [         a  n	Sn
[        U
5      U	eSn	A	ff = f)
aw  
Promotes elements of *args to result dtype, ignoring `None`s.
Includes options for forcing promotion to floating point and
broadcasting the arrays, again ignoring `None`s.
Type promotion rules follow `xp_result_type` instead of `xp.result_type`.

Typically, this function will be called shortly after `array_namespace`
on a subset of the arguments passed to `array_namespace`.

This function accepts array-like iterables, which are immediately converted
to the namespace's arrays before result type calculation. Consequently, the
result dtype may be different when an argument is `1.` vs `[1.]`.

See Also
--------
xp_result_type
Tr   )r   rP   N)rE   r\   rP   r   r   z/Array shapes are incompatible for broadcasting.r\   )r>   r   r   r4   lentupler   broadcast_shapesr<   r   r%   r   rE   astype)r   r   rP   r   r   rE   r   shapesr   erM   outkwargss                rN   r5   r5   )  s   &  24S1A1AXc"-sJ 	  DBGE  ?BoXcdr:SVV 	  d)Q,tAw7E$K7$(<DSSDM< $11=Cii=F1)14V1A$$f-#A&,, 	 C;JJsO
 99(0gt_"F//#77C 99))C'C

3! $ Xq[3q60eCj0S
 = 2  )C!q()s5   2FFF"F"$F'<1F, ,
G	6GG	arrc                    Uc  [        U 5      OUnU R                  nUR                  X!R                  5      (       a  UR	                  XR
                  5      n U $ UR                  US5      (       a  UR	                  XR                  5      n U $ )Nr   )r   rE   r   float32r   	complex64
complex128)r   rP   	arr_dtypes      rN   xp_float_to_complexr   g  ss    !#	B		I 
zz)ZZ((ii\\* J 
I	/	/ii]]+JrU   c                 Z    [        U 5      (       a  U R                  5       $ U R                  $ )z@Query the namespace-dependent default floating-point dtype.
    )r&   get_default_dtypefloat64rg   s    rN   r   r   u  s(     ||##%% zzrU   c                  P    U  H   n[        U5      (       d  M  [        U5      s  $    g)zReturn the device of an array in `args`, for the purpose of
input-output device propagation.
If there are multiple devices, return an arbitrary one.
If there are no arrays, return None (this typically happens only on NumPy).
N)r   r.   )r   r   s     rN   xp_result_devicer     s*      C  S>!	 
 rU   c                      SU R                   ;   $ )z=Returns True if `xp` is an MArray namespace; False otherwise.marray)r   rg   s    rN   r    r      s    r{{""rU   )reprc                   r    \ rS rSr% \S-  \S'   \S-  \S'   \R                  " \S9r	\\
   \S'   S rS rS	rg)
_XPSphinxCapabilityi  Nr6   gpu)default_factorywarningsc                     Uc  gU(       d  gU R                   (       a6  SSR                  U R                   5      -   n[        U5      S::  d   S5       eU$ g)Nzn/au   ⛔u   ⚠️ z;    zWarnings too longu   ✅)r   joinr   )selfvalueress      rN   _render_XPSphinxCapability._render  sL    ===dii66Cs8r>6#66>JrU   c                     U R                  U R                  5      nU R                  U R                  5      nUS SUS 3$ )N20z  )r  r6   r   )r  r6   r   s      rN   __str___XPSphinxCapability.__str__  s;    ll488$ll488$bC8$$rU   r   )r   
__module____qualname____firstlineno__bool__annotations__dataclassesfieldrY   r   strr  r	  __static_attributes__r   rU   rN   r   r     s9    		%++DAHd3iA	%rU   r   r   c	                    [        U5      n[        SS S9[        SS S9[        S SS9[        SSS9[        SSU(       a  / OS/S9[        SS U(       a  S/O/ S9S.n	[        U 5      [        U5      -    H3  u  pX   nUR                  b  SUl        UR                  c  M,  SUl        M5     U	R                  5        Hg  u  pU(       a5  XS1-  ;  a,  UR                  b  SUl        UR                  b	  SUl        M?  MA  U(       d  MJ  X;  d  MQ  UR                  c  M`  SUl        Mi     U H$  u  pX   nUR                  R                  U5        M&     U	$ )	NT)r6   r   zno JIT)r6   r   r   zcomputes graph)r   array_api_strictcupytorch	jax.numpy
dask.arrayFr   )rn   r   rY   r6   r   itemsr   r   )skip_backendsxfail_backendscpu_onlynp_only
exceptionsallow_dask_computejax_jitr   reasoncapabilitiesmodule_backendwarnings                 rN   _make_sphinx_capabilitiesr(    sN    ZJ %48/DdC#$7$48(Tt"R
4 *d+=&'2G
L -(4+??	&;;"GK;;"GK @ (--/v7)%;;{{&#{{&# 'X&2w{{7NGK 0 $&( $ rU   c                 v    SU  SUS    SUS    SUS    SUS	    S
US    S3n[         R                  " U5      $ )Nz
    `aG  ` has experimental support for Python Array API Standard compatible
    backends in addition to NumPy. Please consider testing these features
    by setting an environment variable ``SCIPY_ARRAY_API=1`` and providing
    CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following
    combinations of backend and device (or other capability) are supported.

    ====================  ====================  ====================
    Library               CPU                   GPU
    ====================  ====================  ====================
    NumPy                 r   z
    CuPy                  r  z
    PyTorch               r  z
    JAX                   r  z
    Dask                  r  z}
    ====================  ====================  ====================

    See :ref:`dev-arrayapi` for more information.
    )textwrapdedent)fun_namer#  notes      rN   _make_capabilities_noter.    s    Z 	 (0D E'/D E'0D E'4D E'5D ED& ??4  rU   )
capabilities_tabler  r  r  r  r"  r  r   r   r!  c        
         j   ^ ^^ T c  [         OT m [        UUUUUUUU	US9	m[        S0 TD6mUU U4S jn
U
$ )aI  Decorator for a function that states its support among various
Array API compatible backends.

This decorator has two effects:
1. It allows tagging tests with ``@make_xp_test_case`` or
   ``make_xp_pytest_param`` (see below) to automatically generate
   SKIP/XFAIL markers and perform additional backend-specific
   testing, such as extra validation for Dask and JAX;
2. It automatically adds a note to the function's docstring, containing
   a table matching what has been tested.    

See Also
--------
make_xp_test_case
make_xp_pytest_param
array_api_extra.testing.lazy_xp_function
)	r  r  r  r  r"  r  r   r!  r   c                    > TTU '   [        U R                  T5      n[        U 5      nUS   R                  U5        [	        U5      R                  SS5      S   n X l        U $ ! [         a     U $ f = f)NNotes
r   )r.  r   r   r   r  split__doc__AttributeError)fr-  docr#  r/  sphinx_capabilitiess      rN   	decorator"xp_capabilities.<locals>.decorator&  s     !-1&qzz3FG!nGD!#hnnT1%a(	I   	 	s   A# #
A10A1r   )xp_capabilities_tabledictr(  )r/  r  r  r  r  r"  r  r   r   r!  r:  r#  r9  s   `          @@rN   r3   r3     s\    B 4F3M/1  #%-
L 4ClC  rU   r/  c           	      P   U c  [         OU n SS KnSSKJn  / nU GH  nX   nUS   nUS   nUS   (       a)  UR	                  UR
                  R                  SXxS95        US   (       a)  UR	                  UR
                  R                  SXxS	95        US
    H-  u  pUR	                  UR
                  R                  XS95        M/     US    H-  u  pUR	                  UR
                  R                  XS95        M/     S V
s0 s H  n
XU
   _M
     nn
U" U40 UD6  GM     U$ s  sn
f )Nr   )lazy_xp_functionr  r"  r  T)r  r  r"  r  )r  r  r"  r  )r"  r  )r   r!  )r<  rs   "scipy._lib.array_api_extra.testingr@  r   markskip_xp_backendsxfail_xp_backends)r/  funcsrs   r@  marksfuncr#  r  r"  mod_nameklazy_kwargss               rN   _make_xp_pytest_marksrK  9  sO   3E3M/1 CE)/!,/
h'
#LL55* 6 E F	"LL55 6 D E !-_ =HLL55h5NO !> ,-= >HLL66x6OP !? !BC A1 q/) A 	 C--' * L	Cs   D#c                 >   ^ U c  [         OU n  [        USU 06mU4S j$ )Nr/  c                 6   > [         R                  " S TU 5      $ )Nc                     U" U 5      $ r   r   )r7  gs     rN   <lambda>5make_xp_test_case.<locals>.<lambda>.<locals>.<lambda>m  s    adrU   )	functoolsreduce)rG  rF  s    rN   rP  #make_xp_test_case.<locals>.<lambda>m  s    	(():E4HrU   )r<  rK  )r/  rE  rF  s     @rN   make_xp_test_caserU  X  s1    3E3M/1 " "5P=OPEHHrU   c                \    SSK n[        XS9nUR                  " U /UQ7X@R                  S.6$ )a  Variant of ``make_xp_test_case`` that returns a pytest.param for a function,
with all necessary skip_xp_backends and xfail_xp_backends marks applied::

    @pytest.mark.parametrize(
        "func", [make_xp_pytest_param(f1), make_xp_pytest_param(f2)]
    )
    def test(func, xp):
        ...

The above is equivalent to::

    @pytest.mark.parametrize(
        "func", [
            pytest.param(f1, marks=[
                pytest.mark.skip_xp_backends(...),
                pytest.mark.xfail_xp_backends(...), ...]),
            pytest.param(f2, marks=[
                pytest.mark.skip_xp_backends(...),
                pytest.mark.xfail_xp_backends(...), ...]),
    )
    def test(func, xp):
        ...

Parameters
----------
func : Callable
    Function to be tested. It must be decorated with ``@xp_capabilities``.
*args : Any, optional
    Extra pytest parameters for the use case, e.g.::

    @pytest.mark.parametrize("func,verb", [
        make_xp_pytest_param(f1, "hello"),
        make_xp_pytest_param(f2, "world")])
    def test(func, verb, xp):
        # iterates on (func=f1, verb="hello")
        # and (func=f2, verb="world")

See Also
--------
xp_capabilities
make_xp_test_case
array_api_extra.testing.lazy_xp_function
r   Nr>  )rF  id)rs   rK  r   r   )rG  r/  r   rs   rF  s        rN   make_xp_pytest_paramrX  p  s/    X !$NE<<CtC5]]CCrU   r   )   )   )	r   r   FFr   FTr   N)cr5  rt   r  rR  osr*  collections.abcr   r   r   r   contextvarsr   typesr   typingr	   r
   r   r   r>   numpy.typingnpt
scipy._libr   scipy._lib.array_api_compatr   r   r   r0   rX   r   r.   r   r%   r   r#   r   r&   r   r$   r   r   r   r!   scipy._lib._sparser   scipy._lib._docscraper   __all__environr   r'   r  r  r  r(   rW   r7   r8   rO   rT   r   r   r-   rl   r   r   r   r   r+   r*   r,   r   r   r1   r"   r)   intr   floatr2   r/   r   r4   r5   r   r   r   r    	dataclassr   r(  r.  r3   rK  rU  rX  r<  r   rU   rN   <module>rk     s	      	  9 9 % "  * *   '    ( -	 !jjnn->Ft Fzz~~ne4 '  y s}},	9 ,5hy1 5huo 5p J 4 $U $z $R 48 	, !%",,, )*T1, Tk	, , , , 
,^ 26 )u )Z$. )% )8 .8-F Jz* F(: (),<"= ( ( 3 #'Dd%P($ 9=$ $tRDK, .24 $$4B@ 8<#dBQUJ.**FC FC F3% 3Z 3D 3J :+< 0 48$)&'+/	He HuSz)D0H!H eH "D(	H 5:	H4 6:    d!2  e   */ /Ad !&e ;1|U 
T(9 U #
 E"% % #%0 &(.0&*0f!8  RE$2 dAH 6: > 26 I0 :> /Df  rU   