a
    Qe7                     @   s  d dl Zd dlmZmZmZmZ d dlZd dl mZm	Z	m
Z
mZmZmZmZmZmZ d dlmZmZmZmZ d dlmZ G dd dZG dd	 d	ZG d
d dZG dd dZG dd dZG dd dZG dd deZG dd deZG dd deZ G dd deZ!G dd dZ"dS )    N)assert_almost_equalassert_allcloseassert_array_almost_equalsuppress_warnings)	sincossinhcoshexpinfnanr_pi)spherical_jnspherical_ynspherical_inspherical_kn)quadc                   @   sL   e Z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 )TestSphericalJnc                 C   sN   t g d}ttd|d| d|d   t| d|d  t|   d S )NQ?Gz?Gz(@^@g     J@      )nparrayr   r   r   r   selfx r"   ]/var/www/sunrise/env/lib/python3.9/site-packages/scipy/special/tests/test_spherical_bessel.pytest_spherical_jn_exact   s    
.z'TestSphericalJn.test_spherical_jn_exactc                 C   sN   t g d}d}tt|d |t|d | d| d | t||  d S N   r   r         ?      ?r'   r   r   r   r   r   r    nr!   r"   r"   r#   $test_spherical_jn_recurrence_complex   s
    z4TestSphericalJn.test_spherical_jn_recurrence_complexc                 C   sN   t g d}d}tt|d |t|d | d| d | t||  d S Nr&   r   r'   r   r+   r,   r"   r"   r#   !test_spherical_jn_recurrence_real   s
    z1TestSphericalJn.test_spherical_jn_recurrence_realc                 C   s2   d}t t tg}tt||t ddg d S N   r   )r   r   r   r   r   r,   r"   r"   r#   test_spherical_jn_inf_real%   s    z*TestSphericalJn.test_spherical_jn_inf_realc              	   C   sx   d}t t d td td g}t <}|td tt||t ddtd g W d    n1 sj0    Y  d S Nr(                         ?      ?z%invalid value encountered in multiplyr   )r   r   r   r   filterRuntimeWarningr   r   r    r-   r!   supr"   r"   r#   test_spherical_jn_inf_complex+   s
    z-TestSphericalJn.test_spherical_jn_inf_complexc                 C   s   t tddd d S )Nr   g%-@g<]3r   r   r    r"   r"   r#   test_spherical_jn_large_arg_13   s    z-TestSphericalJn.test_spherical_jn_large_arg_1c                 C   s   t tddd d S )Nr   i'  g|	 ?r<   r=   r"   r"   r#   test_spherical_jn_large_arg_29   s    z-TestSphericalJn.test_spherical_jn_large_arg_2c                 C   s0   t g d}d}tt||t g d d S Nr   r'   r      
   d   r   )r'   r   r   r   r   r   r+   r,   r"   r"   r#   test_spherical_jn_at_zero?   s    z)TestSphericalJn.test_spherical_jn_at_zeroN)__name__
