
    Bpj0                        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rSSKrSSKrSSK	J
r
  SSKJrJr  SSKrSSKr SSKrSSKJr  SSKJr  Sr\R.                  " \5      \R0                  " \5      :  a  Sr/ SQrSr\R8                  " S	5      =(       d    S
rS\;   a  SrS\R<                  S   ;   r " S S\ 5      r! " S S5      r" " S S5      r#S r$S r%S r&S r'S r(S r)g! \ a    Sr Nwf = f)z
Generic test utilities.

    N)ThreadPoolExecutor)module_from_specspec_from_file_location)versionz3.2.0)PytestTestercheck_free_memory_TestPythranFuncIS_MUSLFHOST_GNU_TYPE muslTeditablec                       \ rS rSrSrSrg)FPUModeChangeWarning4   zWarning about FPU mode change N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       Q/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/scipy/_lib/_testutils.pyr   r   4   s    'r   r   c                   ,    \ rS rSrSrS r  SS jrSrg)r   9   a  
Run tests for this namespace

``scipy.test()`` runs tests for all of SciPy, with the default settings.
When used from a submodule (e.g., ``scipy.cluster.test()``, only the tests
for that namespace are run.

Parameters
----------
label : {'fast', 'full'}, optional
    Whether to run only the fast tests, or also those marked as slow.
    Default is 'fast'.
verbose : int, optional
    Test output verbosity. Default is 1.
extra_argv : list, optional
    Arguments to pass through to Pytest.
doctests : bool, optional
    Whether to run doctests or not. Default is False.
coverage : bool, optional
    Whether to run tests with code coverage measurements enabled.
    Default is False.
tests : list of str, optional
    List of module names to run tests for. By default, uses the module
    from which the ``test`` function is called.
parallel : int, optional
    Run tests in parallel with pytest-xdist, if number given is larger than
    1. Default is 1.

c                     Xl         g Nmodule_name)selfr    s     r   __init__PytestTester.__init__W   s    &r   Nc                    SS K n[        R                  U R                     n	[        R
                  R                  U	R                  S   5      n
SS/nUc  / nX-  n[        S U 5       5      (       a  [        S5      eU(       a'  [        U5      S:  a  USS[        U5      S-
  -  -   /-  nU(       a	  US	U
-   /-  nUS
:X  a  USS/-  nOUS:w  a  USU/-  nUc  U R                  /nUb:  US:  a4  [        5       (       a  US[        U5      /-  nOSS KnUR                  SSS9  US/[        U5      -   -  n UR!                  U5      nUS:H  $ ! ["         a  nUR$                  n S nAUS:H  $ S nAff = f)Nr   z--showlocalsz
--tb=shortc              3   B   #    U  H  oS :H  =(       d    US:H  v   M     g7f)-mz	--markersNr   ).0args     r   	<genexpr>(PytestTester.__call__.<locals>.<genexpr>f   s     GJSd{0c[00Js   zMust specify -m before --   -vz--cov=fastr&   znot slowfullz-nzMCould not run tests in parallel because pytest-xdist plugin is not available.   )
stacklevelz--pyargs)pytestsysmodulesr    ospathabspath__path__any
ValueErrorint_pytest_has_xdiststrwarningswarnlistmain
SystemExitcode)r!   labelverbose
extra_argvdoctestscoveragetestsparallelr2   modulemodule_pathpytest_argsr>   rC   excs                  r   __call__PytestTester.__call__Z   s   T--.ggoofooa&89%|4J!GJGGG899s7|a'C#s7|A~"6677KH{233KF?D*--Kf_D%=(K=%%&EHqL ""c(m44 F)*  , 	
|d5k11	;;{+D 	  	88D		s   6E 
E0E++E0r   )r.   r+   NFFNN)r   r   r   r   r   r"   rO   r   r   r   r   r   r   9   s    :' KP6:.r   r   c                   *   \ rS rSrSr\R                  \R                  \R                  \R                  \R                  \R                  /r\R                  \R                  /r\R                   \R"                  /rS rS rS rS rS rS rS	 rS
rg)r	      a$  
These are situations that can be tested in our pythran tests:
- A function with multiple array arguments and then
  other positional and keyword arguments.
- A function with array-like keywords (e.g. `def somefunc(x0, x1=None)`.
Note: list/tuple input is not yet tested!

`self.arguments`: A dictionary which key is the index of the argument,
                  value is tuple(array value, all supported dtypes)
`self.partialfunc`: A function used to freeze some non-array argument
                    that of no interests in the original function
c                 .    0 U l         S U l        S U l        g r   )	argumentspartialfuncexpected)r!   s    r   setup_method_TestPythranFunc.setup_method   s    r   c                     [         R                  " U5      n0 nUR                  R                  5        H<  u  pEUR                  [         R
                  R                  Ld  M.  UR                  X4'   M>     U$ r   )inspect	signature
parametersitemsdefault	Parameterempty)r!   funcr[   optional_argskr-   s         r   get_optional_args"_TestPythranFunc.get_optional_args   s`     %%d+	((..0DAyy 1 1 7 77#$99  1 r   c                 x    SnU R                    H'  n[        U R                   U   S   5      nX1:  d  M%  UnM)     U$ )Nr   r+   )rT   len)r!   max_lenarg_idxcur_lens       r   get_max_dtype_list_length*_TestPythranFunc.get_max_dtype_list_length   s?    ~~G$..1!45G ! & r   c                 8    U[        U5      S-
  :  a  US   $ X   $ )Nr+   )rg   )r!   
dtype_list	dtype_idxs      r   	get_dtype_TestPythranFunc.get_dtype   s(     s:q((b>!((r   c                 0   [        U R                  5       5       Hy  n/ nU R                   HU  nU R                  U R                  U   S   U5      nUR	                  U R                  U   S   R                  U5      5        MW     U R                  " U6   M{     g )Nr+   r   )rangerk   rT   rq   appendastypepythranfunc)r!   type_idx
args_arrayri   	new_dtypes        r   test_all_dtypes _TestPythranFunc.test_all_dtypes   s    d<<>?HJ>> NN4>>'+B1+E+35	!!$.."9!"<"C"CI"NO * j) @r   c                     / nU R                    H0  nUR                  U R                   U   S   S S S2   S S S2   5        M2     U R                  " U6   g )Nr   rn   )rT   ru   rw   r!   ry   ri   s      r   
test_views_TestPythranFunc.test_views   sQ    
~~GdnnW5a82>ttDE &*%r   c           	          / nU R                    H>  nUR                  [        R                  " U R                   U   S   SSS9S S S2   5        M@     U R                  " U6   g )Nr   r0   )axis)rT   ru   nprepeatrw   r~   s      r   test_strided_TestPythranFunc.test_strided   s_    
~~Gbiiw(?(B()336Q38 9 & 	*%r   )rT   rV   rU   N)r   r   r   r   r   r   int8int16int32int64intcintpALL_INTEGERfloat32float64	ALL_FLOAT	complex64
complex128ALL_COMPLEXrW   rd   rk   rq   r{   r   r   r   r   r   r   r	   r	      sz     77BHHbhh"''277KKRZZ(I<</K
)*&&r   r	   c                  "    SSK Jn   U " S5      SL$ )zI
Check if the pytest-xdist plugin is installed, providing parallel tests
r   	find_specxdistN)importlib.utilr   r   s    r   r<   r<      s    
 )WT))r   c                 2   SSK n [        [        R                  S   5      nSR	                  U [        R                  S   5      nX S-  :  a  UR                  U5        gg! [
         a,    [        5       nUc  UR                  S5        U  SUS-   S3n NPf = f)	zB
Check *free_mb* of memory is available, otherwise do pytest.skip
r   NSCIPY_AVAILABLE_MEMz={} MB memory required, but environment SCIPY_AVAILABLE_MEM={}zlCould not determine available memory; set SCIPY_AVAILABLE_MEM variable to free memory in MB to run the test.z MB memory required, but     .Az MB available)r2   _parse_sizer5   environformatKeyError_get_mem_availableskip)free_mbr2   mem_freemsgs       r   r   r      s     	Orzz*?@AMTTRZZ 568 C-C    O%'KK I J	28C<.NOs   ?A   3BBc                 r   SSSSSSSSSSSSSS	S
.n[         R                  " SR                  SR                  UR	                  5       5      5      U [         R
                  5      nU(       a  UR                  S5      U;  a  [        S5      e[        UR                  S5      5      XR                  S5         -  $ )Nr   g      ?     @@g    eAg   mBg      @g      0Ag      Ag      pB)r   brc   MGTkbMbGbTbkibMibGibTibz^\s*(\d+)\s*({})\s*$|r0   zInvalid size stringr+   )	rematchr   joinkeysIgroupr:   float)size_strsuffixesms      r   r   r      s    s4Cti	)	UH
 	(//0IJ	A 
(*.//x
333r   c                      SSK n U R                  5       R                  $ ! [        [        4 a     Of = f[
        R                  R                  S5      (       a  0 n[        S5       nU HF  nUR                  5       n[        US   5      S-  XS   R                  S5      R                  5       '   MH     SSS5        O! , (       d  f       O= fSU;   a  US   $ US	   US
   -   $ g)z<
Get information about memory available, not counting swap.
r   Nlinuxz/proc/meminfor+   r   :memavailablememfreecached)psutilvirtual_memory	availableImportErrorAttributeErrorr3   platform
startswithopensplitr   striplower)r   infoflineps        r   r   r      s    $$&000(  ||w''/"aJJL05adc0AqTZZ_**,-  #""
 T!''	?T(^33s     33'AB==
Cc                   ^^	 SSK n [        R                  " SS/5        U [        [        R                  " 5       5      -  n [        R                  R                  U5      S   n[        R                  " XU-  5        X-  S-  S-  nUS	-  m	[        R                  " T	S
S9  [        US-  5      n[        US5       nUR                  S5        UR                  S[         R"                   S35        SSS5        [         R$                  S:X  a&  [        R                  " SSSSUS[        U5      /T	S9  O#[        R                  " SSSU[        U5      /T	S9  [        R                  " / SQT	S9  [&        R(                  " S5      mUU	4S jnU" S5      U" S5      4$ ! [         a    UR	                  S5         GNf = f! , (       d  f       N= f)z
Helper function to test building and importing Cython modules that
make use of the Cython APIs for BLAS, LAPACK, optimize, and special.
r   Nmesonz	--versionzNo usable 'meson' foundr+   rI   _cython_examplesbuildT)exist_okzinterpreter-native-file.iniwz[binaries]
z
python = ''win32setupz--buildtype=releasez--native-filez--vsenv)cwd)r   compilez-vv
EXT_SUFFIXc                    > TU -  R                  T5      n[        X5      n[        U5      nUR                  R	                  U5        U$ r   )with_suffixr   r   loaderexec_module)modnamesospecmodsuffix
target_dirs       r   load$_test_cython_extension.<locals>.loadF  sC    7"//7&w3t$$
r   	extendingextending_cpp)r2   
subprocess
check_callFileNotFoundErrorr   r=   	threading	get_identr5   r6   r   shutilcopytreemakedirsr   writer3   
executabler   	sysconfigget_config_var)
tmp_pathsrcdirr2   mod_name	build_dirnative_filer   r   r   r   s
           @@r   _test_cython_extensionr     s   
 /w45
 #i11344H ww}}V$Q'H
OOFx/0#g-0BBIW$JKK
T* i"??@K	k3	1		*S^^,A./ 
  ||ww4.(#i.: #-		  	w.S^M",	  5:F %%l3F d?333[  /-./  
 	s   F :5F:F76F7:
Gc           	        ^^	 [         R                  " U 5      m	U	U4S jn[        U S9 n / n[        SU 5       H(  nUR	                  UR
                  " XG/UQ70 UD65        M*     [        U5      U :  a  T	R                  5         SSS5        W Vs/ s H  oR                  5       PM     sn$ ! [        W5      U :  a  T	R                  5         f f = f! , (       d  f       NS= fs  snf )af  
Run a given function concurrently across a given number of threads.

This function ensures that the closure passed by parameter gets called
concurrently by setting up a barrier before it gets called before any of the
threads.

Returns a list of values returned by the worker threads.

Arguments
---------
n_workers: int
    Number of concurrent threads to spawn.
fn: callable
    Function closure to execute concurrently. Its first argument will
    be the thread id.
*args: tuple
    Variable number of positional arguments to pass to the function.
**kwargs: dict
    Keyword arguments to pass to the function.

c                 <   > TR                  5         T" U /UQ70 UD6$ r   )wait)iargskwargsbarrierfns      r   closure(_run_concurrent_barrier.<locals>.closurej  s!    !%d%f%%r   )max_workersr   N)	r   Barrierr   rt   ru   submitrg   abortresult)
	n_workersr  r  r  r  tpefuturesr  r   r  s
    `       @r   _run_concurrent_barrierr  Q  s    . 	*G& 
		2c	 G1i(szz'FtFvFG ) 7|i' 
3 !((1HHJ((	 7|i' ( 
3	2 )s(   C:B,%CC","CC
C)*r   rZ   r5   r   r   r   r3   r   r   concurrent.futuresr   r   r   r   numpyr   scipycythonCython.Compiler.Versionr   cython_version!scipy._external.packaging_versionrequired_versionparseVersionr   __all__r
   r   _vr8   IS_EDITABLERuntimeWarningr   r   r	   r<   r   r   r   r   r  r   r   r   <module>r      s  
  	 	   
   1 D   :}}^$w7G'HH O 
 o.4"	R<G ENN1--	> 	
O OdE& E&P**4254p')o	  Fs   
C! !C,+C,