a
    ¬ˆcN‚  ã                   @   sš   d dl Z d dlZd dlZd dlmZmZmZmZm	Z	 d dlm
Z d dlmZmZ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dS )é    N)Úassert_allcloseÚassert_equalÚassert_warnsÚassert_array_almost_equalÚassert_array_equal)Úraises)ÚRegularGridInterpolatorÚinterpnÚRectBivariateSplineÚNearestNDInterpolatorÚLinearNDInterpolatorÚCloughTocher2DInterpolator)Úmatrixc                   @   sZ  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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/d0„ Zd1d2„ Zej d3d4ej ej!g¡ej d5d6d7g¡d8d9„ ƒƒZ"ej d5d7d6g¡d:d;„ ƒZ#ej d5d7d6g¡d<d=„ ƒZ$d>d?„ Z%d@dA„ Z&dBdC„ Z'dDdE„ Z(d4S )FÚTestRegularGridInterpolatorc                 C   s¤   dgd }t  g d¢¡}|d d …t jt jt jf }|t jd d …t jt jf }|t jt jd d …t jf }|t jt jt jd d …f }||d  |d  |d  }||fS )N©ç        ç      à?ç      ð?é   é
   éd   éè  ©ÚnpÚasarrayÚnewaxis©ÚselfÚpointsÚvaluesÚvalues0Úvalues1Zvalues2Zvalues3© r"   úc/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/scipy/interpolate/tests/test_rgi.pyÚ_get_sample_4d   s    
z*TestRegularGridInterpolator._get_sample_4dc                 C   s®   dgd dgd  }t  g d¢¡}|d d …t jt jt jf }|t jd d …t jt jf }|t jt jd d …t jf }|t jt jt jd d …f }||d  |d  |d  }||fS ©Nr   é   )r   ç      @ç      $@r   r   r   r   r   r"   r"   r#   Ú_get_sample_4d_2   s    z,TestRegularGridInterpolator._get_sample_4d_2c                 C   s¤   dgd }t  g d¢¡}|d d …t jt jt jf }|t jd d …t jt jf }|t jt jd d …t jf }|t jt jt jd d …f }||d  |d  |d  }||fS )N)r   r   r   ç      ø?ç       @g      @ç      @r   r   r   r   r   r   r"   r"   r#   Ú_get_sample_4d_3)   s    
z,TestRegularGridInterpolator._get_sample_4d_3c                 C   s¤   dgd }t  ddg¡}|d d …t jt jt jf }|t jd d …t jt jf }|t jt jd d …t jf }|t jt jt jd d …f }||d  |d  |d  }||fS )N)r   r   r   r   r   r   r   r   r   r   r"   r"   r#   Ú_get_sample_4d_44   s    
z,TestRegularGridInterpolator._get_sample_4d_4c                 C   st   |   ¡ \}}t g d¢g d¢g d¢g¡}dD ]B}t|| ¡ |d�}|| ¡ ƒ}t|||d�}||ƒ}t||ƒ q,d S )N©çš™™™™™¹?r0   r   çÍÌÌÌÌÌì?©çš™™™™™É?r0   gÍÌÌÌÌÌÜ?gš™™™™™é?©r   r   r   r   ©ÚlinearÚnearestÚslinearÚcubicÚquintic©Úmethod)r-   r   r   r   Útolistr   )r   r   r   Úsampler<   ÚinterpÚv1Úv2r"   r"   r#   Útest_list_input?   s     ÿþþz+TestRegularGridInterpolator.test_list_inputc              	   C   sÄ   |   ¡ \}}d}dD ]@}tjt|d�� t|||d� W d   ƒ q1 sJ0    Y  qt||ƒ}t g d¢g d¢g d¢g¡}dD ]>}tjt|d�� |||d� W d   ƒ q€1 s´0    Y  q€d S )Nzpoints in dimension)r9   r:   ©Úmatchr;   r/   r2   r4   )r.   Úpytestr   Ú
ValueErrorr   r   r   )r   r   r   rD   r<   r?   r>   r"   r"   r#   Útest_spline_dim_errorP   s    .
ÿz1TestRegularGridInterpolator.test_spline_dim_errorc                 C   s:   |   ¡ \}}t g d¢g d¢g d¢g¡}|  |||¡ d S )Nr/   r2   r4   )r$   r   r   Ú _assert_linear_and_slinear_close©r   r   r   r>   r"   r"   r#   Útest_linear_and_slinear_close_1a   s
    ÿz;TestRegularGridInterpolator.test_linear_and_slinear_close_1c                 C   s,   |   ¡ \}}t g d¢¡}|  |||¡ d S )N©r0   r0   r(   ç      "@)r)   r   r   rH   rI   r"   r"   r#   Útest_linear_and_slinear_close_2g   s    z;TestRegularGridInterpolator.test_linear_and_slinear_close_2c                 C   s:   t ||dd�}||ƒ}t ||dd�}||ƒ}t||ƒ d S )Nr6   r;   r8   )r   r   )r   r   r>   r   r?   r@   rA   r"   r"   r#   rH   l   s
    z<TestRegularGridInterpolator._assert_linear_and_slinear_closec           
      C   s–   |   ¡ \}}|d|  }t g d¢g d¢g d¢g¡}dD ]X}t|||d�}t||j|d�}t||j|d�}||ƒ}||ƒd||ƒ  }	t||	ƒ q8d S )Nù               @r/   r2   r4   r5   r;   ù              ð?)r-   r   r   r   ÚrealÚimagr   )
