o
    Ö­jV  ã                   @   sì  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 z
d dlmZ dZW n eyW   d	ZY nw zd dlZdZW n eyk   d	ZY nw d
d„ Zdd„ Zejddd�dd„ ƒZ esˆejdd„ ƒZ!deiZ"e�rOe#ee$ƒ�rOz"d dl%Z%e" &de%i¡ e 'e%j(¡e )d¡k r°e*dƒ‚e%j+dd� W n	 e*yÀ   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 z!d dl/Z0e" &de0ji¡ e0j1 &dd¡ e0j1 &de0 2e¡d  ¡ W n
 e*�y   Y nw e 3¡ dv�rOe  4e¡Z5d e5v �r2nz	d!d"„ e5D ƒZ"W n e6�yN   d#e" 7¡ › �Z8e9e8ƒ‚w de"v �rVd$Zej: ;d%e" <¡ ¡Z=ej:j>ed&d'�Z?d(d)„ Z@ejd*d+„ ƒZAejd,d-„ ƒZBdEd/d0„ZCejD EejF Ge H¡ d1¡¡ ejIjJd2ddd3� ejIjJd4ddddeKejLƒd5� ejM Nd6d4¡ZOejI PeO¡ e�rôedFd7d8„ƒZQeQe_ReSg d9¢ƒe_Tej(d:k �rÔejT &eSg d;¢ƒ¡ g d<¢e_Ud=d=d>d?d@dAœe_VeSdBgƒe_WdCg dD¢ie_Xde_YdS dS )Gé    N)Úcontextmanager)Úget_fpu_mode)ÚFPUModeChangeWarning)ÚSCIPY_ARRAY_APIÚSCIPY_DEVICE)Ú_pep440)Ú	dt_configTFc                 C   sÈ   |   dd¡ |   dd¡ |   dd¡ zdd l}W n ty'   |   dd¡ Y nw zddlm} W n ty?   |   dd¡ Y nw |   dd	¡ |   dd
¡ tsb|   dd¡ |   dd¡ |   dd¡ d S 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 timeout)Úparse_durationz8fail_slow: mark a test for a non-default timeout failurez skip_xp_backends(backends, reason=None, np_only=False, cpu_only=False, exceptions=None): mark the desired skip configuration for the `skip_xp_backends` fixture.z£xfail_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
   © r   úK/var/www/html/CropPilot/venv/lib/python3.10/site-packages/scipy/conftest.pyÚpytest_configure   sV   ÿÿÿÿÿÿÿÿÿþþþ÷r   c           	   	   C   sš  |   d¡}|d ur'zttj dd¡ƒ}W n ty   d}Y nw |s't d¡ |   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 |r«z	ttjd ƒ}W n ty   Y W d   ƒ d S w t d¡s³t ¡ 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 sÆw   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)Ú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_workerr   r   r   Úpytest_runtest_setupI   sT   
ÿ


þì
âðõê"ær>   Úfunction)Ú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_modez   s   €
þÿrI   c                   C   s   dS )Nr   r   r   r   r   r   Únum_parallel_threadsŠ   s   rJ   Ú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Úallc                 C   s   i | ]}|t | “qS r   )Úxp_available_backends)Ú.0Úbackendr   r   r   Ú
<dictcomp>¾   s    ÿÿrY   z!'--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                 C   sì   | j |› d� j}t|ƒdkrtd|› �ƒ‚t| j |› d�¡ƒ}g }i }|D ]J}|j d¡r=d|d< |j dg ¡|d< n|j d¡rU| d¡sUd|d< |j dg ¡|d< t|jƒdkrq|jd }| 	|¡ |j
d
i ||ji¤Ž q'||fS )z%A helper for {skip,xfail}_xp_backendsÚ_xp_backendsr   zmultiple backends: Únp_onlyTÚ
exceptionsÚcpu_onlyr   Nr   )Úkeywordsr,   Úlenr%   ÚlistÚnodeÚiter_markersÚkwargsr$   ÚappendÚupdate)rF   Úskip_or_xfailÚargs_r	   Úbackendsrg   ÚmarkerrX   r   r   r   Ú_backends_kwargs_from_requestÐ   s(   


€rn   c                 C   ó2   d|j vrdS t|dd�\}}t| ||dd� dS )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'   ©rj   ©rb   rn   Úskip_or_xfail_xp_backends©r[   rF   rl   rg   r   r   r   rp   ï   s   
rp   c                 C   ro   )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+   rq   rr   rt   r   r   r   ru     s   
ru   r'   c                 C   sº  t t|ƒ}| dd¡}| dd¡}| dg ¡}| d¡ }r&td|›d�ƒ‚|r,|r,d}|r6|s6|s6tdƒ‚|r^| d	d
¡}t|tƒsMt|ƒdkrMtdƒ‚| jdkr\| j|vr\||d� dS |r´d}|du rhg n|}tr´t	dkr´| jdkrd|vr||d� n5| jdkr—d|vr—d|  
d¡jjvr–||d� n| jdkr´d|vr´|  
d¡ ¡ D ]}	d|	jvr³||d� q§|durÙt|ƒD ]\}
}| j|krØ||  d	¡}|sÓd|› �}||d� q¼dS dS )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.
    r_   Fra   r`   Ú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`rK   r\   NzTno array-agnostic implementation or delegation available for this backend and deviceÚcpurO   rN   r   rP   z#do not run with array API backend: )Úgetattrr&   r$   r%   Ú
