o
    EbR                     @   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   B/usr/lib/python3/dist-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   	threadingZ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     )npZlinspaceZmeshgrid)n_pointsxyZx_gridZ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   Ztime_startedr!   interpolater   r	   calibrate_delay(   s   z9TestGIL.test_rectbivariatespline.<locals>.calibrate_delayc                 S   s   t j| || d S r   )scipyr'   ZRectBivariateSpline)r   r   r    r   r   r	   r'   0   s   z5TestGIL.test_rectbivariatespline.<locals>.interpolate   )r%   g      ?working)r   r+   r+   r+   r   )	r   startranger$   sleepr   joinr   r   )r   r(   r   Zworker_threadir   r&   r	   test_rectbivariatespline   s   

z TestGIL.test_rectbivariatesplineN)r   r   r   __doc__r
   r   r   pytestZmarkZslowZxfailr1   r   r   r   r	   r      s    r   )r"   r   r$   Znumpyr   Znumpy.testingr   r3   Zscipy.interpolater)   r   r   r   r   r	   <module>   s    