o
    i                     @   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                   @   s  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e	j
dLdMdNdO fdPdQdO fdRdSdO fdTdUdO fgdVdW Z&dXdY Z'edZd[ Z(ed\d] Z)ee	j
d^d_d`gdadb Z*dcdd Z+e	j
deej,ej-ej.ej/ge	j
dfej,ej-gdgdh Z0dES )i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values1Zvalues2Zvalues3 r)   o/var/www/html/eduruby.in/lip-sync/lip-sync-env/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   )r8   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matchr@   r:   r=   r?   )r9   pytestr   
ValueErrorr   r    r!   )r$   r   r%   r&   rH   rC   rB   r)   r)   r*   test_spline_dim_errorR   s   
"z1TestRegularGridInterpolator.test_spline_dim_errorzpoints_values, sampler:   r=   r?   r;   r;   r1         "@c                 C   sF   || \}}t ||dd}||}t ||dd}||}t|| d S )Nr   r@   r   )r   r   )r$   Zpoints_valuesrB   r%   r&   rC   rD   rE   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=   r?   r@                 ?)r8   r    r!   r   realimagr   )
r$   r   r%   r&   rB   rC   ZrinterpZiinterprD   rE   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)   r/      r   ij)indexingc                 S   s   | d |d  S )Nr   r)   xyr)   r)   r*   <lambda>       zATestRegularGridInterpolator.test_cubic_vs_pchip.<locals>.<lambda>r   r@   r   r4   r/   +=r   )atolZrtol)r    meshgridr   Zallclose)
r$   rY   rZ   xgygr&   r   r   Z
vals_cubicZ
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 )NrL   H@r2   r   r    r!   r   r$   r%   r&   rC   rB   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=   r?   rc   gq@g     \@r+   r   r    r!   r   re   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   r@   )r+   r   r   )r$   rB   rf   r%   r&   rC   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 )Nrk   rl   r   rm   ri   re   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_raisesrJ   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 )Nrk   rl   rq   )r   r   r   )r   r   r   )r   r   r   皙?)r+   r   r    r!   rr   rJ   )r$   r%   r&   rC   rB   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{   rt   rt   rt   rt       @皙ir   r   r   r   )r   rm         &@r   r   r@   )gfffff[gfffff@g     gr   ri   re   r)   r)   r*   test_out_of_bounds_extrap      z5TestRegularGridInterpolator.test_out_of_bounds_extrapc                 C   rv   )NFrw   rz   r|   r}   r   )r   r   r   r   r   r@   )g333333(g33333`@g     gyXr   rd   re   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 )NFrw   rz   r|   r   r   r@   r   r:   r=   r?   rh   )r+   r   r    nanr!   r   re   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   r@   c                 S      g | ]}|qS r)   r)   .0pr)   r)   r*   
<listcomp>   r\   zJTestRegularGridInterpolator.test_nearest_compare_qhull.<locals>.<listcomp>r:   r=   r?   )	r+   r   	itertoolsproductr    r!   reshaper   r   r$   r%   r&   rC   Zpoints_qhullZvalues_qhullZinterp_qhullrB   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     r\   zITestRegularGridInterpolator.test_linear_compare_qhull.<locals>.<listcomp>r   r:   r=   r?   )	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   r/      rT      r   r   r@   rn   ffffff?)r    linspaceMyValuer   _vr   )r$   r   rY   rZ   r&   rC   rD   rE   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   rT   r   ry   y      ?       @)r    randomseedr   randr   rr   rJ   )r$   rY   rZ   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)   rX   r)   r)   r*   f7     z;TestRegularGridInterpolator.test_length_one_axis.<locals>.frT   r   rV   TrW   sparser   Fe   r   rx   ry   r   )r/         r]   r^   gffffff?333333@)333333@333333@r   rt   r   333333?g      '@g?g      )@V瞯<r4   gffffff?r   g?gffffff@rU   r   )r    r   r_   r   r   arrayry   )r$   r   rY   rZ   datarC   r)   r)   r*   test_length_one_axis3  sB     
z0TestRegularGridInterpolator.test_length_one_axisry   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ry   rx   r   r   r/   r   r   rT   r   )
r    r   pisinr   ZzerosvstackTr   r   )r$   ry   r   optionsrY   zfaZfbZx1aZzaZy1bZ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)rT   r/   rU   r   rT   Fr      lJ r   sizer   r   ignoreinvalid)rU   rT   )	r   r    isnanr   r   default_rngerrstater   r   )	r$   r   r   rngrY   iresrZ   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   rT   r/   )rT   rU   r   c                 S   s   | d |d  S Nr/   r)   rX   r)   r)   r*   r     s   z4TestRegularGridInterpolator.test_nan_x_2d.<locals>.frV   Tr   Fr   rx   r   r   r4   rT   r/   r]   r   r   r   r   r   r      r   )r    r   r_   r   r   r   r   r   r   r   r   r   )r$   r   rY   rZ   r   r`   ra   r   rC   r   r   i1i2r   r   r)   r)   r*   test_nan_x_2d  s4   




z)TestRegularGridInterpolator.test_nan_x_2d)ndimsfuncr/   c                 C      d| d  d|d   S Nr/   rU   r)   rX   r)   r)   r*   r[         z$TestRegularGridInterpolator.<lambda>rU   c                 C   s   d| d  d|d   | S r   r)   )rY   rZ   r   r)   r)   r*   r[     s    r   c                 C   s    d| d  d|d   | | S r   r)   rY   rZ   r   ar)   r)   r*   r[     s     r   c                 C   s$   d| d  d|d   | ||  S r   r)   )rY   rZ   r   r   br)   r)   r*   r[     s   $ c                    s   t jd}dd |j d|fd} fddt|D }|t j|dd	d
 }t|||d}||}	dd |D }
|t j|
dd	d
 }t|
||d}||}t|	| d S )N*   rT   r   r/   r   c                    s   g | ]	}t  d qS )   )r    r   )r   _Zsample_highZ
sample_lowr)   r*   r     s    zITestRegularGridInterpolator.test_descending_points_nd.<locals>.<listcomp>rV   Tr   r@   c                 S   s   g | ]	}|d d d qS )Nr   r)   )r   xir)   r)   r*   r     s    )r    r   r   uniformranger_   r   r   )r$   r   r   r   r   Ztest_pointsZascending_pointsZascending_valuesZascending_interpZascending_resultZdescending_pointsZdescending_valuesZdescending_interpZdescending_resultr)   r   r*   test_descending_points_nd  s6   

z5TestRegularGridInterpolator.test_descending_points_ndc                 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   r   r   r)   rX   r)   r)   r*   val_func_2d     zJTestRegularGridInterpolator.test_invalid_points_order.<locals>.val_func_2dr   r5   r         @      @r   r5   r7   r   r   rV   Tr   (must be strictly ascending or descendingrG   )r    r   r_   rI   r   rJ   r   )r$   r   rY   rZ   r%   r&   rH   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   rC   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   r4   r5   r6   r/   r   r0   r1         .@r         9@r   r   r   r   r   r   r   rU   r   Fr   r   rU   r   err_msgr   .rT   r   r]   r^   r   )r    r   r   r   r   r   r   appendr   	transposer   )r$   r   r%   r   r&   rB   rC   vvsjrE   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   r3   )r   r0   r1   r   r   r        A@      B@)	r   r0   r1   r   r   r   r  r  /   c                 S   s   g | ]}t t|qS r)   )tuplereversedr   r)   r)   r*   r     r   zGTestRegularGridInterpolator.test_nonscalar_values_2.<locals>.<listcomp>r   rU   r/   r   r   r   	   r   Fr   rT   r   .r   Zaxisr]   r   
r    r   r   r   r   emptyr   itemZexpand_dimsr   )r$   r   r  r%   r   trailing_pointsr&   rB   rC   r   r  r   r  rE   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   r3   r   )rU   r   r   r   r/   Fr   rT   r  r   .r   r  r]   r   r  )r$   r   r%   r   r  r&   rB   rC   r   r  r   r  rE   r)   r)   r*   test_nonscalar_values_linear_2D6  s0   
z;TestRegularGridInterpolator.test_nonscalar_values_linear_2Dr   xi_dtypec                 C   s   dd }t ddd}t ddd}t j||dd	d
\}}|||}||}t||f|}	t jddgddgg|d}
t|	|
ddgdd d S )Nc                 S   r   r   r)   rX   r)   r)   r*   r   \  r   z:TestRegularGridInterpolator.test_float32_values.<locals>.frT   r   r   r      rV   Tr   r   g@ffffff
@g@r   g Y`@g{,c@gHz>r   )r    r   r_   Zastyper   r   r   )r$   r   r  r   rY   rZ   r`   ra   r   rC   ptsr)   r)   r*   test_float32_valuesU  s   


z/TestRegularGridInterpolator.test_float32_values)1__name__
__module____qualname__r+   r2   r8   r9   parametrize_rgi_interp_methodsrF   rI   markparametrizerK   r    r!   rN   rS   rb   rg   rj   ro   rp   rs   ru   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  Zfloat32Zfloat64Z	complex64Z
complex128r  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__w  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)NzNo array representation)RuntimeErrorr%  r)   r)   r*   	__array__  r   zMyValue.__array__N)r  r  r  __doc__r"  r$  r&  r(  r)   r)   r)   r*   r   r  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d2d3 Zd4d5 Zd6d7 Z ejd8d9d:gd;d< Z!d=S )>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   r5   r7   r   r   g      @)rT   r/   rT   r/   rT   rT   )rT   r/   rU   r/   rT   rT   )rT   r/   r/   r/   rT   rT   )r    r   )r$   rY   rZ   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rT   ffffff@r   r   r  333333?rU   rT   r  r.  r   r0   r   rU   	splinef2dr@   r   rT   )r+  r
   r    r   r   r   r	   ev)r$   rY   rZ   r   lutr   r)   r)   r*   test_spline_2d  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 )Nr,  r/  r@   r   )r+  r    r   r   r	   rA   r   )r$   r   rY   rZ   r   r   rD   rE   r)   r)   r*   rF     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   rT   r/   rT   r/   rT   rT   r/   rU   r/   rT   rT   r/   r/   r/   rT   rT   r-  r   r   r  r.  rU   rT   r  r.  g      r0   r   rU   r0  FR?@r   r   rT   r/   r   )	r    r   r
   r   r	   r1  r   rr   rJ   )r$   rY   rZ   r   r2  r   actualexpectedr)   r)   r*   test_spline_2d_outofbounds  s(   
$

z&TestInterpN.test_spline_2d_outofboundsc                 C   r-   r.   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 )NrL   r   r@   r=  r   r    r!   r	   r   r$   r%   r&   Z	interp_rgrB   rf   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$@rM   r9  r   Fr   r=  r    r!   r	   r   r$   r%   r&   rB   rf   r:  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   r@   rL   r>  r?  r)   r)   r*   test_nearest_4d  s
   zTestInterpN.test_nearest_4dc                 C   rA  )NrB  r9  r   Fr   rC  rD  r)   r)   r*   test_4d_nearest_outofbounds  rF  z'TestInterpN.test_4d_nearest_outofboundsc                 C   sT   |   \}}tg d}t|||dd}t|||d d d f dd}t|| d S )NrL   F)rx   )r=  r    r!   r	   r   r$   r%   r&   rB   rD   rE   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   r/   rU   r   r   Fr   r/   rU   r   )
r=  r    r   r   r   r	   r   r   r   r   rI  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   rT   r/   rU   Fr   rK  )r+  r    r   r	   r   r   r_   Zc_r   Zravelr   r   )r$   r   rY   rZ   r&   r%   r   yirB   rD   xxyyrE   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   r/   r   r   r   r   Fr   r   r   c              	      s&   g | ]}t d |f  ddqS .Fr   r	   )r   r  r   r%   rB   r&   r)   r*   r   $  s
    
z5TestInterpN.test_nonscalar_values.<locals>.<listcomp>r   rT   r   r]   r   )
r    r   r   r	   r   r   r   r   r   r   )r$   r   r   r   r  rE   r)   rS  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   rT   c                    s0   g | ]  fd dt jd D qS )c              	      s(   g | ]}t d | f ddqS rQ  rR  )r   r   )r  r   r%   rB   r&   r)   r*   r   @  s    zBTestInterpN.test_nonscalar_values_2.<locals>.<listcomp>.<listcomp>r  )r   r   )r   rS  )r  r*   r   @  s
    
z7TestInterpN.test_nonscalar_values_2.<locals>.<listcomp>r   r]   r   )	r    r   r   r	   r   r   r   r!   r   )r$   r   r   r  r   r  r)   rS  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   rU   r   r   r   r   r0  r@   )r=  r    r   r   r   rr   rJ   r	   )r$   r%   r&   rB   r)   r)   r*    test_non_scalar_values_splinef2dG  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 )NrO   r,  r/  r@   rP   )r+  r    r   r   r	   rQ   rR   r   )r$   r   rY   rZ   r&   r%   rB   rD   Zv2rZv2irE   r)   r)   r*   rS   Q  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 )NrO   r,  r/  r0  r@   )r+  r    r   r   r   ZComplexWarningr	   )r$   rY   rZ   r&   r%   rB   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   r/   r   rT   r   r   rn   r   r@   )r    r   r   r	   r   r   )r$   r   rY   rZ   r&   rD   rE   r)   r)   r*   r   k  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   r/   r   rT   r   rU   r@   )r    r   r   r   r   r	   r!   r   )r$   r   rY   rZ   r&   rB   rD   rE   r)   r)   r*   test_matrix_inputy  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;   rT   r   rT   g@g	@gffffff@)r/   rU   r   )gQ?gffffff@gffffff @r   r   rt   r4   gffffffFrw   )r    r   r	   r   )r$   r&   r   r   rf   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)   r*   value_func_4d  s    z9TestInterpN.test_descending_points.<locals>.value_func_4d)r   rT   r/   rU   )r   r   r   r   )r   r;   r>   r   rV   Tr   r;   r   r   r   r   r   )r    r   r_   r   r   r	   r   )r$   rW  x1Zx2Zx3Zx4r%   r&   r  Zcorrect_resultZ
x1_descendZ
x2_descendZ
x3_descendZ
x4_descendZpoints_shuffledZvalues_shuffledZtest_resultr)   r)   r*   test_descending_points  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   r4  r5  r6  r7  r8  r   rG   )r    r   r   rI   r   rJ   r	   )r$   rY   rZ   r   r   rH   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   rT   r   rT   )rT   rT   rU   zaThe requested sample points xi have dimension 3, but this RegularGridInterpolator has dimension 1rG   )r    r   rr   rJ   r	   )r$   r%   r&   r   msgr)   r)   r*   test_invalid_xi_dimensions  s   
"z&TestInterpN.test_invalid_xi_dimensionsc                 C   s   t ddd}t ddd}t ddd}|||f}t d}t g d}|D ]}d|j_q(d|j_d|j_t||| t||| d S )	Nr   r   r   r   r   r   r   r   Gz@(\@gffffff?Fr    r   r   r   flagsZ	writeabler	   r   )r$   rY   rZ   r   r%   r&   pointdr)   r)   r*   test_readonly_grid  s   


zTestInterpN.test_readonly_gridc                 C   s|   t ddd}t ddd}||f}t d}t ddg}|D ]}d|j_q d|j_d|j_t||| t||| d S )	Nr   r   r   r   r   r   r^  r_  Fr`  )r$   rY   rZ   r%   r&   rb  rc  r)   r)   r*   test_2d_readonly_grid  s   

