o
    Ö­j'  ã                   @   sB   d dl Z d dlZd dlZd dlZd dlZd dlZG dd„ dƒZdS )é    Nc                   @   sF   e Zd ZdZdd„ Zdd„ Zdd„ Zejj	ejj
dd	�d
d„ ƒƒZdS )ÚTestGILzECheck if the GIL is properly released by scipy.interpolate functions.c                 C   s
   g | _ d S ©N)Úmessages©Úself© r   ú]/var/www/html/CropPilot/venv/lib/python3.10/site-packages/scipy/interpolate/tests/test_gil.pyÚsetup_method   s   
zTestGIL.setup_methodc                 C   s   | j  |¡ d S r   )r   Úappend)r   Úmessager   r   r   Úlog   s   zTestGIL.logc                    s&   | j ‰G ‡ ‡‡fdd„dtjƒ}|ƒ S )Nc                       s   e Zd Z‡ ‡‡fdd„ZdS )z0TestGIL.make_worker_thread.<locals>.WorkerThreadc                    s   ˆdƒ ˆˆ Ž  ˆdƒ d S )Núinterpolation startedúinterpolation completer   r   ©Úargsr   Útargetr   r   Úrun   s   z4TestGIL.make_worker_thread.<locals>.WorkerThread.runN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   ÚWorkerThread   s    r   )r   Ú	threadingÚThread)r   r   r   r   r   r   r   Úmake_worker_thread   s   zTestGIL.make_worker_threadz*race conditions, may depend on system load)Úreasonc                    s|   dd„ ‰ ‡ ‡fdd„}dd„ ‰|dd�}|   ˆ|¡}| ¡  tdƒD ]}t d	¡ |  d
¡ q"| ¡  | jg d¢ks<J ‚d S )Nc                 S   s4   t  dd| ¡ }}t  ||¡\}}|| }|||fS )Nr   éè  )ÚnpÚlinspaceÚmeshgrid)Ún_pointsÚxÚyÚx_gridÚy_gridÚzr   r   r   Úgenerate_params!   s   
z9TestGIL.test_rectbivariatespline.<locals>.generate_paramsc                    sF   t  dd¡D ]}ˆ |ƒ}t ¡ }ˆ|Ž  t ¡ | | kr |  S qd S )Niˆ  r   )Ú	itertoolsÚcountÚtime)Úrequested_timer   r   Útime_started©r%   Úinterpolater   r   Úcalibrate_delay'   s   ÿüz9TestGIL.test_rectbivariatespline.<locals>.calibrate_delayc                 S   s   t j | ||¡ d S r   )Úscipyr,   ÚRectBivariateSpline)r    r!   r$   r   r   r   r,   /   s   z5TestGIL.test_rectbivariatespline.<locals>.interpolateé   )r)   g      à?Úworking)r   r1   r1   r1   r   )r   ÚstartÚranger(   Úsleepr   Újoinr   )r   r-   r   Úworker_threadÚir   r+   r   Útest_rectbivariatespline   s   

z TestGIL.test_rectbivariatesplineN)r   r   r   Ú__doc__r	   r   r   ÚpytestÚmarkÚxslowÚxfailr8   r   r   r   r   r   
   s    r   )	r&   r   r(   Únumpyr   r:   Úscipy.interpolater.   r   r   r   r   r   Ú<module>   s    