o
    gW                     @   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 d dlmZ ejdg d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)matrixmethod)linearnearestslinearcubicquinticpchipc                   @   sJ  e Zd Zdd Zdd Zdd Zdd Zed	d
 Ze	j
dg ddd Ze	j
deeg dg dg dgfeeg dfgdd Zedd Zdd Zdd Zdd Ze	j
deg dd feg d!d"feg d#d"feg d$d%feg d&d'fgd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Ze	j
dd:d;gd<d= Zd>d? Zd@dA ZdBdC Z e	j
dDdEej!ej"ge	j
dd;d:gdFdG Z#e	j
dd:d;gdHdI Z$e	j
dd:d;gdJdK Z%edLdM Z&dNdO Z'edPdQ Z(edRdS Z)ee	j
dTdUdVgdWdX Z*dYdZ Z+dES )[TestRegularGridInterpolatorc                 C      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values1values2values3 r+   ^/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/scipy/interpolate/tests/test_rgi.py_get_sample_4d      
z*TestRegularGridInterpolator._get_sample_4dc                 C      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   r   )Nr   r   r         ?       @      @      @r   r   r   r   r   r#   r+   r+   r,   _get_sample_4d_3+   r.   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_46   r.   z,TestRegularGridInterpolator._get_sample_4d_4c                 C   sj   |   \}}tg dg dg dg}t|| |d}|| }t|||d}||}t|| d S )N皙?r=   r   ?皙?r=   g?g?r   r   r   r   r   )r:   r    r!   r   tolistr   )r$   r   r%   r&   sampleinterpv1v2r+   r+   r,   test_list_inputA   s   z+TestRegularGridInterpolator.test_list_inputr   )r   r   r   c                 C   s   |   \}}d}tjt|d t|||d W d    n1 s!w   Y  t||}tg dg dg dg}tjt|d |||d W d    d S 1 sRw   Y  d S )Nzpoints in dimensionmatchrB   r<   r?   rA   )r;   pytestr   
ValueErrorr   r    r!   )r$   r   r%   r&   rJ   rE   rD   r+   r+   r,   test_spline_dim_errorR   s   
"z1TestRegularGridInterpolator.test_spline_dim_errorzpoints_values, sampler<   r?   rA   r=   r=   r3         "@c                 C   sF   || \}}t ||dd}||}t ||dd}||}t|| d S )Nr   rB   r   )r   r   )r$   points_valuesrD   r%   r&   rE   rF   rG   r+   r+   r,   test_linear_and_slinear_closeb   s   z9TestRegularGridInterpolator.test_linear_and_slinear_closec           
      C   s   |   \}}|d|  }tg dg dg dg}t|||d}t||j|d}t||j|d}||}||d||  }	t||	 d S )N               @r<   r?   rA   rB                 ?)r:   r    r!   r   realimagr   )
r$   r   r%   r&   rD   rE   rinterpiinterprF   rG   r+   r+   r,   test_complexx   s   z(TestRegularGridInterpolator.test_complexc           
      C   s   g dg d}}t j||dd\}}dd ||}t||f|dd}t||f|dd}|d	d