r   r   r   r>   r<   r?   ZrinterpZiinterpr@   rA   r"   r"   r#   Útest_complexs   s$    ÿÿÿÿz(TestRegularGridInterpolator.test_complexc                 C   s:   |   ¡ \}}t||ƒ}t g d¢¡}d}t||ƒ|ƒ d S )NrK   çÍÌÌÌÌH�@©r)   r   r   r   r   ©r   r   r   r?   r>   Úwantedr"   r"   r#   Útest_linear_xi1d…   s
    
z,TestRegularGridInterpolator.test_linear_xi1dc                 C   sR   |   ¡ \}}t||ƒ}t g d¢g d¢g d¢g¡}t g d¢¡}t||ƒ|ƒ d S )Nr/   r2   r4   ©rS   gš™™™™qŠ@g     \�@©r$   r   r   r   r   rU   r"   r"   r#   Útest_linear_xi3dŒ   s    
ÿz,TestRegularGridInterpolator.test_linear_xi3dc                 C   s¾   |   ¡ \}}t||dd�}t g d¢¡}d}t||ƒ|ƒ t g d¢¡}d}t||ƒ|ƒ t g d¢¡}d}t||ƒ|ƒ t g d¢¡}d	}t||ƒ|ƒ t g d
¢¡}d}t||ƒ|ƒ d S )Nr7   r;   )r0   r0   r1   r1   g     0‘@)r0   r0   r0   r0   r   ©r   r   r   r   ©r   r   r   r   ç     \‘@)r0   çš™™™™™Ù?g333333ã?r1   g     |�@rY   rU   r"   r"   r#   Útest_nearest”   s"    z(TestRegularGridInterpolator.test_nearestc                 C   sL   |   ¡ \}}t||ƒ}t g d¢g d¢g¡}t ddg¡}t||ƒ|ƒ d S )Nr[   r\   r   r]   rY   rU   r"   r"   r#   Útest_linear_edges§   s
    
