a
    BCCfJ#                     @   sP  d dl Z 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
Z
d dlmZ d dlmZ d dlmZ d dlmZmZ dd Zdd	 Zd
d Ze	jddddd ZdeiZereeerzd dlZedei W n ey   Y n0 z$d dlZedei e e W n ey&   Y n0 zd dl!Z!ede!i W n eyV   Y n0 e" dvre #eZ$de$v r|n>zdd e$D ZW n* e%y   de&  Z'e(e'Y n0 dev rdZe	j)*de+ Z,e	jdd Z-e
j./ej01e2 d e
j3j4dddd  e
j3j4d!dddde5e
j6d" ej78d#d!Z9e
j3:e9 dS )$    N)get_fpu_mode)FPUModeChangeWarning)_pep440)SCIPY_ARRAY_APISCIPY_DEVICEc                 C   s`   |  dd |  dd |  dd zdd l}W n tyN   |  dd Y n0 |  dd d S )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 timeoutzskip_if_array_api(*backends, reasons=None, np_only=False, cpu_only=False): mark the desired skip configuration for the `skip_if_array_api` fixture.)Zaddinivalue_linepytest_timeout	Exception)configr    r   J/var/www/html/django/DPS/env/lib/python3.9/site-packages/scipy/conftest.pypytest_configure   s$    
r   c                 C   s0   t tjt dkr"| |}n
| |}|S )Nz3.6.0)r   parsepytest__version__VersionZget_closest_markerZ
get_marker)itemnamemarkr   r   r   	_get_mark#   s    
r   c           	   	   C   s  t | d}|d urNzttjdd}W n ty>   d}Y n0 |sNtd t | d}|d urt	dj
dk rtd	|jd   t }|tj zdd
lm} d}W n ty   d}Y n0 |r^zttjd }W n" ty   Y W d    d S 0 tds^t d }t|| d}z||dd W n" ty\   Y W d    d S 0 W d    n1 st0    Y  d S )NZxslowZSCIPY_XSLOW0Fz@very slow test; set environment variable SCIPY_XSLOW=1 to run itZxfail_on_32bitr      z&Fails on our 32-bit test platform(s): )threadpool_limitsTZPYTEST_XDIST_WORKER_COUNTZOMP_NUM_THREADS      Zblas)Zuser_api)r   intosenvironget
ValueErrorr   skipnpZintpitemsizeZxfailargsnptZsuppress_warningsfilterZ PytestUnraisableExceptionWarningZthreadpoolctlr   r	   KeyErrorgetenv	cpu_countmax)	r   r   vsupr   ZHAS_THREADPOOLCTLZxdist_worker_countZmax_openmp_threadsZthreads_per_workerr   r   r   pytest_runtest_setup+   s<    





r,   functionT)scopeZautousec                 c   s@   t  }dV  t  }||kr<tjd|dd|ddtdd dS )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   )requestZold_modeZnew_moder   r   r   check_fpu_mode\   s    r4   numpyarray_api_strictZpytorchcupy)1trueallc                 C   s   i | ]}|t | qS r   )xp_available_backends).0backendr   r   r   
<dictcomp>   s   r>   z!'--array-api-backend' must be in cudaxpc           
      C   s"  d|j vrdS |j d j}|j d j}|dd}|dd}|rr|ddg}|d }| jd	krntj|d
 dS |rd}trtdkr| jdkrtj|d
 n(| jdkrdt	
djjvrtj|d
 |dur|dd}t|D ]8\}}	| j|	kr|sd|	 }n|| }tj|d
 qdS )a  
    Skip based on the ``skip_if_array_api`` marker.

    Parameters
    ----------
    *backends : tuple
        Backends to skip, 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``.
    reasons : list, optional
        A list of reasons for each skip. When ``np_only`` is ``True``,
        this should be a singleton list. Otherwise, this should be a list
        of reasons, one for each corresponding backend in ``backends``.
        If unprovided, default reasons are used. Note that it is not possible
        to specify a custom reason with ``cpu_only``. Default: ``None``.
    np_only : bool, optional
        When ``True``, the test is skipped 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
        singleton list to ``reasons``. Default: ``False``.
    cpu_only : bool, optional
        When ``True``, the test is skipped 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``.
    skip_if_array_apiNnp_onlyFcpu_onlyreasonsz#do not run with non-NumPy backends.r   r5   )reasonz4do not run with `SCIPY_ARRAY_API` set and not on CPUcpur7   torchz#do not run with array API backend: )keywordsr#   kwargsr   __name__r   r    r   r   rG   emptyZdevicetype	enumerate)
r@   r3   backendsrI   rB   rC   rD   rE   ir=   r   r   r   rA      s8    





rA   z.hypothesisZnondeterministic)r   deadline
print_blobZdeterministic)r   rP   rQ   ZdatabaseZderandomizeZsuppress_health_checkSCIPY_HYPOTHESIS_PROFILE);jsonr   r1   tempfiler5   r!   Znumpy.testingtestingr$   r   Z
hypothesisZscipy._lib._fpumoder   Zscipy._lib._testutilsr   Z
scipy._libr   Zscipy._lib._array_apir   r   r   r   r,   Zfixturer4   r;   
isinstancestrr6   updateImportErrorrG   Zset_default_devicer7   lowerloadsZSCIPY_ARRAY_API_r&   keysmsgr   r   ZparametrizevaluesZarray_api_compatiblerA   configurationZset_hypothesis_home_dirpathjoin
gettempdirsettingsZregister_profilelistZHealthCheckr   r   rR   Zload_profiler   r   r   r   <module>   s   1





=