
    e!hV              
       T   d dl Z d dlZd dlZd dlZd dlmZ d dlZd dlm	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mZ 	 d dlmZ dZ	 d dlZdZd
 Zd Z ej>                  dd      d        Z esej>                  d        Z!deiZ"erZ e#ee$      rP	 d dl%Z%e"jM                  de%i        ejN                  e%jP                         ejR                  d      k  r e*d       e%jV                  d       	 d dl,Z,e"jM                  de,i        e,jZ                  e       	 d dl.Z.e"jM                  de.i       	 d dl/Z0e"jM                  de0j                  i       e0jb                  jM                  dd       e0jb                  jM                  d e0jd                  e      d            ejf                         dvr, e jh                  e      Z5de5v rn	 e5D  ci c]  } | e"|    
 c} Z"de"v rdZejt                  jw                  de"jy                               Z=ejt                  j}                  ed !      Z?d" Z@ej>                  d#        ZAej>                  d$        ZBd9d%ZCej                  j                  ej                  j                   ej                         d&             ej                  j                  d'dd(       ej                  j                  d)dddd eKej                        *       ej                  j                  d+d)      ZOej                  j                  eO       ered:d,       ZQeQe_R         eSg d-      e_T        ejP                  d.k  r#ej                  jM                   eSg d/             g d0e_U        d1d1d2d3d4d5e_V         eSd6g      e_W        d7g d8ie_X        de_Y        yy# e$ r d	ZY sw xY w# e$ r d	ZY zw xY w# e*$ r Y w xY w# e*$ r Y w xY w# e*$ r Y w xY w# e*$ r Y Tw xY wc c} w # e6$ r de"jo                          Z8 e9e8      w xY w);    N)contextmanager)get_fpu_mode)FPUModeChangeWarning)SCIPY_ARRAY_APISCIPY_DEVICE)_pep440)	dt_configTFc                    | j                  dd       | j                  dd       | j                  dd       	 dd l}	 ddlm} | j                  dd	       | j                  dd
       t
        s7| j                  dd       | j                  dd       | j                  dd       y y # t        $ r | j                  dd       Y w xY w# t        $ r | j                  dd       Y w xY w)Nmarkerszslow: Tests that are very slow.zHxslow: mark test as extremely slow (not run unless explicitly requested)z8xfail_on_32bit: mark test as failing on 32-bit platformsr   z.timeout: mark a test for a non-default timeout)parse_durationz8fail_slow: mark a test for a non-default timeout failurezskip_xp_backends(backends, reason=None, np_only=False, cpu_only=False, exceptions=None): mark the desired skip configuration for the `skip_xp_backends` fixture.zxfail_xp_backends(backends, reason=None, np_only=False, cpu_only=False, exceptions=None): mark the desired xfail configuration for the `xfail_xp_backends` fixture.zOparallel_threads(n): run the given test function in parallel using `n` threads.z8thread_unsafe: mark the test function as single-threadedzCiterations(n): run the given test function `n` times in each thread)addinivalue_linepytest_timeout	Exceptionpytest_fail_slowr   PARALLEL_RUN_AVAILABLE)configr   r   s      V/var/www/html/diagnosisapp-backend/venv/lib/python3.12/site-packages/scipy/conftest.pypytest_configurer      s   
I)+
IRT
IBDIS 	4 I	RS I	TU "!	" 	F	
 	Q	
 "%  IG	II  SQ	SSs"   B% C %CCC$#C$c                 n   | j                  d      }|A	 t        t        j                  j	                  dd            }|st        j                  d       | j                  d      }|Gt        j                  d      j                  dk  r%t        j                  d	|j                  d           t        j                         5 }|j                  t        j                          	 dd
lm} d}|rc	 t        t        j                  d         }t        j*                  d      s1t        j,                         dz  }t/        ||z  d      }	  |d       d d d        y # t
        $ r d}Y *w xY w# t&        $ r d}Y w xY w# t(        $ r Y d d d        y w xY w# t&        $ r Y d d d        y w xY w# 1 sw Y   y xY w)NxslowSCIPY_XSLOW0Fz@very slow test; set environment variable SCIPY_XSLOW=1 to run itxfail_on_32bitr      z&Fails on our 32-bit test platform(s): )threadpool_limitsTPYTEST_XDIST_WORKER_COUNTOMP_NUM_THREADS      blas)user_api)get_closest_markerintosenvironget