z-TestRegularGridInterpolator.test_linear_edgesc                 C   s´   ddg}t  g d¢¡}|d d …t jf }|t jd d …f }||d  }ttt||ƒ ddg}ttt||ƒ ddg}ttt||ƒ g d¢}ttt||ƒ ddg}ttt||dd� d S )	Nr   )r   r   r   r   )r   )r   r   g      è?r   )r   r   r   Úundefmethodr;   )r   r   r   Úassert_raisesrF   r   )r   r   r   r    r!   r"   r"   r#   Útest_valid_create®   s     
ÿz-TestRegularGridInterpolator.test_valid_createc                 C   s‚   |   ¡ \}}t||ƒ}t g d¢g d¢g¡}tt||dƒ t g d¢g d¢g¡}tt||ƒ t g d¢g d¢g¡}tt||ƒ d S )Nr[   r\   ra   )r   r   r   )r   r   r   )r   r   r   çš™™™™™ñ?)r$   r   r   r   rb   rF   )r   r   r   r?   r>   r"   r"   r#   Útest_valid_callÀ   s    
z+TestRegularGridInterpolator.test_valid_callc                 C   s‚   |   ¡ \}}t||dd d�}t g d¢g d¢g d¢g d¢g¡}t g d¢¡}t||dd	�|ƒ t g d
¢¡}t||dd	�|ƒ d S )NF©Úbounds_errorÚ
fill_value©çš™™™™™¹¿rj   rj   rj   ©rd   rd   rd   rd   ©é   çÍÌÌÌÌÌ @çš™™™™™ñ¿iõÿÿÿ©rn   rn   ro   ro   )r   r]   ç      &@rq   r7   r;   )gfffffÆ[Àgfffff“@g     žÅÀgš™™™™‹’Àr6   rY   rU   r"   r"   r#   Útest_out_of_bounds_extrapÊ   s    ÿÿz5TestRegularGridInterpolator.test_out_of_bounds_extrapc                 C   s‚   |   ¡ \}}t||dd d�}t g d¢g d¢g d¢g d¢g¡}t g d¢¡}t||dd	�|ƒ t g d
¢¡}t||dd	�|ƒ d S )NFrf   ri   rk   rl   rp   )r   rq   rq   rq   r7   r;   )g333333(Àg33333£`@g     ´�Àgš™™™™yXÀr6   rT   rU   r"   r"   r#   Útest_out_of_bounds_extrap2Õ   s    ÿÿz6TestRegularGridInterpolator.test_out_of_bounds_extrap2c                 C   s°   |   ¡ \}}t||dtjd�}t g d¢g d¢g d¢g¡}t tjtjtjg¡}t||dd�|ƒ t||dd�|ƒ t g d	¢g d
¢g d¢g¡}t g d¢¡}t||ƒ|ƒ d S )NFrf   ri   rk   rp   r7   r;   r6   r/   r2   r4   rX   )r$   r   r   Únanr   r   rU   r"   r"   r#   Útest_out_of_bounds_fillà   s    ÿÿÿz3TestRegularGridInterpolator.test_out_of_bounds_fillc                 C   s‚   |   ¡ \}}t||dd�}tj|Ž }dd„ |D ƒ}t |¡}| d¡}t||ƒ}t g d¢g d¢g d¢g¡}t||ƒ||ƒƒ d S )	Nr7   r;   c                 S   s   g | ]}|‘qS r"   r"   ©Ú.0Úpr"   r"   r#   Ú
<listcomp>ò   ó    zJTestRegularGridInterpolator.test_nearest_compare_qhull.<locals>.<listcomp>éÿÿÿÿr/   r2   r4   )	r$   r   Ú	itertoolsÚproductr   r   Úreshaper   r   ©r   r   r   r?   Zpoints_qhullZvalues_qhullZinterp_qhullr>   r"   r"   r#   Útest_nearest_compare_qhullî   s    



ÿz6TestRegularGridInterpolator.test_nearest_compare_qhullc                 C   s~   |   ¡ \}}t||ƒ}tj|Ž }dd„ |D ƒ}t |¡}| d¡}t||ƒ}t g d¢g d¢g d¢g¡}t||ƒ||ƒƒ d S )Nc                 S   s   g | ]}|‘qS r"   r"   rv   r"   r"   r#   ry   þ   rz   zITestRegularGridInterpolator.test_linear_compare_qhull.<locals>.<listcomp>r{   r/   r2   r4   )	r$   r   r|   r}   r   r   r~   r   r   r   r"   r"   r#   Útest_linear_compare_qhullú   s    




ÿz5TestRegularGridInterpolator.test_linear_compare_qhullc                 C   sz   t  ddd¡}t  ddd¡}tdƒ}dD ]L}t||f||d�}|d	d
gƒ}t||f|j|d�}|d	d
gƒ}t||ƒ q(d S )Nr   r&   é   é   é   ©r‚   r„   ©r7   r6   r;   r^   çffffffæ?)r   ÚlinspaceÚMyValuer   Ú_vr   )r   ÚxÚyr   r<   r?   r@   rA   r"   r"   r#   Útest_duck_typed_values  s    
ÿÿz2TestRegularGridInterpolator.test_duck_typed_valuesc                 C   sb   t j d¡ t  ddd¡}t  ddd¡}t j dd¡}t||f|dd� ttt||f|dd� d S )	NéÒ  r   r&   r‚   rƒ   r„   ©rh   y      ð?       @)r   ÚrandomÚseedrˆ   Úrandr   rb   rF   )r   r‹   rŒ   r   r"   r"   r#   Útest_invalid_fill_value  s    
ÿz3TestRegularGridInterpolator.test_invalid_fill_valuec                 C   s:   t jddd�}dd„ |jD ƒ}t||ƒ t||dd� d S )N©r   é   é   z>f4)Zdtypec                 S   s   g | ]}t  |¡‘qS r"   )r   Úarange)rw   Únr"   r"   r#   ry   &  rz   zCTestRegularGridInterpolator.test_fillvalue_type.<locals>.<listcomp>r   r�   )r   ÚonesÚshaper   )r   r   r   r"   r"   r#   Útest_fillvalue_type#  s    
z/TestRegularGridInterpolator.test_fillvalue_typec                 C   sP  dd„ }t  ddd¡}t  ddd¡}|t j||ddd�Ž }t||f|dd	d
d�}t|t  ddgddgddgg¡ƒg d¢dd� t|t  ddgddgddgg¡ƒg d¢dd� t|t  ddg¡ƒ|jdd� d |_t|ddgddggƒddgdd� t|ddgddggƒddgdd� t||f|dd	d d�}t|ddgddggƒd d!gdd� d S )"Nc                 S   s   | | S ©Nr"   ©r‹   rŒ   r"   r"   r#   Úf/  s    z;TestRegularGridInterpolator.test_length_one_axis.<locals>.frƒ   r   ÚijT©ZindexingÚsparser6   Fée   ©r<   rg   rh   r‚   )r&   é   é   ç›+¡†›„=©Zatolgffffffö?ç333333@)ç333333@ç333333@r¥   rd   r©   ç333333Ó?g      '@gÍÌÌÌÌÌô?g      )@çVçž¯Ò<r*   gffffffþ?r7   gÍÌÌÌÌÌü?éüÿÿÿgffffff@é   r¤   )r   rˆ   Úmeshgridr   r   Úarrayrh   )r   rž   r‹   rŒ   Údatar?   r"   r"   r#   Útest_length_one_axis+  sB    ÿ þ þþÿÿÿþz0TestRegularGridInterpolator.test_length_one_axisrh   Nr<   r6   r7   c                 C   sò   |d|dœ}t  ddt j d¡}t  |¡}t|f|d d … fi |¤Ž}t|dgf|d d …d f fi |¤Ž}t  ddt j d d¡}||ƒ}	t  d¡}
|t  ||
g¡jƒ}t||	ƒ t  	d¡}
|t  ||
g¡jƒ}|d u rät||	ƒ n
t||ƒ d S )	NF©rh   rg   r<   r   r&   r•   r{   rƒ   r   )
r   rˆ   ÚpiÚsinr   ÚzerosÚvstackÚTr   r™   )r   rh   r<   Úoptionsr‹   ÚzÚfaZfbZx1aZzaZy1bZzbr"   r"   r#   Útest_length_one_axis2V  s"    ÿ
$


z1TestRegularGridInterpolator.test_length_one_axis2c                 C   sÊ   t g d¢fg d¢dd|d�}t |tjgƒ¡s2J ‚tj d¡}|jdd�d	 }|jdd�d
k}tj||< tjdd�� ||ƒ}W d   ƒ n1 s’0    Y  t|| tjƒ t||  |||  ƒƒ d S )N)rƒ   r&   r®   r”   rƒ   Fr³   ì   l¿J r   ©Úsizer   r   Úignore©Úinvalid)r   r   Úisnanrt   r�   Údefault_rngÚerrstater   )r   r<   rž   Úrngr‹   ÚiÚresr"   r"   r#   Útest_nan_x_1dr  s    ÿ
&z)TestRegularGridInterpolator.test_nan_x_1dc                 C   s   t  g d¢¡t  g d¢¡ }}dd„ }t j||ddd�\}}|||ƒ}t||f||dd	�}t jd
d��& |dt jgddggƒ}	W d   ƒ n1 s’0    Y  t|	d ddd� t  |	d ¡sÀJ ‚t j 	d¡}
|
jdd�d d }|
jdd�d }|
jdd�dk}|
jdd�dk}||B }t j||< t j||< t  ||g¡j
}t jd
d�� ||ƒ}	W d   ƒ n1 �sh0    Y  t|	| t jƒ t|	|  |||  ƒƒ d S )N)r   rƒ   r&   )rƒ   r®   r„   c                 S   s   | d |d  S ©Nr&   r"   r�   r"   r"   r#   rž   Œ  s    z4TestRegularGridInterpolator.test_nan_x_2d.<locals>.frŸ   Tr    F©r<   rg   rÀ   rÁ   r*   rƒ   r&   r¦   r§   r   r½   r   r¾   r   é   r   )r   r°   r¯   r   rÅ   rt   r   rÃ   r�   rÄ   r¸   r   )r   r<   r‹   rŒ   rž   ZxgZygr±   r?   rÈ   rÆ   Úi1Úi2rÇ   rº   r"   r"   r#   Útest_nan_x_2dˆ  s0    

ÿ4

(z)TestRegularGridInterpolator.test_nan_x_2dc                 C   s  t j d¡ t j d¡}t j d¡}t  ||¡}t  t|ƒt|ƒ¡}t  t|ƒt|ƒ¡}t  ||¡\}}t  | 	¡ | 	¡ f¡j
}tttfD ]Ž}|tt||ƒƒ|ƒ}||ƒ}	|||fƒ}
||dfƒ}|||ƒ}||dƒ}t|	j|
j  k�o|j  k�o|j  k�o|jkn  dƒ qŠd S )Nr   r   r   T)r   r�   r‘   Úhypotrˆ   ÚminÚmaxr¯   r·   Úravelr¸   r   r   r   ÚlistÚzipr   r¿   )r   r‹   rŒ   rº   ÚXÚYÚXYÚinterpolatorr?   Zinterp_points0Zinterp_points1Zinterp_points2Zinterp_points3Zinterp_points4r"   r"   r#   Útest_broadcastable_input­  s8    ÿ

ÿ
þ
ý
üüz4TestRegularGridInterpolator.test_broadcastable_inputc                 C   sœ   t j d¡ t j d¡}|d d …df |d d …df  }}t  ||¡}t j d¡}|jdd� |jdd� |jdd� tttfD ]}|||ƒ}||ƒ q€d S )Nr   )r   r&   rƒ   )é2   r&   F)Úwrite)r   r�   r‘   rÐ   Zsetflagsr   r   r   )r   Zxyr‹   rŒ   rº   rØ   rÙ   r?   r"   r"   r#   Útest_read_onlyÌ  s    "ÿ
z*TestRegularGridInterpolator.test_read_onlyc                 C   sä   dd„ }t  ddd¡}t  ddd¡}t  ddd	¡}|||f}|t j|d
ddœŽŽ }t||ƒ}t  g d¢g d¢g¡}||ƒ}	|d d d… }
|d d d… }|d d d… }|
||f}|t j|d
ddœŽŽ }t||ƒ}||ƒ}t|	|ƒ d S )Nc                 S   s   d| d  d|d   | S ©Nr&   r®   r"   )r‹   rŒ   rº   r"   r"   r#   Úval_func_3dà  s    zGTestRegularGridInterpolator.test_descending_points.<locals>.val_func_3drƒ   r   r¥   r„   é   é	   é!   rŸ   Tr    )rn   gÍÌÌÌÌÌ@gš™™™™™ @)çffffff
@gÍÌÌÌÌÌ@gffffff@r{   )r   rˆ   r¯   r   r°   r   )r   rß   r‹   rŒ   rº   r   r   Zmy_interpolating_functionÚptsÚcorrect_resultZx_descendingZy_descendingZz_descendingÚpoints_shuffledÚvalues_shuffledÚtest_resultr"   r"   r#   Útest_descending_pointsß  s2    
ÿÿ
ÿÿz2TestRegularGridInterpolator.test_descending_pointsc                 C   s‚   dd„ }t  g d¢¡}t  g d¢¡}||f}|t j|dddœŽŽ }d}tjt|d	�� t||ƒ W d   ƒ n1 st0    Y  d S )
Nc                 S   s   d| d  d|d   S rÞ   r"   r�   r"   r"   r#   Úval_func_2dü  s    zJTestRegularGridInterpolator.test_invalid_points_order.<locals>.val_func_2d©r   r+   r   ç      @ç      @©r   r+   r,   rì   rí   rŸ   Tr    ú(must be strictly ascending or descendingrC   )r   r°   r¯   rE   r   rF   r   )r   rê   r‹   rŒ   r   r   rD   r"   r"   r#   Útest_invalid_points_orderû  s    
ÿ
z5TestRegularGridInterpolator.test_invalid_points_order))Ú__name__Ú
__module__Ú__qualname__r$   r)   r-   r.   rB   rG   rJ   rM   rH   rR   rW   rZ   r_   r`   rc   re   rr   rs   ru   r€   r�   r�   r“   r›   r²   rE   ÚmarkZparametrizer   rt   r´   r¼   rÉ   rÏ   rÚ   rÝ   ré   rð   r"   r"   r"   r#   r      sH   
+

$r   c                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )r‰   z"
    Minimal indexable object
    c                 C   s(   d| _ || _t t |¡¡ |¡| _d S rÊ   )Úndimrš   r   r—   Úprodr~   rŠ   )r   rš   r"   r"   r#   Ú__init__  s    zMyValue.__init__c                 C   s
   | j | S rœ   )rŠ   )r   Úidxr"   r"   r#   Ú__getitem__  s    zMyValue.__getitem__c                 C   s   d S rœ   r"   ©r   r"   r"   r#   Ú__array_interface__  s    zMyValue.__array_interface__c                 C   s   t dƒ‚d S )NzNo array representation)ÚRuntimeErrorrú   r"   r"   r#   Ú	__array__  s    zMyValue.__array__N)rñ   rò   ró   Ú__doc__r÷   rù   rû   rý   r"   r"   r"   r#   r‰   	  s
   r‰   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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 )*ÚTestInterpNc                 C   sf   t  dd¡}t  g d¢¡}t  dd¡}t  g d¢¡}t  g d¢g d¢g d¢g d¢g d¢g¡}|||fS )Nrƒ   r¤   rî   ©rƒ   r&   rƒ   r&   rƒ   ©rƒ   r&   r®   r&   rƒ   ©rƒ   r&   r&   r&   rƒ   )r   r—   r°   )r   r‹   rŒ   rº   r"   r"   r#   Ú_sample_2d_data  s    ÿzTestInterpN._sample_2d_datac                 C   sp   |   ¡ \}}}t|||ƒ}t g d¢g d¢g¡j}tt||f||dd�| |d d …df |d d …df ¡ƒ d S )N©rƒ   çffffff@r¨   r   rã   ç333333ó?r®   ©rƒ   rã   r  rì   r'   r   r®   Ú	splinef2dr;   r   rƒ   )r  r
   r   r°   r¸   r   r	   Úev)r   r‹   rŒ   rº   ÚlutÚxir"   r"   r#   Útest_spline_2d'  s    