g}|d	d
g}	t j||	dddrCJ d S )N)   r1      r   ij)indexingc                 S   s   | d |d  S )Nr   r+   xyr+   r+   r,   <lambda>       zATestRegularGridInterpolator.test_cubic_vs_pchip.<locals>.<lambda>r   rB   r   r6   r1   +=r   )atolrtol)r    meshgridr   allclose)
r$   r^   r_   xgygr&   r   r   
vals_cubic
vals_pchipr+   r+   r,   test_cubic_vs_pchip   s   z/TestRegularGridInterpolator.test_cubic_vs_pchipc                 C   s:   |   \}}t||}tg d}d}t||| d S )NrN   H@r4   r   r    r!   r   r$   r%   r&   rE   rD   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<   r?   rA   rl   gq@g     \@r-   r   r    r!   r   rn   r+   r+   r,   test_linear_xi3d   s   
z,TestRegularGridInterpolator.test_linear_xi3dzsample, wanted)r=   r=   r>   r>   g     0@)r=   r=   r=   r=   r   r   r   r   r   r   r   r   r        \@)r=   皙?g333333?r>   g     |@c                 C   s,   |   \}}t||dd}t||| d S )Nr   rB   )r-   r   r   )r$   rD   ro   r%   r&   rE   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 )Nrt   ru   r   rv   rr   rn   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   undefmethodrB   )r    r!   r"   assert_raisesrL   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 )Nrt   ru   rz   )r   r   r   )r   r   r   )r   r   r   皙?)r-   r   r    r!   r{   rL   )r$   r%   r&   rE   rD   r+   r+   r,   test_valid_call   s   
z+TestRegularGridInterpolator.test_valid_callc                 C      |   \}}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皙r   r   r   r}   r}   r}   r}       @皙ir   r   r   r   )r   rv         &@r   r   rB   )gfffff[gfffff@g     gr   rr   rn   r+   r+   r,   test_out_of_bounds_extrap      z5TestRegularGridInterpolator.test_out_of_bounds_extrapc                 C   r   )NFr   r   r   r   r   )r   r   r   r   r   rB   )g333333(g33333`@g     gyXr   rm   rn   r+   r+   r,   test_out_of_bounds_extrap2   r   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 )NFr   r   r   r   r   rB   r   r<   r?   rA   rq   )r-   r   r    nanr!   r   rn   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 )	Nr   rB   c                 S      g | ]}|qS r+   r+   .0pr+   r+   r,   
<listcomp>   ra   zJTestRegularGridInterpolator.test_nearest_compare_qhull.<locals>.<listcomp>r<   r?   rA   )	r-   r   	itertoolsproductr    r!   reshaper   r   r$   r%   r&   rE   points_qhullvalues_qhullinterp_qhullrD   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   r   r+   r+   r   r+   r+   r,   r     ra   zITestRegularGridInterpolator.test_linear_compare_qhull.<locals>.<listcomp>r   r<   r?   rA   )	r-   r   r   r   r    r!   r   r   r   r   r+   r+   r,   test_linear_compare_qhull  s   




z5TestRegularGridInterpolator.test_linear_compare_qhullr   r   c                 C   sp   t ddd}t ddd}td}t||f||d}|dd	g}t||f|j|d}|dd	g}t|| d S )
Nr   r1      rY      r   r   rB   rw   ffffff?)r    linspaceMyValuer   _vr   )r$   r   r^   r_   r&   rE   rF   rG   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   r1   r   rY   r   r   y      ?       @)r    randomseedr   randr   r{   rL   )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)dtypec                 S   s   g | ]}t |qS r+   )r    arange)r   nr+   r+   r,   r   .  s    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,   f7     z;TestRegularGridInterpolator.test_length_one_axis.<locals>.frY   r   r[   Tr\   sparser   Fe   r   r   r   r   )r1         rb   rc   gffffff?333333@)333333@333333@r   r}   r   333333?g      '@g?g      )@V瞯<r6   gffffff?r   g?gffffff@rZ   r   )r    r   re   r   r   arrayr   )r$   r   r^   r_   datarE   r+   r+   r,   test_length_one_axis3  sB     
z0TestRegularGridInterpolator.test_length_one_axisr   Nc                 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 rst||	 d S t|| d S )	NFr   r   r   r   r1   r   r   rY   r   )
r    r   pisinr   zerosvstackTr   r   )r$   r   r   optionsr^   zfafbx1azay1bzbr+   r+   r,   test_length_one_axis2^  s"   
$


z1TestRegularGridInterpolator.test_length_one_axis2c           	      C   s(  t g dfg ddd|d}t|tjgsJ tjd}|jddd	 }|jddd
k}tj||< tjdd ||}W d    n1 sIw   Y  t|| tj t||  |||   g d}dg}td}t ||f|dd|d}t|tjdgsJ t|dtjgsJ d S )N)rY   r1   rZ   r   rY   Fr      lJ r   sizer   r   ignoreinvalid)rZ   rY   )	r   r    isnanr   r   default_rngerrstater   r   )	r$   r   r   rngr^   iresr_   r   r+   r+   r,   test_nan_x_1dz  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 sIw   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 sw   Y  t|	| t j t|	|  |||   d S )N)r   rY   r1   )rY   rZ   r   c                 S   s   | d |d  S Nr1   r+   r]   r+   r+   r,   r     s   z4TestRegularGridInterpolator.test_nan_x_2d.<locals>.fr[   Tr   Fr   r   r   r   r6   rY   r1   rb   r   r   r   r   r   r      r   )r    r   re   r   r   r   r   r   r   r   r   r   )r$   r   r^   r_   r   rg   rh   r   rE   r   r   i1i2r   r   r+   r+   r,   test_nan_x_2d  s4   




z)TestRegularGridInterpolator.test_nan_x_2dc                 C   s   dd }t ddd}t ddd}t ddd	}|||f}|t j|d
dd }t|||d}t g dg dg}	||	}
|d d d }|d d d }|d d d }|||f}|t j|d
dd }t|||d}||	}t|
| d S )Nc                 S   s   d| d  d|d   | S Nr1   rZ   r+   )r^   r_   r   r+   r+   r,   val_func_3d  s   zGTestRegularGridInterpolator.test_descending_points.<locals>.val_func_3drY   r   r   r      	   !   r[   Tr   rB   )r   g@g @)ffffff
@g@gffffff@r   )r    r   re   r   r   r   )r$   r   r   r^   r_   r   r%   r&   my_interpolating_functionptscorrect_resultx_descendingy_descendingz_descendingpoints_shuffledvalues_shuffledtest_resultr+   r+   r,   test_descending_points  s4   

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    d S 1 s;w   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   r7   r         @      @r   r7   r9   r   r   r[   Tr   (must be strictly ascending or descendingrI   )r    r   re   rK   r   rL   r   )r$   r   r^   r_   r%   r&   rJ   r+   r+   r,   test_invalid_points_order  s   

"z5TestRegularGridInterpolator.test_invalid_points_orderc                 C   s6   t tdgtd|dd}t|dgsJ d S )Nr   Fr   r   )r   r    r   r   r   )r$   r   rE   r+   r+   r,   test_fill_value  s   z+TestRegularGridInterpolator.test_fill_valuec                 C   s   dgd dgd  }t jd}|d}|d}t|||dd}||}t|jd	|d
 g }tdD ]}	t||d|	f |dd}||| q4t |	ddd}
t
||
d|d d S )Nr   r   r   r6   r7   r8   r1   r   r2   r3         .@r         9@r   r   r   r   r   r   r   rZ   r   Fr   r   rZ   r   err_msgr   .rY   r   rb   rc   r  )r    r   r   r   r   r   rangeappendr   	transposer   )r$   r   r%   r   r&   rD   rE   vvsjrG   r+   r+   r,   test_nonscalar_values  s,   

z1TestRegularGridInterpolator.test_nonscalar_valuesflip_pointsFTc                 C   s  g d}|rdd |D }t jd}d}|dddd	g|R }|d
}t|||dd}||}	|	jdg|R ks=J t |jdd  }
t|jd D ]!}t|jd D ]}t||d||f |dd}|||
||f< qWqNt j|
dd}t|	|d|d d S )Nr  r5   )r   r2   r3   r  r   r       A@      B@)	r   r2   r3   r  r   r  r  r  /   c                 S   s   g | ]}t t|qS r+   )tuplereversedr   r+   r+   r,   r     s    zGTestRegularGridInterpolator.test_nonscalar_values_2.<locals>.<listcomp>r   rZ   r1   r   r   r   r   r   Fr   rY   r   .r   axisrb   r  	r    r   r   r   r   emptyr  expand_dimsr   )r$   r   r  r%   r   trailing_pointsr&   rD   rE   r  r  r   r  rG   r+   r+   r,   test_nonscalar_values_2	  s.   
z3TestRegularGridInterpolator.test_nonscalar_values_2c                 C   s   d}ddg}t jd}d}|ddg|R }|d}t|||d	d
}||}|jdg|R ks4J t |jdd  }	t|jd D ]!}
t|jd D ]}t||d|
|f |d	d
}|||	|
|f< qNqEt j|	dd}t||d|d d S )Nr   r  r5   r   )rZ   r   r   r   r1   Fr   rY   r  r   .r   r  rb   r  r   )r$   r   r%   r   r#  r&   rD   rE   r  r  r   r  rG   r+   r+   r,   test_nonscalar_values_linear_2D0  s0   
z;TestRegularGridInterpolator.test_nonscalar_values_linear_2D),__name__
__module____qualname__r-   r4   r:   r;   parametrize_rgi_interp_methodsrH   rK   markparametrizerM   r    r!   rQ   rX   rk   rp   rs   rx   ry   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      s    







+

$


%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__T  s   zMyValue.__init__c                 C   s
   | j | S r   )r   )r$   idxr+   r+   r,   __getitem__Y  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)NzNo array representation)RuntimeErrorr1  r+   r+   r,   	__array___  r   zMyValue.__array__N)r&  r'  r(  __doc__r.  r0  r2  r4  r+   r+   r+   r,   r   O  s    r   c                   @   s   e Zd Zdd Zdd Ze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edd Zedd Zedd Zdd Zedd  Zd!d" Zejd#d$d%gd&d' Zed(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2S )3TestInterpNc              	   C   sT   t g d}t g d}t g dg dg dg dg dg dg}|||fS )N)r   r7   r9   r   r   g      @)rY   r1   rY   r1   rY   rY   )rY   r1   rZ   r1   rY   rY   )rY   r1   r1   r1   rY   rY   )r    r   )r$   r^   r_   r   r+   r+   r,   _sample_2d_datad  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rY   ffffff@r   r   r   333333?rZ   rY   r   r:  r   r2   r   rZ   	splinef2drB   r   rY   )r7  r
   r    r   r   r   r	   ev)r$   r^   r_   r   lutxir+   r+   r,   test_spline_2ds  s   
"zTestInterpN.test_spline_2dc                 C   sp   |   \}}}tg dg dgj}t||f|||d}t| | f| | |d}t|||d d S )Nr8  r;  rB   r  )r7  r    r   r   r	   rC   r   )r$   r   r^   r_   r   r?  rF   rG   r+   r+   r,   rH   |  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   rY   r1   rY   r1   rY   rY   r1   rZ   r1   rY   rY   r1   r1   r1   rY   rY   r9  r   r   r   r:  rZ   rY   r   r:  g      r2   r   rZ   r<  FR?@r   r   rY   r1   r   )	r    r   r
   r   r	   r=  r   r{   rL   )r$   r^   r_   r   r>  r?  actualexpectedr+   r+   r,   test_spline_2d_outofbounds  s(   
$

z&TestInterpN.test_spline_2d_outofboundsc                 C   r/   r0   r   r#   r+   r+   r,   _sample_4d_data  s   zTestInterpN._sample_4d_datac                 C   sH   |   \}}t||}tg dg}t|||dd}t||| d S )NrN   r   rB   rJ  r   r    r!   r	   r   r$   r%   r&   	interp_rgrD   ro   r+   r+   r,   test_linear_4d  s
   
zTestInterpN.test_linear_4dc                 C   B   |   \}}tg dg}d}t|||dddd}t|| d S )Nr=   r   g333333$@rO   rF  r   Fr   rJ  r    r!   r	   r   r$   r%   r&   rD   ro   rG  r+   r+   r,   test_4d_linear_outofbounds     
z&TestInterpN.test_4d_linear_outofboundsc                 C   sL   |   \}}t||dd}tg dg}t|||dd}t||| d S )Nr   rB   rN   rK  rL  r+   r+   r,   test_nearest_4d  s
   zTestInterpN.test_nearest_4dc                 C   rO  )NrP  rF  r   Fr   rQ  rR  r+   r+   r,   test_4d_nearest_outofbounds  rT  z'TestInterpN.test_4d_nearest_outofboundsc                 C   sT   |   \}}tg d}t|||dd}t|||d d d f dd}t|| d S )NrN   F)r   )rJ  r    r!   r	   r   r$   r%   r&   rD   rF   rG   r+   r+   r,   
test_xi_1d  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   r1   rZ   r   r   Fr   r1   rZ   r   )
rJ  r    r   r   r   r	   r   r   r   r   rW  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 f |d d d f f}t||||dd}	t|	jd t||\}
}tj|
j	 |j	 f }t||||dd}t
|	||	j d S )Nr   rY   r1   rZ   Fr   rY  )r7  r    r   r	   r   r   re   c_r   ravelr   r   )r$   r   r^   r_   r&   r%   r?  yirD   rF   xxyyrG   r+   r+   r,   test_xi_broadcast  s    zTestInterpN.test_xi_broadcastc                    s   dgd dgd  t jd}|d|dt dd}t|jd	 d
  fddtdD }t |ddd}t	||d d d S )Nr  r1   r  r   r  r	  Fr   r
  r  c              	      s&   g | ]}t d |f  ddqS .Fr   r	   )r   r  r   r%   rD   r&   r+   r,   r     s
    
z5TestInterpN.test_nonscalar_values.<locals>.<listcomp>r   rY   r   rb   r  )
r    r   r   r	   r   r   r  r   r  r   )r$   r   r   r  r  rG   r+   rc  r,   r    s"   


z!TestInterpN.test_nonscalar_valuesc                    s   g dt jd}d}|ddddg|R |dt d	d
}|jdg|R ks1J  fddtjd D }t|t |jd d d S )Nr  r   r  r   r   r   r   r   Fr   rY   c                    s0   g | ]  fd dt jd D qS )c              	      s(   g | ]}t d | f ddqS ra  rb  )r   r   )r  r   r%   rD   r&   r+   r,   r     s    zBTestInterpN.test_nonscalar_values_2.<locals>.<listcomp>.<listcomp>r  )r  r   )r   rc  )r  r,   r     s
    
z7TestInterpN.test_nonscalar_values_2.<locals>.<listcomp>r   rb   r  )	r    r   r   r	   r   r  r   r!   r   )r$   r   r   r#  r  r  r+   rc  r,   r$    s   
z#TestInterpN.test_nonscalar_values_2c                 C   sT   |   \}}tjd tjddddd}tjddd}ttt|||dd d S )	Nr   rZ   r   r   r   r   r<  rB   )rJ  r    r   r   r   r{   rL   r	   )r$   r%   r&   rD   r+   r+   r,    test_non_scalar_values_splinef2d$  s   
z,TestInterpN.test_non_scalar_values_splinef2dc                 C   s   |   \}}}||f}|d|  }tg dg dgj}t||||d}t||j||d}t||j||d}	|d|	  }
t||
 d S )NrR   r8  r;  rB   rS   )r7  r    r   r   r	   rT   rU   r   )r$   r   r^   r_   r&   r%   rD   rF   v2rv2irG   r+   r+   r,   rX   .  s   
zTestInterpN.test_complexc                 C   sz   |   \}}}||f}|d|  }tg dg dgj}ttj t|||dd W d    d S 1 s6w   Y  d S )NrR   r8  r;  r<  rB   )r7  r    r   r   r   ComplexWarningr	   )r$   r^   r_   r&   r%   rD   r+   r+   r,   test_complex_spline2fd=  s   
"z"TestInterpN.test_complex_spline2fdr   r   r   c                 C   sd   t ddd}t ddd}td}t||f|ddg|d	}t||f|jddg|d	}t|| d S )
Nr   r1   r   rY   r   r   rw   r   rB   )r    r   r   r	   r   r   )r$   r   r^   r_   r&   rF   rG   r+   r+   r,   r   H  s   z"TestInterpN.test_duck_typed_valuesc                 C   sz   t ddd}t ddd}tt jdd}t jddd}t||f|||d}t||ft |||d}t|| d S )Nr   r1   r   rY   r   rZ   rB   )r    r   r   r   r   r	   r!   r   )r$   r   r^   r_   r&   rD   rF   rG   r+   r+   r,   test_matrix_inputV  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)r=   rY   r   rY   g@g	@gffffff@)r1   rZ   r   )gQ?gffffff@gffffff @r   r   r}   r6   gffffffFr   )r    r   r	   r   )r$   r&   r?  r   ro   r+   r+   r,   r   c  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_4dz  s    z9TestInterpN.test_descending_points.<locals>.value_func_4d)r   rY   r1   rZ   )r   r   r   r   )r   r=   r@   r   r[   Tr   r=   r   r   r   r   r   )r    r   re   r  r   r	   r   )r$   rk  x1x2x3x4r%   r&   r   r   
x1_descend
x2_descend
x3_descend
x4_descendr   r   r   r+   r+   r,   r   y  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    d S 1 sKw   Y  d S )
Nr   r   rA  rB  rC  rD  rE  r  rI   )r    r   r   rK   r   rL   r	   )r$   r^   r_   r   r?  rJ   r+   r+   r,   r    s   
"z%TestInterpN.test_invalid_points_orderc                 C   sZ   dg}ddg}t d}d}tt|d t||| W d    d S 1 s&w   Y  d S )N)r   rY   r   rY   )rY   rY   rZ   zaThe requested sample points xi have dimension 3, but this RegularGridInterpolator has dimension 1rI   )r    r   r{   rL   r	   )r$   r%   r&   r?  msgr+   r+   r,   test_invalid_xi_dimensions  s   
"z&TestInterpN.test_invalid_xi_dimensionsN)r&  r'  r(  r7  r@  r)  rH   rI  rJ  rN  rS  rU  rV  rX  rZ  r`  r  r$  rd  rX   rh  rK   r*  r+  r   ri  r   r   r  ru  r+   r+   r+   r,   r6  c  sD    	

		







r6  )r   rK   numpyr    numpy.testingr   r   r   r   r   r   r{   scipy.interpolater   r	   r
   r   r   scipy.sparse._sputilsr   r*  r+  r)  r   r   r6  r+   r+   r+   r,   <module>   s"        ?