o
    ic%                     @   sJ  d dl Zd dlmZmZ d dlZd dlmZ d dlm	  m
Z d dlmZ dd Zdd Zd	d
 Zdd ZG dd dZG dd dZdd Zejdg dejdd dejgdd Zejdg dejddejgejddejgdd Zejdg dejdddejgejdddejgd d! ZdS )"    N)assert_assert_allclose)_ufuncs)FuncDatac                  C   sb   t jdddt dd} dt j  d }t | t | }t| |}t	t j
||dd	 d S )
Nr   i'     long)dtype      gV瞯<rtol)nparanger   randomrandcosZarccosr   eval_chebytr   Zallclose)nxZv1Zv2 r   b/home/kim/smarthome/.venv/lib/python3.10/site-packages/scipy/special/tests/test_orthogonal_eval.pytest_eval_chebyt
   s
   r   c                   C   s   t dddks
J d S )Nr   y       @        g     @)r   r   r   r   r   r   test_eval_chebyt_gh20129   s   r   c                   C   s4   t ttddd t ttddd d S )Nr   g?)r   r   isnanr   eval_genlaguerrer   r   r   r   !test_eval_genlaguerre_restriction   s   r   c                   C   sX   t jdd tdd tdd tddd W d    d S 1 s%w   Y  d S )Nraiseallr
   r   )r   errstater   eval_legendreeval_laguerreeval_gegenbauerr   r   r   r   test_warnings   s
   "r$   c                   @   s   e Zd ZdZ		d&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d Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%S )'	TestPolyszQ
    Check that the eval_* functions agree with the constructed polynomials

    r   
   :0yE>c	                    sX  t jdg }	t |D ]c}
fdd|D }t |j}|s$dg}|D ]I}|r2|
ft| }n|
f}|d |d |d  |  }|d |d< |d |d< t || j	}t j
t ||df|||f }|	| q&qt j|	dd}	 fdd}t jd	d
 t||	ttt|d d|d}|  W d    d S 1 sw   Y  d S )N  c                    s&   g | ]\}}|||     qS r   )r   .0ab)nparamrngr   r   
<listcomp>2   s   & z(TestPolys.check_poly.<locals>.<listcomp>r   r
   Zaxisc                     s*   | d  tdf| dd   }  |  S )Nr   r   r
   )astyper   r   )pfuncr   r   polyfuncD   s   "z&TestPolys.check_poly.<locals>.polyfuncr   r   r	   r   r   )r   r   ZRandomStater   asarrayTtupler   Zpoly1dZcoefc_tileappendconcatenater    r   listrangelencheck)selfr4   clsparam_rangesx_rangennr-   nxr   datasetr   paramsr2   r   Zpolyzr5   dsr   )r4   r-   r.   r   
check_poly,   s4   " 
"zTestPolys.check_polyc                 C   s$   | j tjtjddgddgdd d S )NgGzr&   r   r
   h㈵>rC   rD   r   )rK   r   eval_jacobiorthZjacobirA   r   r   r   test_jacobiM   s   
zTestPolys.test_jacobic                 C   s$   | j tjtjddgddgdd d S )Nr
   r&   r   r
   r   r
   rM   rN   )rK   r   eval_sh_jacobirP   Z	sh_jacobirQ   r   r   r   test_sh_jacobiR   s   
zTestPolys.test_sh_jacobic                 C   s"   | j tjtjdgddgdd d S )NgV-߿r&   r   r
   gHz>rN   )rK   r   r#   rP   Z
gegenbauerrQ   r   r   r   test_gegenbauerW   s   

zTestPolys.test_gegenbauerc                 C      | j tjtjg ddgd d S Nr   r
   rC   rD   )rK   r   r   rP   ZchebytrQ   r   r   r   test_chebyt\      
zTestPolys.test_chebytc                 C   rY   rZ   )rK   r   eval_chebyurP   ZchebyurQ   r   r   r   test_chebyu`   r]   zTestPolys.test_chebyuc                 C   rY   Nr	   r[   )rK   r   eval_chebysrP   ZchebysrQ   r   r   r   test_chebysd   r]   zTestPolys.test_chebysc                 C   rY   r`   )rK   r   eval_chebycrP   ZchebycrQ   r   r   r   test_chebych   r]   zTestPolys.test_chebycc                 C   L   t jdd | jtjtjg ddgd W d    d S 1 sw   Y  d S Nignorer   r   r
   r[   )r   r    rK   r   eval_sh_chebytrP   Z	sh_chebytrQ   r   r   r   test_sh_chebytl   
   "zTestPolys.test_sh_chebytc                 C   rY   Nr   r
   r[   )rK   r   eval_sh_chebyurP   Z	sh_chebyurQ   r   r   r   test_sh_chebyuq   r]   zTestPolys.test_sh_chebyuc                 C   rY   rZ   )rK   r   r!   rP   ZlegendrerQ   r   r   r   test_legendreu   r]   zTestPolys.test_legendrec                 C   rf   rg   )r   r    rK   r   eval_sh_legendrerP   Zsh_legendrerQ   r   r   r   test_sh_legendrey   rk   zTestPolys.test_sh_legendrec                 C   s    | j tjtjdgddgd d S NrL   r   d   r[   )rK   r   r   rP   ZgenlaguerrerQ   r   r   r   test_genlaguerre~   s   