ValueErrorpytestskipnpintpitemsizexfailargsnptsuppress_warningsfilter PytestUnraisableExceptionWarningthreadpoolctlr   r   KeyErrorgetenv	cpu_countmax)	itemmarkvsupr   HAS_THREADPOOLCTLxdist_worker_countmax_openmp_threadsthreads_per_workers	            r   pytest_runtest_setupr@   I   s   ""7+D	BJJNN=#67A KK K L""#34DBGGAJ//!3=diil^LM 
			  C

6::;	&7 $
 
%(4O)P%Q"
 99./%'\\^q%8"%();?Q)QST%U"%&86J5   	A	$  	& %	&  ) $ !  = 67 s   )E  F+$E,,F+/E=;F+
FE)(E),E:7F+9E::F+=	FF+FF+	F(F+'F((F++F4function)scopeautousec              #      K   t               }d t               }||k7  r&t        j                  d|dd|ddt        d       yyw)z9
    Check FPU mode was not changed during the test.
    NzFPU mode changed from z#xz to z during the testr   )category
stacklevel)r   warningswarnr   )requestold_modenew_modes      r   check_fpu_moderL   z   sT     
 ~H	~H8.xm4} M! !3	C s   AAc                       y)Nr    rN       r   num_parallel_threadsrP      s    rO   numpyarray_api_strictz2.0z'array-api-strict must be >= version 2.0z2023.12)api_versiontorchcupy	jax.numpyjax_enable_x64jax_default_device)1trueallz!'--array-api-backend' must be in cudaxpzsTest involves masked arrays, object arrays, or other types that are not valid input when `SCIPY_ARRAY_API` is used.reasonc                    | j                   | d   j                  }t        |      dkD  rt        d|       t	        | j
                  j                  | d            }g }i }|D ]  }|j                  j                  d      r%d|d<   |j                  j                  dg       |d<   nP|j                  j                  d      r5|j                  d      s$d|d<   |j                  j                  dg       |d<   t        |j                        dkD  s|j                  d   }|j                  |        |j                  d	i ||j                  i  ||fS )