isinstanceÚstrrc   Ú__name__r   r   ÚemptyÚdeviceÚtypeÚdevicesÚdevice_kindÚ	enumerate)r[   rl   rg   rj   r_   ra   r`   rv   r]   ÚdÚirX   r   r   r   rs     sT   
#

€

€


€ùrs   z.hypothesisÚnondeterministic)ÚnameÚdeadlineÚ
print_blobÚdeterministic)r…   r†   r‡   ÚdatabaseÚderandomizeÚsuppress_health_checkÚSCIPY_HYPOTHESIS_PROFILEc              	   c   sª  � t ƒ }ddg}|D ]
}t tdd�||< q
g d¢}|D ]	}t td�||< qddlm} d	d
g}|D ]}t |jdd�||< q1g d¢}|D ]	}t td�||< qCt tdd�t dtd�t d|jd�dœ}| |¡ t	dƒ}	ddl
m}
 ddl}|
ƒ �U |j d¡ t ¡ �2 | r˜| j|v r˜tjdi || j ¤Ž dV  n| r£| j|	v r£dV  n	t dt¡ dV  W d  ƒ n1 s¶w   Y  W d  ƒ dS W d  ƒ dS 1 sÎw   Y  dS )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)rB   Úmessage)zscipy.signal.cwtzscipy.signal.morletzscipy.signal.morlet2zscipy.signal.rickerzscipy.integrate.simpsonzscipy.interpolate.interp2dzscipy.linalg.kron)rB   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�   rB   z"The maximum number of subdivisions)r�   z
linalg.rstz	stats.rstúscipy.signal.normalize)Ú_fixed_default_rngNÚignoreÚerror)r’   )ÚdictÚRuntimeWarningÚDeprecationWarningÚscipyrŽ   ÚIntegrationWarningÚUserWarningÚPendingDeprecationWarningri   ÚsetÚscipy._lib._utilr‘   rK   ÚrandomÚseedrD   Úcatch_warningsr…   ÚfilterwarningsÚsimplefilterÚWarning)ÚtestÚknown_warningsÚdivide_by_zeror…   Ú
deprecatedrŽ   Úintegration_wÚuser_wÚdctÚlegitr‘   r(   r   r   r   Úwarnings_errors_and_rng†  sf   €ÿÿÿÿ
ÿÿø


ÿ€÷þ"þr«   )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"   rD   ÚtempfileÚ
contextlibr   rK   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>   ÚfixturerI   rJ   rV   ry   rz   rL   ri   ÚparseÚ__version__ÚVersionÚImportErrorÚset_array_api_strict_flagsrN   Úset_default_devicerO   Ú	jax.numpyÚjaxr   r   ÚlowerÚloadsÚSCIPY_ARRAY_API_r2   ÚkeysÚmsgr%   r7   ÚparametrizeÚvaluesÚarray_api_compatibleÚskipifÚskip_xp_invalid_argrn   rp   ru   rs   ÚconfigurationÚset_hypothesis_home_dirÚpathÚjoinÚ
gettempdirÚsettingsÚregister_profilerd   ÚHealthCheckr#   r$   rŒ   Úload_profiler«   Úuser_context_mgrr›   ÚskiplistÚpytest_extra_ignoreÚpytest_extra_xfailÚ
pseudocodeÚlocal_resourcesÚstrict_checkr   r   r   r   Ú<module>   sú   ÿÿ*1


ÿÿÿÿÿ


þþ
ÿ


VÿÿýÿQ
ú
ÿ
 �Û