ÿ"ÿzTestInterpN.test_spline_2dc                 C   sz   |   ¡ \}}}t g d¢g d¢g¡j}dD ]J}t||f|||d�}t| ¡ | ¡ f| ¡ | ¡ |d�}t|||d� q*d S )Nr  r  ©r7   r6   r  r;   ©Úerr_msg)r  r   r°   r¸   r	   r=   r   )r   r‹   rŒ   rº   r  r<   r@   rA   r"   r"   r#   rB   0  s    
ÿÿzTestInterpN.test_list_inputc              
   C   sÚ   t  g d¢¡}t  g d¢¡}t  g d¢g d¢g d¢g d¢g d¢g¡}t|||ƒ}t  g d¢g d¢g¡j}t||f||ddd	d
�}| |d d …df |d d …df ¡}d	|dd…< t||ƒ ttt||f||ddd d
� d S )Nrî   r   r  r  ©rƒ   r  rª   r   rã   r  r®   ©rƒ   rã   r  g      Àr'   r   r®   r  FçR¸…ë?�@r£   r   rƒ   r&   r   )	r   r°   r
   r¸   r	   r	  r   rb   rF   )r   r‹   rŒ   rº   r
  r  ÚactualÚexpectedr"   r"   r#   Útest_spline_2d_outofbounds;  s$    ÿ
