o
    gR                     @   sN   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	G dd dZ
dS )    N)assert_equalc                   @   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   ^/home/ubuntu/cloudmapper/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                    sz   dd   fdd}dd |dd}|  |}|  tdD ]}td	 | d
 q"|  t| jg d 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-   0   s   z5TestGIL.test_rectbivariatespline.<locals>.interpolate   )r*   g      ?working)r   r2   r2   r2   r   )	r   startranger)   sleepr   joinr   r   )r   r.   r   worker_threadir   r,   r	   test_rectbivariatespline   s   

z TestGIL.test_rectbivariatesplineN)r   r   r   __doc__r
   r   r   pytestmarkslowxfailr9   r   r   r   r	   r      s    r   )r'   r   r)   numpyr   numpy.testingr   r;   scipy.interpolater/   r   r   r   r   r	   <module>   s    