__module____qualname__r$   r.   r0   r3   r;   r>   r?   rE   r"   r"   r"   r#   r      s   r   c                   @   sD   e Z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 )TestSphericalYnc                 C   sN   t g d}ttd|d| d|d   t| d|d  t|   d S )Nr   r   r'   r   )r   r   r   r   r   r   r   r"   r"   r#   test_spherical_yn_exactH   s    
.z'TestSphericalYn.test_spherical_yn_exactc                 C   sN   t g d}d}tt|d |t|d | d| d | t||  d S r/   r   r   r   r   r,   r"   r"   r#   !test_spherical_yn_recurrence_realP   s
    z1TestSphericalYn.test_spherical_yn_recurrence_realc                 C   sN   t g d}d}tt|d |t|d | d| d | t||  d S r%   rK   r,   r"   r"   r#   $test_spherical_yn_recurrence_complexW   s
    z4TestSphericalYn.test_spherical_yn_recurrence_complexc                 C   s2   d}t t tg}tt||t ddg d S r1   )r   r   r   r   r   r,   r"   r"   r#   test_spherical_yn_inf_real^   s    z*TestSphericalYn.test_spherical_yn_inf_realc              	   C   sx   d}t t d td td g}t <}|td tt||t ddtd g W d    n1 sj0    Y  d S r4   )r   r   r   r   r7   r8   r   r   r9   r"   r"   r#   test_spherical_yn_inf_complexd   s
    z-TestSphericalYn.test_spherical_yn_inf_complexc                 C   s2   t g d}d}tt||t |jt  d S NrA   r   )r   r   r   r   fullshaper   r,   r"   r"   r#   test_spherical_yn_at_zerol   s    z)TestSphericalYn.test_spherical_yn_at_zeroc                 C   s0   t g d}d}tt||t |jt d S NrA   r5   )r   r   r   r   rQ   rR   r   r,   r"   r"   r#   !test_spherical_yn_at_zero_complexr   s    z1TestSphericalYn.test_spherical_yn_at_zero_complexN)
rF   rG   rH   rJ   rL   rM   rN   rO   rS   rU   r"   r"   r"   r#   rI   G   s   rI   c                   @   s   e Zd Zdd Zdd ZdS )TestSphericalJnYnCrossProductc                 C   sf   t g d}t g d}t|d |t|| t||t|d |  }d|d  }t|| d S )Nr'   rB      g?r'   rC   r'   r   r   r   r   r   r   r    r-   r!   leftrightr"   r"   r#   $test_spherical_jn_yn_cross_product_1~   s    zBTestSphericalJnYnCrossProduct.test_spherical_jn_yn_cross_product_1c                 C   sn   t g d}t g d}t|d |t|| t||t|d |  }d| d |d  }t|| d S )NrW   rY   r   r   rZ   r[   r"   r"   r#   $test_spherical_jn_yn_cross_product_2   s    zBTestSphericalJnYnCrossProduct.test_spherical_jn_yn_cross_product_2N)rF   rG   rH   r^   r_   r"   r"   r"   r#   rV   }   s   	rV   c                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )TestSphericalInc                 C   sN   t g d}ttd|d| d|d   t| d|d  t|   d S N)r   r   r   r   r   r'   r   )r   r   r   r   r   r	   r   r"   r"   r#   test_spherical_in_exact   s    
.z'TestSphericalIn.test_spherical_in_exactc                 C   sN   t g d}d}tt|d |t|d | d| d | t||  d S r/   r   r   r   r   r,   r"   r"   r#   !test_spherical_in_recurrence_real   s
    z1TestSphericalIn.test_spherical_in_recurrence_realc                 C   sN   t g d}d}tt|d |t|d | d| d | t||  d S r%   rc   r,   r"   r"   r#   $test_spherical_in_recurrence_complex   s
    z4TestSphericalIn.test_spherical_in_recurrence_complexc                 C   s4   d}t t tg}tt||t t tg d S )NrB   )r   r   r   r   r   r,   r"   r"   r#   test_spherical_in_inf_real   s    z*TestSphericalIn.test_spherical_in_inf_realc                 C   sD   d}t t d td td g}tt||t t ttg d S )Nr(   r5   r6   )r   r   r   r   r   r   r,   r"   r"   r#   test_spherical_in_inf_complex   s    z-TestSphericalIn.test_spherical_in_inf_complexc                 C   s0   t g d}d}tt||t g d d S r@   rc   r,   r"   r"   r#   test_spherical_in_at_zero   s    z)TestSphericalIn.test_spherical_in_at_zeroN)	rF   rG   rH   rb   rd   re   rf   rg   rh   r"   r"   r"   r#   r`      s   r`   c                   @   sD   e Z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 )TestSphericalKnc                 C   sP   t g d}ttd|td t|  d| d|d   d|d     d S ra   )r   r   r   r   r   r
   r   r"   r"   r#   test_spherical_kn_exact   s    