ÿÿ$
ÿz&TestInterpN.test_spline_2d_outofboundsc                 C   s®   dgd dgd  }t  g d¢¡}|d d …t jt jt jf }|t jd d …t jt jf }|t jt jd d …t jf }|t jt jt jd d …f }||d  |d  |d  }||fS r%   r   r   r"   r"   r#   Ú_sample_4d_dataN  s    zTestInterpN._sample_4d_datac                 C   sH   |   ¡ \}}t||ƒ}t g d¢g¡}t|||dd�}t||ƒ|ƒ d S )NrK   r6   r;   ©r  r   r   r   r	   r   ©r   r   r   Z	interp_rgr>   rV   r"   r"   r#   Útest_linear_4dX  s
    
zTestInterpN.test_linear_4dc                 C   sB   |   ¡ \}}t g d¢g¡}d}t|||dddd�}t||ƒ d S )N©r0   rj   g333333$@rL   r  r6   Fr£   ©r  r   r   r	   r   ©r   r   r   r>   rV   r  r"   r"   r#   Útest_4d_linear_outofbounds`  s    
ÿz&TestInterpN.test_4d_linear_outofboundsc                 C   sL   |   ¡ \}}t||dd�}t g d¢g¡}t|||dd�}t||ƒ|ƒ d S )Nr7   r;   rK   r  r  r"   r"   r#   Útest_nearest_4di  s
    zTestInterpN.test_nearest_4dc                 C   sB   |   ¡ \}}t g d¢g¡}d}t|||dddd�}t||ƒ d S )Nr  r  r7   Fr£   r  r  r"   r"   r#   Útest_4d_nearest_outofboundsq  s    