z!TestInterpN.test_2d_readonly_gridc                 C   s   t ddd}t |t |fj d d df }|jjr J t ddd}t ddd}|||f}t d}t 	g d}t
||| t||| d S )Nr   r   r   r   r   r\  r]  )r    r   r   Z
empty_liker   copyra  c_contiguousr   r   r	   r   )r$   rY   rZ   r   r%   r&   rb  r)   r)   r*   test_non_c_contiguous_grid  s   &

z&TestInterpN.test_non_c_contiguous_gridr   z>f8z<f8c                 C   sj   t jddd|d}t jddd|d}||f}t jd|d}t jddg|d}t||| t||| d S )	Nr   r   r   r   r   re  r^  r_  )r    r   r   r   r	   r   )r$   r   rY   rZ   r%   r&   rb  r)   r)   r*   test_endianness  s   zTestInterpN.test_endiannessN)"r  r  r  r+  r3  r  rF   r<  r=  r@  rE  rG  rH  rJ  rL  rP  r  r  rT  rS   rU  rI   r  r  r   rV  r   rY  r   r[  rd  rf  ri  rj  r)   r)   r)   r*   r*    sN    	

		








r*  )r   rI   numpyr    Znumpy.testingr   r   r   r   r   r   rr   Zscipy.interpolater   r	   r
   r   r   Zscipy.sparse._sputilsr   r  r  r  r   r   r*  r)   r)   r)   r*   <module>   s"        b