0z'TestSphericalKn.test_spherical_kn_exactc                 C   sn   t g d}d}td|d  t|d | d|d  t|d |  d| d| d  | t||  d S )Nr&   r   r   r'   r   r   r   r   r   r,   r"   r"   r#   !test_spherical_kn_recurrence_real   s
    4 z1TestSphericalKn.test_spherical_kn_recurrence_realc                 C   sn   t g d}d}td|d  t|d | d|d  t|d |  d| d| d  | t||  d S )Nr&   r*   r   r'   r   rk   r,   r"   r"   r#   $test_spherical_kn_recurrence_complex   s
    4 z4TestSphericalKn.test_spherical_kn_recurrence_complexc                 C   s4   d}t t tg}tt||t t dg d S )NrB   r   )r   r   r   r   r   r,   r"   r"   r#   test_spherical_kn_inf_real   s    z*TestSphericalKn.test_spherical_kn_inf_realc                 C   sD   d}t t d td td g}tt||t t dtg d S )Nr(   r5   r6   r   )r   r   r   r   r   r   r,   r"   r"   r#   test_spherical_kn_inf_complex   s    z-TestSphericalKn.test_spherical_kn_inf_complexc                 C   s0   t g d}d}tt||t |jt d S rP   )r   r   r   r   rQ   rR   r   r,   r"   r"   r#   test_spherical_kn_at_zero   s    z)TestSphericalKn.test_spherical_kn_at_zeroc                 C   s0   t g d}d}tt||t |jt d S rT   )r   r   r   r   rQ   rR   r   r,   r"   r"   r#   !test_spherical_kn_at_zero_complex   s    z1TestSphericalKn.test_spherical_kn_at_zero_complexN)
rF   rG   rH   rj   rl   rm   rn   ro   rp   rq   r"   r"   r"   r#   ri      s   	ri   c                   @   s4   e Zd Zdd Zejjdd Zejjdd ZdS )SphericalDerivativesTestCasec                    s@   t  fdd||\}}t| | | |d d S )Nc                    s     | S N)df)zr-   r    r"   r#   <lambda>       zBSphericalDerivativesTestCase.fundamental_theorem.<locals>.<lambda>)Zatol)r   r   f)r    r-   abZintegralZ	tolerancer"   rv   r#   fundamental_theorem   s
    z0SphericalDerivativesTestCase.fundamental_theoremc                 C   s   |  ddd d S )Nr   g      @      .@r|   r=   r"   r"   r#   test_fundamental_theorem_0   s    z7SphericalDerivativesTestCase.test_fundamental_theorem_0c                 C   s   |  ddd d S )Nr(         ?g333333?r~   r=   r"   r"   r#   test_fundamental_theorem_7   s    z7SphericalDerivativesTestCase.test_fundamental_theorem_7N)	rF   rG   rH   r|   pytestmarkZslowr   r   r"   r"   r"   r#   rr      s
   
rr   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestSphericalJnDerivativesc                 C   s
   t ||S rs   r   r    r-   ru   r"   r"   r#   ry     s    zTestSphericalJnDerivatives.fc                 C   s   t ||ddS NTZ
