a
    ‡ù»j8$  ã                   @   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�rºeeeƒ�rºz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�rºe  #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 �rÈdZe	j) *de +¡ ¡Z,e	jdd„ ƒZ-e
j. /ej0 1e 2¡ d¡¡ e
j3j4dddd � e
j3j4d!dddde5e
j6ƒd"� ej7 8d#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 timeoutz“skip_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   ú4E:\soccer\ml_env\Lib\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r†t 	d¡j
dk r†t 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 |rÆd}trÆtdkrÆ| jdkržtj|d
� n(| jdkrÆdt	 
d¡jjvrÆtj|d
� |du�r| dd¡}t|ƒD ]8\}}	| j|	krä|�sd|	› �}n|| }tj|d
� qä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   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.testingZ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


þ


=ÿÿýÿ