o
    5ήcu                  
   @   s   d dl Z d dlZd dlmZmZ d dlZd dlmZ d dlm	Z
 d dlmZ ddddd	d
dddd	Zg dZdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! ZdS )"    N)assert_assert_equal)raises)_sf_error_test_function                        	   )	singular	underflowoverflowslowloss	no_resultdomainargother)ignorewarnraisec                 C   s   |dkr!t tj | |  W d    d S 1 sw   Y  d S |dkrAttj | |  W d    d S 1 s:w   Y  d S t  td | |  W d    d S 1 sZw   Y  d S )Nr   r   error)	pytestwarnsscSpecialFunctionWarningassert_raisesSpecialFunctionErrorwarningscatch_warningssimplefilter)funargsaction r(   H/tmp/pip-target-vg8gfxp4/lib/python/scipy/special/tests/test_sf_error.py_check_action   s   
"
"


"r*   c                  C   s6   t  } |  D ]\}}t|tv  t|tv  qd S )N)r   geterritemsr   _sf_error_code_map_sf_error_actions)errkeyvaluer(   r(   r)   test_geterr-   s
   r2   c               
   C   s   t  } zPt D ]@\}}tD ]9}t  }t jdi ||i}t||k t  }t|| |k || || t||k tt	|f| qq	W t jdi |  d S t jdi |  w Nr(   )
r   r+   r-   r,   r.   seterrr   popr*   r   )	entry_errcategory
error_coder'   geterr_olderrseterr_olderrnewerrr(   r(   r)   test_seterr4   s    

&r<   c               	   C   s   t t} tjdd% tjtjdd td W d    n1 s$w   Y  W d    n1 s3w   Y  t t}|| ksCJ d S )Nr   )allzdomain error)matchg       @)sysgetrefcountr   errstater   r   r!   ndtri)refcount_beforerefcount_afterr(   r(   r)   test_sf_error_special_refcountF   s   

rE   c               	   C   z   t  } t jdd" tt j t d W d    n1 s w   Y  W d    n1 s/w   Y  t| t   d S )Nr   )r   r   )r   r+   rA   r    r!   loggammar   olderrr(   r(   r)   test_errstate_pyx_basicR      rJ   c               	   C   rF   )Nr   )r   )r   r+   rA   r    r!   spencer   rH   r(   r(   r)   test_errstate_c_basicZ   rK   rN   c               	   C   rF   )Nr   )r   i)r   r+   rA   r    r!   wrightomegar   rH   r(   r(   r)   test_errstate_cpp_basicb   rK   rP   c               
   C   sx   t  D ]5\} }tD ].}t }tjdi | |i tt|f| W d    n1 s,w   Y  t|t  q
qd S r3   )	r-   r,   r.   r   r+   rA   r*   r   r   )r7   r8   r'   rI   r(   r(   r)   test_errstatej   s   rQ   c               	   C   s   t  } t jddd' t d tt j t d W d    n1 s&w   Y  W d    n1 s5w   Y  t| t   d S )Nr   r   )r=   r   r   g      )r   r+   rA   gammalnr    r!   rM   r   rH   r(   r(   r)   test_errstate_all_but_ones   s   
rS   )r?   r"   numpy.testingr   r   r   r   r    scipy.specialspecialr   scipy.special._ufuncsr   r-   r.   r*   r2   r<   rE   rJ   rN   rP   rQ   rS   r(   r(   r(   r)   <module>   s6    	