o
    4BiJ#                     @   s<  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yt   Y nw zd dlZedei e e W n	 ey   Y nw zd dl!Z!ede!i W n	 ey   Y nw e" dvre #eZ$de$v rnz	dd e$D ZW n e%y   de&  Z'e(e'w 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y'   |  dd Y nw |  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.)addinivalue_linepytest_timeout	Exception)configr	    r   N/var/www/html/Trade-python/venv/lib/python3.10/site-packages/scipy/conftest.pypytest_configure   s&   r   c                 C   s2   t tjt dkr| |}|S | |}|S )Nz3.6.0)r   parsepytest__version__Versionget_closest_marker
get_marker)itemnamemarkr   r   r   	_get_mark#   s
   

r   c           	   	   C   s  t | d}|d ur'zttjdd}W n ty   d}Y nw |s'td t | d}|d urCt	dj
dk rCtd	|jd   t |}|tj z
dd
lm} d}W n tyc   d}Y nw |rz	ttjd }W n ty   Y W d    d S w tdst d }t|| d}z||dd W n  ty   Y W d    d S w W d    d S W d    d S W d    d S 1 sw   Y  d S )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)r   intosenvironget
ValueErrorr   skipnpintpitemsizexfailargsnptsuppress_warningsfilter PytestUnraisableExceptionWarningthreadpoolctlr   r
   KeyErrorgetenv	cpu_countmax)	r   r   vsupr   HAS_THREADPOOLCTLxdist_worker_countmax_openmp_threadsthreads_per_workerr   r   r   pytest_runtest_setup+   sT   




"r?   functionT)scopeautousec                 c   sF    t  }dV  t  }||kr!tjd|dd|ddtdd dS 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   )requestold_modenew_moder   r   r   check_fpu_mode\   s   
rJ   numpyarray_api_strictpytorchcupy)1trueallc                 C   s   i | ]}|t | qS r   )xp_available_backends).0backendr   r   r   
<dictcomp>   s    rU   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}|r9|ddg}|d }| jd	kr7tj|d
 dS |rcd}trctdkrc| jdkrOtj|d
 n| jdkrcdt	
djjvrctj|d
 |dur|dd}t|D ]\}}	| j|	kr|sd|	 }n|| }tj|d
 qqdS d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   rK   )reasonz4do not run with `SCIPY_ARRAY_API` set and not on CPUcpurN   torchz#do not run with array API backend: )keywordsr/   kwargsr(   __name__r   r*   r   r   r^   emptydevicetype	enumerate)
rW   rG   backendsr`   rY   rZ   r[   r\   irT   r   r   r   rX      s>   




rX   z.hypothesisnondeterministic)r   deadline
print_blobdeterministic)r   ri   rj   databasederandomizesuppress_health_checkSCIPY_HYPOTHESIS_PROFILE);jsonr&   rE   tempfilerK   r+   numpy.testingtestingr0   r   
hypothesisscipy._lib._fpumoder   scipy._lib._testutilsr   
scipy._libr   scipy._lib._array_apir   r   r   r   r?   fixturerJ   rR   
isinstancestrrL   updateImportErrorr^   set_default_devicerN   lowerloadsSCIPY_ARRAY_API_r5   keysmsgr)   r   parametrizevaluesarray_api_compatiblerX   configurationset_hypothesis_home_dirpathjoin
gettempdirsettingsregister_profilelistHealthCheckr'   r(   ro   load_profiler   r   r   r   <module>   s   1



=