zTestPolys.test_genlaguerrec                 C   rY   Nr   rs   r[   )rK   r   r"   rP   ZlaguerrerQ   r   r   r   test_laguerre   r]   zTestPolys.test_laguerrec                 C   rY   Nirs   r[   )rK   r   eval_hermiterP   ZhermiterQ   r   r   r   test_hermite   r]   zTestPolys.test_hermitec                 C   rY   rw   )rK   r   eval_hermitenormrP   ZhermitenormrQ   r   r   r   test_hermitenorm   r]   zTestPolys.test_hermitenormNr   r   r&   r&   r&   r'   )__name__
__module____qualname____doc__rK   rR   rV   rX   r\   r_   rc   re   rj   rn   ro   rq   rt   rv   ry   r{   r   r   r   r   r%   &   s(    
!r%   c                   @   s   e Zd ZdZ		d$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d Zdd Zdd Zdd Zdd  Zd!d" Zd#S )%TestRecurrencezI
    Check that the eval_* functions sig='ld->d' and 'dd->d' agree.

    r   r&   r'   c              	      sn  t jd g }t |D ]n}	fdd|D }
t |
j}
|s#dg}
|
D ]U}|r1|	ft| }n|	f}|d |d |d  t j|  }|d |d< |d |d< tt	|d d d d}t j
t ||df| ||f i |f }|| q%qt j|dd	} fd
d}t jdd t||ttt	|d d|d}|  W d    d S 1 sw   Y  d S )Nr(   c                    s(   g | ]\}}||| t j   qS r   )r   r   r   r)   )r-   r   r   r/      s   ( z-TestRecurrence.check_poly.<locals>.<listcomp>r   r
   d->dsigr0   c                     sV   | d  tj}|f| dd   } |jj}t|t| d d  d d} | i |S )Nr   r
   r   r   r   )r1   r   Zintpr   chardictr?   )r2   p0Zp0_type_charkwr3   r   r   r5      s
   z+TestRecurrence.check_poly.<locals>.polyfuncr   r   r	   r   r   )r   r   seedr   r6   r7   r8   r   r   r?   r9   r:   r;   r<   r    r   r=   r>   r@   )rA   r4   rC   rD   rE   r-   rF   r   rG   r   rH   r2   r   r   rI   r5   rJ   r   )r4   r-   r   rK      s4   $,
"zTestRecurrence.check_polyc                 C   s   | j tjddgddgd d S )NrL   r   r
   r[   )rK   r   rO   rQ   r   r   r   rR      s   
zTestRecurrence.test_jacobic                 C   s   | j tjddgddgd d S )NrS   rT   r   r
   r[   )rK   r   rU   rQ   r   r   r   rV      s   
zTestRecurrence.test_sh_jacobic                 C      | j tjdgddgd d S )NrW   r   r
   r[   )rK   r   r#   rQ   r   r   r   rX         

zTestRecurrence.test_gegenbauerc                 C      | j tjg ddgd d S rZ   )rK   r   r   rQ   r   r   r   r\         
zTestRecurrence.test_chebytc                 C   r   rZ   )rK   r   r^   rQ   r   r   r   r_      r   zTestRecurrence.test_chebyuc                 C   r   r`   )rK   r   rb   rQ   r   r   r   rc      r   zTestRecurrence.test_chebysc                 C   r   r`   )rK   r   rd   rQ   r   r   r   re      r   zTestRecurrence.test_chebycc                 C   r   rl   )rK   r   ri   rQ   r   r   r   rj      r   zTestRecurrence.test_sh_chebytc                 C   r   rl   )rK   r   rm   rQ   r   r   r   rn      r   zTestRecurrence.test_sh_chebyuc                 C   r   rZ   )rK   r   r!   rQ   r   r   r   ro      r   zTestRecurrence.test_legendrec                 C   r   rl   )rK   r   rp   rQ   r   r   r   rq      r   zTestRecurrence.test_sh_legendrec                 C   r   rr   )rK   r   r   rQ   r   r   r   rt      r   zTestRecurrence.test_genlaguerrec                 C   r   ru   )rK   r   r"   rQ   r   r   r   rv      r   zTestRecurrence.test_laguerrec                 C   s   t dd}d}t|| d S )NF         ?gi\m)r   rx   r   )rA   vr+   r   r   r   ry      s   zTestRecurrence.test_hermiteNr|   )r}   r~   r   r   rK   rR   rV   rX   r\   r_   rc   re   rj   rn   ro   rq   rt   rv   ry   r   r   r   r   r      s&    
$r   c                   C   s0   t tddsJ t tddsJ d S )Nr   r   )r   r   r   rx   rz   r   r   r   r   test_hermite_domain   s   r   r   )r   r
   r	   r   r
   c                 C   sX   t t| |t t | |gksJ t t| |t t | |gks*J d S N)r   r   r   rx   anyrz   )r   r   r   r   r   test_hermite_nan   s   *.r   )r   r
   r	   g	@alphar	   c                 C   :   t t| ||}t t | ||g}||ksJ d S r   )r   r   r   r   r   )r   r   r   Znan_laguerrenan_argr   r   r   test_genlaguerre_nan     r   g        gư>c                 C   r   r   )r   r   r   r#   r   )r   r   r   Znan_gegenbauerr   r   r   r   test_gegenbauer_nan  r   r   )numpyr   Znumpy.testingr   r   ZpytestZscipy.specialr   Zscipy.special._orthogonalZspecialZ_orthogonalrP   Zscipy.special._testutilsr   r   r   r   r$   r%   r   r   markZparametrizenanr   r   r   r   r   r   r   <module>   s0    	ie