derivativer   r   r"   r"   r#   rt     s    zTestSphericalJnDerivatives.dfc                 C   s0   t g d}tt|dddt g d d S )N)r   r'   r   r   r(      r   Tr   )r   gUUUUUU?r   r   r   r   r+   r    r-   r"   r"   r#   test_spherical_jn_d_zero  s    z3TestSphericalJnDerivatives.test_spherical_jn_d_zeroN)rF   rG   rH   ry   rt   r   r"   r"   r"   r#   r      s   r   c                   @   s   e Zd Zdd Zdd ZdS )TestSphericalYnDerivativesc                 C   s
   t ||S rs   r   r   r"   r"   r#   ry     s    zTestSphericalYnDerivatives.fc                 C   s   t ||ddS r   r   r   r"   r"   r#   rt     s    zTestSphericalYnDerivatives.dfNrF   rG   rH   ry   rt   r"   r"   r"   r#   r     s   r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestSphericalInDerivativesc                 C   s
   t ||S rs   r   r   r"   r"   r#   ry     s    zTestSphericalInDerivatives.fc                 C   s   t ||ddS r   r   r   r"   r"   r#   rt     s    zTestSphericalInDerivatives.dfc                 C   s,   t g d}tt|dddt d d S )N)r'   r   r   r(   r   r   Tr   rB   )r   r   r   r   zerosr   r"   r"   r#   test_spherical_in_d_zero  s    z3TestSphericalInDerivatives.test_spherical_in_d_zeroN)rF   rG   rH   ry   rt   r   r"   r"   r"   r#   r     s   r   c                   @   s   e Zd Zdd Zdd ZdS )TestSphericalKnDerivativesc                 C   s
   t ||S rs   r   r   r"   r"   r#   ry   #  s    zTestSphericalKnDerivatives.fc                 C   s   t ||ddS r   r   r   r"   r"   r#   rt   &  s    zTestSphericalKnDerivatives.dfNr   r"   r"   r"   r#   r   "  s   r   c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )TestSphericalOldc                 C   s   t d}d}td||d d< td||d d< td|dd|d d< td|dd|d d< |d d }|d d d|d d   }t|d t dd	gd
 t|d ||gd
 d S )N)r   r   皙?r   r'   Tr         $@gA\?gc"?r)   )r   emptyr   r   r   )r    Zi1nr!   Zinp0Zinp1r"   r"   r#   test_sph_in.  s    
zTestSphericalOld.test_sph_inc                 C   s   d}t d}td||d< td|dd|d< t t || t || t ||d   g}tt| | t d}td||d< td|dd|d< t dt	 t
|  | d	t	 t
|  d| d|d    g}tt| | d S )
Ng      ?)r   r   Tr   r'   r   r   g      )r   r   r   r   r   r	   r   r   r   r   r
   )r    r!   Zsph_i0Zsph_i0_expectedZsph_k0Zsph_k0_expectedr"   r"   r#   test_sph_in_kn_order0>  s    

$z&TestSphericalOld.test_sph_in_kn_order0c                 C   s   t d}d}td||d d< td||d d< td||d d< td|dd|d d< td|dd|d d< td|dd|d d< |d d  }|d d d|d d   }|d d d	|d d   }t|d g d
d t|d |||gd d S )Nr   r   r   r   r'   r   Tr   r   r}   )gkG~?gk?g)qe?r)   )r   r   r   r   )r    s1r!   Zs10Zs11Zs12r"   r"   r#   test_sph_jnN  s    
zTestSphericalOld.test_sph_jnc                 C   s   t d}d}td||d d< td||d d< td||d d< td|dd|d d< td|dd|d d< td|dd|d d< |d d  }|d d  d|d d   }|d d  d	|d d   }t|d g d
d t|d |||gd d S )Nr   r   r   r'   r   Tr   r   r}   )gDT@g3̱wJC@g-uAI@r)   	   )r   r   r   r   )r    knr!   Zkn0Zkn1Zkn2r"   r"   r#   test_sph_kna  s    
zTestSphericalOld.test_sph_knc                 C   sf   t dd}t dd}t|dd t|dd t dddt dd  d }t ddd	d
}t||d d S )Nr   r   r   g[_$ewrB   g&$r   r'   Tr      )r   r   )r    Zsy1Zsy2ZsphpyZsy3r"   r"   r#   test_sph_ynt  s    

zTestSphericalOld.test_sph_ynN)rF   rG   rH   r   r   r   r   r   r"   r"   r"   r#   r   *  s
   r   )#numpyr   Znumpy.testingr   r   r   r   r   r   r   r   r	   r
   r   r   r   r   Zscipy.specialr   r   r   r   Zscipy.integrater   r   rI   rV   r`   ri   rr   r   r   r   r   r   r"   r"   r"   r#   <module>   s    ,96.1