z%A helper for {skip,xfail}_xp_backends_xp_backendsr   zmultiple backends: np_onlyT
exceptionscpu_onlyr   rN   )keywordsr.   lenr'   listnodeiter_markerskwargsr&   appendupdate)rI   skip_or_xfailargs_r   backendsrj   markerbackends           r   _backends_kwargs_from_requestrr      sG    l;<AAE
5zA~ .ug6777<<,,l-KLMGHF 6==Y' $F9#)==#4#4\2#FF< ]]z*::i(%)z"'-}}'8'8r'J|$ v{{akk!nGOOG$FMM5Wfmm456  VrO   c                 `    d|j                   vryt        |d      \  }}t        | ||d       y)a  skip_xp_backends(backend=None, reason=None, np_only=False, cpu_only=False, exceptions=None)

    Skip a decorated test for the provided backend, or skip a category of backends.

    See ``skip_or_xfail_backends`` docstring for details. Note that, contrary to
    ``skip_or_xfail_backends``, the ``backend`` and ``reason`` arguments are optional
    single strings: this function only skips a single backend at a time.
    To skip multiple backends, provide multiple decorators.
    skip_xp_backendsNr)   rm   re   rr   skip_or_xfail_xp_backendsr]   rI   ro   rj   s       r   rt   rt      s4     !1!114WFSHfb(F&IrO   c                 `    d|j                   vryt        |d      \  }}t        | ||d       y)a  xfail_xp_backends(backend=None, reason=None, np_only=False, cpu_only=False, exceptions=None)

    xfail a decorated test for the provided backend, or xfail a category of backends.

    See ``skip_or_xfail_backends`` docstring for details. Note that, contrary to
    ``skip_or_xfail_backends``, the ``backend`` and ``reason`` arguments are optional
    single strings: this function only xfails a single backend at a time.
    To xfail multiple backends, provide multiple decorators.
    xfail_xp_backendsNr-   ru   rv   rx   s       r   rz   rz     s4     '"2"224WGTHfb(F'JrO   c                    t        t        |      }|j                  dd      }|j                  dd      }|j                  dg       }|j                  d      x}rt        d|d      |r|rd}|r|s|st        d      |rb|j                  d	d
      }t	        |t
              st        |      dkD  rt        d      | j                  dk7  r| j                  |vr	 ||       y|rd}|g n|}t        rt        dk7  r| j                  dk(  rd|vr
 ||       n| j                  dk(  r5d|vr1d| j                  d      j                  j                  vrY ||       nO| j                  dk(  r@d|vr<| j                  d      j                         D ]  }	d|	j                  vs ||        |Ht        |      D ]9  \  }
}| j                  |k(  s||   j                  d	      }|sd| } ||       ; yy)an  
    Skip based on the ``skip_xp_backends`` or ``xfail_xp_backends`` marker.

    See the "Support for the array API standard" docs page for usage examples.

    Parameters
    ----------
    backends : tuple
        Backends to skip/xfail, e.g. ``("array_api_strict", "torch")``.
        These are overriden when ``np_only`` is ``True``, and are not
        necessary to provide for non-CPU backends when ``cpu_only`` is ``True``.
        For a custom reason to apply, you should pass a dict ``{'reason': '...'}``
        to a keyword matching the name of the backend.
    reason : str, optional
        A reason for the skip/xfail in the case of ``np_only=True``.
        If unprovided, a default reason is used. Note that it is not possible
        to specify a custom reason with ``cpu_only``.
    np_only : bool, optional
        When ``True``, the test is skipped/xfailed for all backends other
        than the default NumPy backend. There is no need to provide
        any ``backends`` in this case. To specify a reason, pass a
        value to ``reason``. Default: ``False``.
    cpu_only : bool, optional
        When ``True``, the test is skipped/xfailed on non-CPU devices.
        There is no need to provide any ``backends`` in this case,
        but any ``backends`` will also be skipped on the CPU.
        Default: ``False``.
    exceptions : list, optional
        A list of exceptions for use with ``cpu_only`` or ``np_only``.
        This should be provided when delegation is implemented for some,
        but not all, non-CPU/non-NumPy backends.
    skip_or_xfail : str
        ``'skip'`` to skip, ``'xfail'`` to xfail.
    rb   Frd   rc   reasonsz.provide a single `reason=` kwarg; got reasons=z insteadz<`exceptions` is only valid alongside `cpu_only` or `np_only`r_   z#do not run with non-NumPy backends.r   z8please provide a singleton `reason` when using `np_only`rQ   r^   NzTno array-agnostic implementation or delegation available for this backend and devicecpurU   rT   r   rV   z#do not run with array API backend: )getattrr(   r&   r'   
isinstancestrrf   __name__r   r   emptydevicetypedevicesdevice_kind	enumerate)r]   ro   rj   rm   rb   rd   rc   r|   r_   dirq   s               r   rw   rw     s   F FM2MjjE*Gzz*e,HL"-J**Y''w'J'8TUU 88wWXXH&KL&#&3v;? 4 5 5;;'!bkk&C(0%-R:
|u4{{f$z)AV,'G:,E 2 2 7 77!0+:0M!,,. 5AAMM1%V45 #H- 	-JAw{{g%,,X6B7)LFV,	- rO   z.hypothesisnondeterministic)namedeadline
print_blobdeterministic)r   r   r   databasederandomizesuppress_health_checkSCIPY_HYPOTHESIS_PROFILEc              #   ~  K   t               }ddg}|D ]  }t        t        d      ||<    g d}|D ]  }t        t              ||<    ddlm} d	d
g}|D ]  }t        |j
                  d      ||<    g d}|D ]  }t        t              ||<    t        t        d      t        dt              t        d|j
                        d}|j                  |       t        d      }	ddl
m}
 ddl} |
       5  |j                  j                  d       t        j                          5  | r5| j"                  |v r't        j$                  di || j"                      d n3| r| j"                  |	v rd nt        j&                  dt(               d ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY ww)zmTemporarily turn (almost) all warnings to errors.

        Filter out known warnings which we allow.
        zscipy.linalg.normzscipy.ndimage.center_of_masszdivide by zero)rE   message)zscipy.signal.cwtzscipy.signal.morletzscipy.signal.morlet2zscipy.signal.rickerzscipy.integrate.simpsonzscipy.interpolate.interp2dzscipy.linalg.kron)rE   r   )	integratezscipy.special.ellip_normalzscipy.special.ellip_harm_2zThe occurrence of roundoff)zscipy.stats.anderson_ksampzscipy.stats.kurtosistestzscipy.stats.normaltestscipy.sparse.linalg.normzExited at iterationzthe matrix subclass is not)r   rE   z"The maximum number of subdivisions)r   z
linalg.rstz	stats.rstscipy.signal.normalize)_fixed_default_rngNerror)ignore)dictRuntimeWarningDeprecationWarningscipyr   IntegrationWarningUserWarningPendingDeprecationWarningrl   setscipy._lib._utilr   rQ   randomseedrG   catch_warningsr   filterwarningssimplefilterWarning)testknown_warningsdivide_by_zeror   
deprecatedr   integration_wuser_wdctlegitr   r*   s               r   warnings_errors_and_rngr     s       !?
 # 	BD#'0@$BN4 	B


  	ED#'1C#DN4 	E 	$55
 " 	ND#'1M1M0L$NN4 	N
H 	>D#'#=N4 	> k3HI 979 A'::<

 	c" ,- 	8! 	IINN4 ((* 	DII7++ I.<TYY.GIdii50))'7;		 		 		 	s7   C7F=90F1)A+F%F1	F=%F.	*F11F:6F=)zscipy.linalg.LinAlgErrorzscipy.fftpack.fftshiftzscipy.fftpack.ifftshiftzscipy.fftpack.fftfreqzscipy.special.sinczscipy.optimize.show_optionsr   r   z$scipy.io.matlab.MatlabObject.stridesz"scipy.io.matlab.MatlabObject.dtypez"scipy.io.matlab.MatlabOpaque.dtypez$scipy.io.matlab.MatlabOpaque.stridesz&scipy.io.matlab.MatlabFunction.stridesz$scipy.io.matlab.MatlabFunction.dtype2)zscipy.io.hb_readzscipy.io.hb_writez)scipy.sparse.csgraph.connected_componentsz&scipy.sparse.csgraph.depth_first_orderz"scipy.sparse.csgraph.shortest_pathz#scipy.sparse.csgraph.floyd_warshallzscipy.sparse.csgraph.dijkstraz!scipy.sparse.csgraph.bellman_fordzscipy.sparse.csgraph.johnsonzscipy.sparse.csgraph.yenz(scipy.sparse.csgraph.breadth_first_orderz*scipy.sparse.csgraph.reverse_cuthill_mckeez$scipy.sparse.csgraph.structural_rankz*scipy.sparse.csgraph.construct_dist_matrixz%scipy.sparse.csgraph.reconstruct_pathzscipy.ndimage.value_indiceszscipy.stats.mstats.describe)zscipy.stats.distributionszscipy.optimize.cython_optimizez
scipy.testzscipy.show_configzscipy/special/_precomputez#scipy/interpolate/_interpnd_info.pyzscipy/_lib/array_api_compatzscipy/_lib/highszscipy/_lib/unuranzscipy/_lib/_gcutils.pyzscipy/_lib/doccer.pyzscipy/_lib/_uarrayzReST parser limitationz__cinit__ unexpected argumentznan in scalar_powerzintegration warning)zND_regular_grid.rstzextrapolation_examples.rstzsampling_pinv.rstzsampling_srou.rstzprobability_distributions.rstzintegrate.nquad(func,zio.rst)zoctave_a.matzoctave_cells.matzoctave_struct.mat)r)   )N)Zjsonr$   rG   tempfile
contextlibr   rQ   r*   numpy.testingtestingr/   r(   
hypothesisscipy._lib._fpumoder   scipy._lib._testutilsr   scipy._lib._array_apir   r   
scipy._libr   scipy_doctest.conftestr	   
HAVE_SCPDTModuleNotFoundErrorpytest_run_parallelr   r   r   r@   fixturerL   rP   xp_available_backendsr   r   rR   rl   parse__version__VersionImportErrorset_array_api_strict_flagsrT   set_default_devicerU   	jax.numpyjaxr   r   lowerloadsSCIPY_ARRAY_API_r4   keysmsgr'   r9   parametrizevaluesarray_api_compatibleskipifskip_xp_invalid_argrr   rt   rz   rw   configurationset_hypothesis_home_dirpathjoin
gettempdirsettingsregister_profilerg   HealthCheckr%   r&   r   load_profiler   user_context_mgrr   skiplistpytest_extra_ignorepytest_extra_xfail
pseudocodelocal_resourcesstrict_check)rq   s   0r   <module>r      s    	   %     , 6 ? 0J#!
'
T.b j$/C 0C ^^ 
 !" z/37	$$&8:J%KL7==)5569OOGHH333!	
$$gu%56   .$$fd^4$$k399%=>

*D1

.L0I!0LM
 m3%4::o6$$& $4) 27;;)% 
""L{{..t5J5Q5Q5ST kk((I ) K 
> J J" K K P-l    0 0GGLL$$$&6    $ $	dt %     $ $	dTtz556 %  ::>>*D*9;  
      !9 :  O Ob "9I  I( 
~~!!# ' # 	,%I!$  8&><2)>$I   789I 
!I "II ]  J  #"#B        )  &9:O:T:T:V9WX o%&s   N5 O A!O ;)O %O) =A,O5 P P%P 5O ?O OOOOO&%O&)O21O25O>=O>P !P'