o
    Eb7                     @   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   N   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#   K/usr/lib/python3/dist-packages/scipy/special/tests/test_spherical_bessel.pytest_spherical_jn_exact      
.z'TestSphericalJn.test_spherical_jn_exactc                 C   N   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   
   z4TestSphericalJn.test_spherical_jn_recurrence_complexc                 C   r'   Nr)   r   r*   r   r.   r/   r#   r#   r$   !test_spherical_jn_recurrence_real   r2   z1TestSphericalJn.test_spherical_jn_recurrence_realc                 C   2   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%      z*TestSphericalJn.test_spherical_jn_inf_realc              	   C   z   d}t t d td td g}t }|td tt||t ddtd g W d    d S 1 s6w   Y  d S Nr+                         ?      ?z%invalid value encountered in multiplyr   )r   r   r   r   filterRuntimeWarningr   r   r!   r0   r"   supr#   r#   r$   test_spherical_jn_inf_complex+      ""z-TestSphericalJn.test_spherical_jn_inf_complexc                 C      t tddd d S )Nr   g%-@g<]3r   r   r!   r#   r#   r$   test_spherical_jn_large_arg_13      z-TestSphericalJn.test_spherical_jn_large_arg_1c                 C   rD   )Nr   i'  g|	 ?rE   rF   r#   r#   r$   test_spherical_jn_large_arg_29   rH   z-TestSphericalJn.test_spherical_jn_large_arg_2c                 C   0   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?      z)TestSphericalJn.test_spherical_jn_at_zeroN)__name__