ÿz'TestInterpN.test_4d_nearest_outofboundsc                 C   sT   |   ¡ \}}t g d¢¡}t|||dd�}t|||d d d …f dd�}t||ƒ d S )NrK   F)rg   )r  r   r   r	   r   ©r   r   r   r>   r@   rA   r"   r"   r#   Ú
test_xi_1dz  s
    zTestInterpN.test_xi_1dc                 C   sv   |   ¡ \}}tj d¡ tj ddd¡}t|||ddd�}t|jdƒ t||| d	d¡ddd�}t	|| |j¡ƒ d S )
NrŽ   r&   r®   r   r7   FrË   ©r&   r®   r{   )
r  r   r�   r‘   r’   r	   r   rš   r~   r   r   r"   r"   r#   Ú
test_xi_nd‚  s    
ÿÿzTestInterpN.test_xi_ndc                 C   sÌ   |   ¡ \}}}||f}t ddd¡}t ddd¡}dD ]�}|d d …d f |d d d …f f}t||||dd�}	t|	jdƒ t ||¡\}
}tj|
j 	¡ |j 	¡ f }t||||dd�}t
|	| |	j¡ƒ q6d S )	Nr   rƒ   r&   r®   r  FrË   r"  )r  r   rˆ   r	   r   rš   r¯   Zc_r¸   rÓ   r   r~   )r   r‹   rŒ   r   r   r  Úyir<   r>   r@   ÚxxÚyyrA   r"   r"   r#   Útest_xi_broadcast‘  s      
ÿÿzTestInterpN.test_xi_broadcastc                    s¾   |   ¡ \‰‰tj d¡ tj ddddd¡‰tj ddd¡‰dD ]d‰ tˆˆˆˆ dd	�}t|jd
ˆ d� ‡ ‡‡‡fdd„tdƒD ƒ}t 	|¡ 
ddd¡}t||ˆ d� q@tttˆˆˆdd� d S )NrŽ   r®   r¤   r„   r¥   r   r†   FrË   )r„   r¥   r¤   r  c              	      s&   g | ]}t ˆˆd |f ˆˆ dd�‘qS ).FrË   )r	   )rw   Új©r<   r   r>   r   r"   r#   ry   ³  s   þÿz5TestInterpN.test_nonscalar_values.<locals>.<listcomp>rƒ   r&   r   r  r;   )r  r   r�   r‘   r’   r	   r   rš   Úranger°   Ú	transposer   rb   rF   )r   ÚvÚvsrA   r"   r)  r#   Útest_nonscalar_values¦  s"    
ÿþÿz!TestInterpN.test_nonscalar_valuesc                 C   s¨   |   ¡ \}}}||f}|d|  }t g d¢g d¢g¡j}dD ]N}t||||d�}t||j||d�}t||j||d�}	|d|	  }
t||
ƒ q>ttj	t|||dd� d S )NrN   r  r  )r6   r7   r;   rO   r  )
r  r   r°   r¸   r	   rP   rQ   r   r   ZComplexWarning)r   r‹   rŒ   r   r   r>   r<   r@   Zv2rZv2irA   r"   r"   r#   rR   ¾  s    
ÿÿzTestInterpN.test_complexc                 C   sn   t  ddd¡}t  ddd¡}tdƒ}dD ]@}t||f|dd	g|d
�}t||f|jdd	g|d
�}t||ƒ q(d S )Nr   r&   r‚   rƒ   r„   r…   r†   r^   r‡   r;   )r   rˆ   r‰   r	   rŠ   r   )r   r‹   rŒ   r   r<   r@   rA   r"   r"   r#   r�   Ñ  s    z"TestInterpN.test_duck_typed_valuesc                 C   s„   t  ddd¡}t  ddd¡}tt j dd¡ƒ}t j ddd¡}dD ]<}t||f|||d�}t||ft  |¡||d�}t||ƒ qBd S )	Nr   r&   r‚   rƒ   r„   r®   r  r;   )r   rˆ   r   r�   r’   r	   r   r   )r   r‹   rŒ   r   r>   r<   r@   rA   r"   r"   r#   Útest_matrix_inputÜ  s    zTestInterpN.test_matrix_inputc                 C   s¢   t  g d¢g¡}t  ddgddgddgg¡}tdgg d¢f||ƒ}g d¢}t||dd	� t  d
dgddgddgg¡}tdgg d¢f||dd d�}t||dd	� d S )N)r0   rƒ   r   rƒ   gš™™™™™@gš™™™™™	@gffffff@)r&   r®   r   )gìQ¸…ëÑ?gffffff@gffffff @r¬   r§   rd   r*   gffffffÀFrf   )r   r°   r	   r   )r   r   r  rÈ   rV   r"   r"   r#   r²   é  s    ÿz TestInterpN.test_length_one_axisc              	   C   s  dd„ }t  g d¢¡}t  g d¢¡}t  g d¢¡}t  g d¢¡}||||f}|t j|dddœŽŽ }d	d
t  t  ddd¡¡t  dd
d¡f}t|||ƒ}	|d d d… }
|d d d… }|d d d… }|d d d… }|
|||f}|t j|dddœŽŽ }t|||ƒ}t|	|ƒ d S )Nc                 S   s    d| d  d|d   | | S rÞ   r"   )r‹   rŒ   rº   Úar"   r"   r#   Úvalue_func_4d   s    z9TestInterpN.test_descending_points.<locals>.value_func_4d)r   rƒ   r&   r®   )r   r   r•   r–   )r   r0   r3   r«   rŸ   Tr    r0   r«   r   r–   r   r{   )r   r°   r¯   r+  rˆ   r	   r   )r   r1  Úx1Zx2Zx3Zx4r   r   rä   rå   Z
x1_descendZ
x2_descendZ
x3_descendZ
x4_descendræ   rç   rè   r"   r"   r#   ré   ÿ  s.    ÿÿÿz"TestInterpN.test_descending_pointsc                 C   s¢   t  g d¢¡}t  g d¢¡}t  g d¢g d¢g d¢g d¢g d¢g¡}t  g d¢g d¢g¡j}d}tjt|d	��  t||f||ƒ W d   ƒ n1 s”0    Y  d S )
Nrë   rî   r   r  r  r  r  rï   rC   )r   r°   r¸   rE   r   rF   r	   )r   r‹   rŒ   rº   r  rD   r"   r"   r#   rð     s    ÿ
ÿz%TestInterpN.test_invalid_points_orderc                 C   sX   dg}ddg}t  d¡}d}tt|d�� t|||ƒ W d   ƒ n1 sJ0    Y  d S )N)r   rƒ   r   rƒ   )rƒ   rƒ   r®   zaThe requested sample points xi have dimension 3, but this RegularGridInterpolator has dimension 1rC   )r   r™   rb   rF   r	   )r   r   r   r  Úmsgr"   r"   r#   Útest_invalid_xi_dimensions%  s    
z&TestInterpN.test_invalid_xi_dimensionsN)rñ   rò   ró   r  r  rB   r  r  r  r  r  r  r!  r#  r'  r.  rR   r�   r/  r²   ré   rð   r4  r"   r"   r"   r#   rÿ     s(   		
		rÿ   )r|   rE   Únumpyr   Znumpy.testingr   r   r   r   r   r   rb   Zscipy.interpolater   r	   r
   r   r   r   Zscipy.sparse._sputilsr   r   r‰   rÿ   r"   r"   r"   r#   Ú<module>   s       z