__module____qualname__r%   r1   r4   r8   rB   rG   rI   rP   r#   r#   r#   r$   r      s    r   c                   @   D   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   r&   z'TestSphericalYn.test_spherical_yn_exactc                 C   r'   r3   r   r   r   r   r/   r#   r#   r$   !test_spherical_yn_recurrence_realP   r2   z1TestSphericalYn.test_spherical_yn_recurrence_realc                 C   r'   r(   rX   r/   r#   r#   r$   $test_spherical_yn_recurrence_complexW   r2   z4TestSphericalYn.test_spherical_yn_recurrence_complexc                 C   r5   r6   )r   r   r   r   r   r/   r#   r#   r$   test_spherical_yn_inf_real^   r9   z*TestSphericalYn.test_spherical_yn_inf_realc              	   C   r:   r;   )r   r   r   r   r>   r?   r   r   r@   r#   r#   r$   test_spherical_yn_inf_complexd   rC   z-TestSphericalYn.test_spherical_yn_inf_complexc                 C   s2   t g d}d}tt||t |jt  d S NrL   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   0   t g d}d}tt||t |jt d S NrL   r<   )r   r   r   r   r^   r_   r   r/   r#   r#   r$   !test_spherical_yn_at_zero_complexr   s   z1TestSphericalYn.test_spherical_yn_at_zero_complexN)
rR   rS   rT   rW   rY   rZ   r[   r\   r`   rc   r#   r#   r#   r$   rV   G   s    rV   c                   @      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*   rM      g?r*   rN   r*   r   r   r   r   r   r   r!   r0   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 )Nrf   rh   r   r   ri   rj   r#   r#   r$   $test_spherical_jn_yn_cross_product_2   s   zBTestSphericalJnYnCrossProduct.test_spherical_jn_yn_cross_product_2N)rR   rS   rT   rm   rn   r#   r#   r#   r$   re   }   s    	re   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   r   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   N   t g d}d}tt|d |t|d | d| d | t||  d S r3   r   r   r   r   r/   r#   r#   r$   !test_spherical_in_recurrence_real   r2   z1TestSphericalIn.test_spherical_in_recurrence_realc                 C   rr   r(   rs   r/   r#   r#   r$   $test_spherical_in_recurrence_complex   r2   z4TestSphericalIn.test_spherical_in_recurrence_complexc                 C   s4   d}t t tg}tt||t t tg d S )NrM   )r   r   r   r   r   r/   r#   r#   r$   test_spherical_in_inf_real       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+   r<   r=   )r   r   r   r   r   r   r/   r#   r#   r$   test_spherical_in_inf_complex   s   "z-TestSphericalIn.test_spherical_in_inf_complexc                 C   rJ   rK   rs   r/   r#   r#   r$   test_spherical_in_at_zero   rQ   z)TestSphericalIn.test_spherical_in_at_zeroN)	rR   rS   rT   rq   rt   ru   rv   rx   ry   r#   r#   r#   r$   ro      s    ro   c                   @   rU   )TestSphericalKnc                 C   sP   t g d}ttd|td t|  d| d|d   d|d     d S rp   )r   r   r   r   r   r
   r    r#   r#   r$   test_spherical_kn_exact   s   
0z'TestSphericalKn.test_spherical_kn_exactc                 C   n   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   
   4 z1TestSphericalKn.test_spherical_kn_recurrence_realc                 C   r|   )Nr)   r-   r   r*   r   r}   r/   r#   r#   r$   $test_spherical_kn_recurrence_complex   r   z4TestSphericalKn.test_spherical_kn_recurrence_complexc                 C   s4   d}t t tg}tt||t t dg d S )NrM   r   )r   r   r   r   r   r/   r#   r#   r$   test_spherical_kn_inf_real   rw   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+   r<   r=   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   ra   r]   )r   r   r   r   r^   r_   r   r/   r#   r#   r$   test_spherical_kn_at_zero      z)TestSphericalKn.test_spherical_kn_at_zeroc                 C   ra   rb   )r   r   r   r   r^   r_   r   r/   r#   r#   r$   !test_spherical_kn_at_zero_complex   r   z1TestSphericalKn.test_spherical_kn_at_zero_complexN)
rR   rS   rT   r{   r~   r   r   r   r   r   r#   r#   r#   r$   rz      s    	rz   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r0   r!   r#   r$   <lambda>   s    zBSphericalDerivativesTestCase.fundamental_theorem.<locals>.<lambda>)Zatol)r   r   f)r!   r0   abZintegralZ	tolerancer#   r   r$   fundamental_theorem   s
   
z0SphericalDerivativesTestCase.fundamental_theoremc                 C      |  ddd d S )Nr   g      @      .@r   rF   r#   r#   r$   test_fundamental_theorem_0      z7SphericalDerivativesTestCase.test_fundamental_theorem_0c                 C   r   )Nr+         ?g333333?r   rF   r#   r#   r$   test_fundamental_theorem_7   r   z7SphericalDerivativesTestCase.test_fundamental_theorem_7N)	rR   rS   rT   r   pytestZmarkZslowr   r   r#   r#   r#   r$   r      s    
r   c                   @   $   e Zd Zdd Zdd Zdd ZdS )TestSphericalJnDerivativesc                 C   
   t ||S r   r   r!   r0   r   r#   r#   r$   r        
zTestSphericalJnDerivatives.fc                 C      t ||ddS NTZ
derivativer   r   r#   r#   r$   r        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!   r0   r#   r#   r$   test_spherical_jn_d_zero  s   z3TestSphericalJnDerivatives.test_spherical_jn_d_zeroN)rR   rS   rT   r   r   r   r#   r#   r#   r$   r          r   c                   @   rd   )TestSphericalYnDerivativesc                 C   r   r   r   r   r#   r#   r$   r     r   zTestSphericalYnDerivatives.fc                 C   r   r   r   r   r#   r#   r$   r     r   zTestSphericalYnDerivatives.dfNrR   rS   rT   r   r   r#   r#   r#   r$   r         r   c                   @   r   )TestSphericalInDerivativesc                 C   r   r   r   r   r#   r#   r$   r     r   zTestSphericalInDerivatives.fc                 C   r   r   r   r   r#   r#   r$   r     r   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   rM   )r   r   r   r   Zzerosr   r#   r#   r$   test_spherical_in_d_zero  s   z3TestSphericalInDerivatives.test_spherical_in_d_zeroN)rR   rS   rT   r   r   r   r#   r#   r#   r$   r     r   r   c                   @   rd   )TestSphericalKnDerivativesc                 C   r   r   r   r   r#   r#   r$   r   #  r   zTestSphericalKnDerivatives.fc                 C   r   r   r   r   r#   r#   r$   r   &  r   zTestSphericalKnDerivatives.dfNr   r#   r#   r#   r$   r   "  r   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[_$ewrM   g&$r   r*   Tr      )r   r   )r!   Zsy1Zsy2ZsphpyZsy3r#   r#   r$   test_sph_ynt  s   

zTestSphericalOld.test_sph_ynN)rR   rS   rT   r   r   r   r   r   r#   r#   r#   r$   r   *  s    r   )#Z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   rV   re   ro   rz   r   r   r   r   r   r   r#   r#   r#   r$   <module>   s"   ,96.1