
    xf                         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(                  j+                  dg d      Z G d d	      Z G d
 d      Z G d d      Zy)    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                      e Zd Zd Zd Zd Zd Zed        Ze	j                  j                  dg d      d        Ze	j                  j                  d	e ej                  g d
g dg dg      fe ej                  g d      fg      d        Zed        Zd Zd Zd Ze	j                  j                  d ej                  g d      df ej                  g d      df ej                  g d      df ej                  g d      df ej                  g d      dfg      d        Zd Zd Zd  Zd! Zd" Zd# Zd$ Zd% Ze	j                  j                  dd&d'g      d(        Zd) Zd* Zd+ Z e	j                  j                  d,d-ejB                  ejD                  g      e	j                  j                  dd'd&g      d.               Z#e	j                  j                  dd&d'g      d/        Z$e	j                  j                  dd&d'g      d0        Z%ee	j                  j                  d1d2d3 fd4d5 fd6d7 fd8d9 fg      d:               Z&d; Z'ed<        Z(ed=        Z)ee	j                  j                  d>d?d@g      dA               Z*dB Z+e	j                  j                  dCejX                  ejZ                  ej\                  ej^                  g      e	j                  j                  dDejX                  ejZ                  g      dE               Z0y-)FTestRegularGridInterpolatorc                    dgdz  }t        j                  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z  z   |dz  z   |dz  z   }||fS )N              ?      ?   
   d     npasarraynewaxisselfpointsvaluesvalues0values1values2values3s          B/usr/lib/python3/dist-packages/scipy/interpolate/tests/test_rgi.py_get_sample_4dz*TestRegularGridInterpolator._get_sample_4d   s    !#L)BJJ

BJJ>?Q

BJJ>?RZZBJJ>?RZZQ>?GbL(7S=87T>Iv~    c                 "   dgdz  dgdz  z   }t        j                  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z  z   |dz  z   |dz  z   }||fS Nr      )r         @      $@r   r   r    r!   r%   s          r-   _get_sample_4d_2z,TestRegularGridInterpolator._get_sample_4d_2    s    !#}o&99L)BJJ

BJJ>?Q

BJJ>?RZZBJJ>?RZZQ>?GbL(7S=87T>Iv~r/   c                    dgdz  }t        j                  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z  z   |dz  z   |dz  z   }||fS )Nr   r   r         ?       @      @      @r   r   r   r    r!   r%   s          r-   _get_sample_4d_3z,TestRegularGridInterpolator._get_sample_4d_3+   s    56:?@BJJ

BJJ>?Q

BJJ>?RZZBJJ>?RZZQ>?GbL(7S=87T>Iv~r/   c                    dgdz  }t        j                  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z  z   |dz  z   |dz  z   }||fS )N)r   r   r   r   r   r   r   r    r!   r%   s          r-   _get_sample_4d_4z,TestRegularGridInterpolator._get_sample_4d_46   s    !S#J'BJJ

BJJ>?Q

BJJ>?RZZBJJ>?RZZQ>?GbL(7S=87T>Iv~r/   c                    | j                         \  }}t        j                  g dg dg dg      }t        ||j	                         |      } ||j	                               }t        |||      } ||      }t        ||       y )N皙?rA   r   ?皙?rA   g?g?r   r   r   r   r   )r<   r"   r#   r	   tolistr   )r&   r   r'   r(   sampleinterpv1v2s           r-   test_list_inputz+TestRegularGridInterpolator.test_list_inputA   s    ..0/1D/1 2 ))/068 FMMO$()/068 F^Br/   r   )r   r   r   c                 r   | j                         \  }}d}t        j                  t        |      5  t	        |||       d d d        t	        ||      }t        j                  g dg dg dg      }t        j                  t        |      5   |||       d d d        y # 1 sw Y   bxY w# 1 sw Y   y xY w)Nzpoints in dimensionmatchrF   r@   rC   rE   )r>   pytestr   
ValueErrorr	   r"   r#   )r&   r   r'   r(   rO   rI   rH   s          r-   test_spline_dim_errorz1TestRegularGridInterpolator.test_spline_dim_errorR   s    ..0% ]]:U3 	C#FF6B	C )8/1D/1 2]]:U3 	*6&)	* 	*	C 	C	* 	*s   B!B-!B*-B6zpoints_values, sampler@   rC   rE   rA   rA   r4         "@c                      ||       \  }}t        ||d      } ||      }t        ||d      } ||      }t        ||       y )Nr   rF   r   )r	   r   )r&   points_valuesrH   r'   r(   rI   rJ   rK   s           r-   test_linear_and_slinear_closez9TestRegularGridInterpolator.test_linear_and_slinear_closeb   sJ     't,(IF^(	JF^Br/   c                 B   | j                         \  }}|d|z  z
  }t        j                  g dg dg dg      }t        |||      }t        ||j                  |      }t        ||j
                  |      } ||      } ||      d ||      z  z   }	t        ||	       y )N               @r@   rC   rE   rF                 ?)r<   r"   r#   r	   realimagr   )
r&   r   r'   r(   rH   rI   rinterpiinterprJ   rK   s
             r-   test_complexz(TestRegularGridInterpolator.test_complexx   s    ..0"V)#/1D/1 2 )G)&&++fM)&&++fMF^V_r'&/11Br/   c                     g dg d}}t        j                  ||d      \  }} d ||      }t        ||f|d      }t        ||f|d      } |dd	g      } |dd	g      }	t        j                  ||	d
d      rJ y )N)   r2      r   ij)indexingc                     | dz  |dz  z  S )Nr    xys     r-   <lambda>zATestRegularGridInterpolator.test_cubic_vs_pchip.<locals>.<lambda>   s    q!tad{ r/   r   rF   r   r8   r2   +=r   )atolrtol)r"   meshgridr	   allclose)
r&   rh   ri   xgygr(   r   r   
vals_cubic
vals_pchips
             r-   test_cubic_vs_pchipz/TestRegularGridInterpolator.test_cubic_vs_pchip   s    \1QD1B*B3'AwG'AwGC8_
C8_
;;z:EJJJJr/   c                     | j                         \  }}t        ||      }t        j                  g d      }d}t	         ||      |       y )NrS   H@r5   r	   r"   r#   r   r&   r'   r(   rI   rH   wanteds         r-   test_linear_xi1dz,TestRegularGridInterpolator.test_linear_xi1d   sB    ..0(8/0!&.&9r/   c                     | j                         \  }}t        ||      }t        j                  g dg dg dg      }t        j                  g d      }t	         ||      |       y )Nr@   rC   rE   rv   gq@g     \@r.   r	   r"   r#   r   rx   s         r-   test_linear_xi3dz,TestRegularGridInterpolator.test_linear_xi3d   sY    ,,.(8/1D/1 223!&.&9r/   zsample, wanted)rA   rA   rB   rB   g     0@)rA   rA   rA   rA   r   r   r   r   r   r   r   r   r        \@)rA   皙?g333333?rB   g     |@c                 j    | j                         \  }}t        ||d      }t         ||      |       y )Nr   rF   )r.   r	   r   )r&   rH   ry   r'   r(   rI   s         r-   test_nearestz(TestRegularGridInterpolator.test_nearest   s2     ,,.(	J!&.&9r/   c                     | j                         \  }}t        ||      }t        j                  g dg dg      }t        j                  ddg      }t	         ||      |       y )Nr   r   r   r   r}   rx   s         r-   test_linear_edgesz-TestRegularGridInterpolator.test_linear_edges   sU    ,,.(8-/?@ARK(!&.&9r/   c                    ddg}t        j                  g d      }|d d t         j                  f   }|t         j                  d d f   }||dz  z   }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       y )	Nr   )r   r   r   r   )r   )r   r   g      ?r   )r   r   r   undefmethodrF   )r"   r#   r$   assert_raisesrQ   r	   )r&   r'   r(   r)   r*   s        r-   test_valid_createz-TestRegularGridInterpolator.test_valid_create   s    -L)BJJ'Q'GbL(j"966J"L1j"966J#\2j"966J;j"966J-j"966*	,r/   c                 L   | j                         \  }}t        ||      }t        j                  g dg dg      }t	        t
        ||d       t        j                  g dg dg      }t	        t
        ||       t        j                  g dg dg      }t	        t
        ||       y )Nr   r   r   )r   r   r   )r   r   r   )r   r   r   皙?)r.   r	   r"   r#   r   rQ   )r&   r'   r(   rI   rH   s        r-   test_valid_callz+TestRegularGridInterpolator.test_valid_call   s    ,,.(8-/?@Aj&&-@\<89j&&1-/@ABj&&1r/   c                 6   | j                         \  }}t        ||dd       }t        j                  g dg dg dg dg      }t        j                  g d      }t	         ||d	      |       t        j                  g d
      }t	         ||d	      |       y )NFbounds_error
fill_value皙r   r   r   r   r   r   r       @皙ir   r   r   r   )r   r         &@r   r   rF   )gfffff[gfffff@g     gr   r}   rx   s         r-   test_out_of_bounds_extrapz5TestRegularGridInterpolator.test_out_of_bounds_extrap   s    ,,.(e48:13G13IK L12!&	"BFK>?!&"A6Jr/   c                 6   | j                         \  }}t        ||dd       }t        j                  g dg dg dg dg      }t        j                  g d      }t	         ||d	      |       t        j                  g d
      }t	         ||d	      |       y )NFr   r   r   r   r   )r   r   r   r   r   rF   )g333333(g33333`@g     gyXr   rw   rx   s         r-   test_out_of_bounds_extrap2z6TestRegularGridInterpolator.test_out_of_bounds_extrap2   s    ..0(e48:13G13IK L/0!&	"BFK9:!&"A6Jr/   c                    | j                         \  }}t        ||dt        j                        }t        j                  g dg dg dg      }t        j                  t        j                  t        j                  t        j                  g      }t         ||d      |       t         ||d      |       t        j                  g d	g d
g dg      }t        j                  g d      }t         ||      |       y )NFr   r   r   r   r   rF   r   r@   rC   rE   r|   )r.   r	   r"   nanr#   r   rx   s         r-   test_out_of_bounds_fillz3TestRegularGridInterpolator.test_out_of_bounds_fill   s    ,,.(e46FF<13G35 6RVVRVVRVV45!&	"BFK!&"A6J/1D/1 223!&.&9r/   c                 b   | j                         \  }}t        ||d      }t        j                  | }|D cg c]  }| }}t	        j
                  |      }|j                  d      }t        ||      }t	        j
                  g dg dg dg      }t         ||       ||             y c c}w )Nr   rF   r@   rC   rE   )	r.   r	   	itertoolsproductr"   r#   reshaper   r   	r&   r'   r(   rI   points_qhullpvalues_qhullinterp_qhullrH   s	            r-   test_nearest_compare_qhullz6TestRegularGridInterpolator.test_nearest_compare_qhull   s    ,,.(	J ((&1#/0a00zz,/~~b),\<H/1D/1 2!&.,v2FG 1s   	B,c                 ^   | j                         \  }}t        ||      }t        j                  | }|D cg c]  }| }}t	        j
                  |      }|j                  d      }t        ||      }t	        j
                  g dg dg dg      }t         ||       ||             y c c}w )Nr   r@   rC   rE   )	r.   r	   r   r   r"   r#   r   r   r   r   s	            r-   test_linear_compare_qhullz5TestRegularGridInterpolator.test_linear_compare_qhull  s    ,,.(8 ((&1#/0a00zz,/~~b)+L,G/1D/1 2!&.,v2FG 1s   	B*r   r   c                 
   t        j                  ddd      }t        j                  ddd      }t        d      }t        ||f||      } |dd	g      }t        ||f|j                  |      } |dd	g      }t        ||       y )
Nr   r2      ra      r   r   rF   r   ffffff?)r"   linspaceMyValuer	   _vr   )r&   r   rh   ri   r(   rI   rJ   rK   s           r-   test_duck_typed_valuesz2TestRegularGridInterpolator.test_duck_typed_values  s}    KK1a KK1a (!QGS#J(!Q6JS#JBr/   c                 2   t         j                  j                  d       t        j                  ddd      }t        j                  ddd      }t         j                  j	                  dd      }t        ||f|d       t        t        t
        ||f|d       y )	N  r   r2   r   ra   r   r   y      ?       @)r"   randomseedr   randr	   r   rQ   )r&   rh   ri   r(   s       r-   test_invalid_fill_valuez3TestRegularGridInterpolator.test_invalid_fill_value  sv    
		tKK1a KK1a 1% 	 A1= 	j"9!ff	7r/   c                     t        j                  dd      }|j                  D cg c]  }t        j                  |       }}t	        ||       t	        ||d       y c c}w )Nr         z>f4dtyper   r   )r"   onesshapearanger	   )r&   r(   nr'   s       r-   test_fillvalue_typez/TestRegularGridInterpolator.test_fillvalue_type+  sL    U3(.51"))A,55/2> 6s   Ac           
         d }t        j                  ddd      }t        j                  ddd      } |t        j                  ||dd       }t        ||f|ddd	
      }t	         |t        j
                  ddgddgddgg            g dd       t	         |t        j
                  ddgddgddgg            g dd       t	         |t        j
                  ddg            |j                  d       d |_        t	         |ddgddgg      ddgd       t	         |ddgddgg      ddgd       t        ||f|ddd 
      }t	         |ddgddgg      dd gd       y )!Nc                     | |z   S Nrf   rg   s     r-   fz;TestRegularGridInterpolator.test_length_one_axis.<locals>.f7  s    q5Lr/   ra   r   rc   Trd   sparser   Fe   r   r   r   r   )r2         rk   rl   gffffff?333333@)333333@333333@r   r   r   333333?g      '@g?g      )@V瞯<r8   gffffff?r   g?gffffff@rb   r   )r"   r   rn   r	   r   arrayr   )r&   r   rh   ri   datarI   s         r-   test_length_one_axisz0TestRegularGridInterpolator.test_length_one_axis3  s   	KK1a KK2r""++aT$?@(!Qh6;M 	rxx!Q!Q!R(ABC""	$
 	rxx!SAs8aW(EFG&"	$
 	rxxc
34))"	$
 !C1d)45d%	1 	c
S$K89d%	1 )!Qi6;Nc
RI67A"	$r/   r   Nc                 ~   |d|d}t        j                  ddt         j                  z  d      }t        j                  |      }t	        |f|d d  fi |}t	        |dgf|d d d f   fi |}t        j                  ddt         j                  z  dz   d      } ||      }	t        j
                  d      }
 |t        j                  ||
g      j                        }t        ||	       t        j                  d      }
 |t        j                  ||
g      j                        }|t        ||	       y t        ||       y )	NFr   r   r   r   r2   r   r   ra   r   )
r"   r   pisinr	   zerosvstackTr   r   )r&   r   r   optionsrh   zfafbx1azay1bzbs               r-   test_length_one_axis2z1TestRegularGridInterpolator.test_length_one_axis2^  s    ",U#% KK1RUU7B'FF1I$aT1Q4;7;$a!XqDzEWEkk"agai-W hhsm		3*%''(B ggcl		3*%''(B#B
+r/   c                 "   t        g dfg ddd|      }t        j                   |t        j                  g            sJ t        j                  j                  d      }|j	                  d      d	z  }|j	                  d      d
kD  }t        j                  ||<   t        j                  d      5   ||      }d d d        t        |   t        j                         t        ||     |||                 g d}dg}t        j                  d      }t        ||f|dd|      }t        j                   |t        j                  dg            sJ t        j                   |dt        j                  g            sJ y # 1 sw Y   xY w)N)ra   r2   rb   r   ra   Fr      lJ r   sizer   r   ignoreinvalid)rb   ra   )	r	   r"   isnanr   r   default_rngerrstater   r   )	r&   r   r   rngrh   iresri   r   s	            r-   test_nan_x_1dz)TestRegularGridInterpolator.test_nan_x_1dz  sP    $YL,116vGxx266($$$ ii##J/JJCJ "JJCJ 3&vv![[* 	
 A$C	 	SVRVV$S!Wa1"h' Ewwv#QFDQ16vGxx2661+'''xx1bff+'''#	 	s   4	FFc                    t        j                  g d      t        j                  g d      }}d }t        j                  ||dd      \  }} |||      }t        ||f||d      }t        j                  d	
      5   |dt         j
                  gddgg      }	d d d        t        	d   dd       t        j                  |	d         sJ t         j                  j                  d      }
|
j                  d      dz  dz
  }|
j                  d      dz  }|
j                  d      dkD  }|
j                  d      dkD  }||z  }t         j
                  ||<   t         j
                  ||<   t        j                  ||g      j                  }t        j                  d	
      5   ||      }	d d d        t        |	|   t         j
                         t        |	|     |||                 y # 1 sw Y   VxY w# 1 sw Y   NxY w)N)r   ra   r2   )ra   rb   r   c                     | dz  |dz  z   S Nr2   rf   rg   s     r-   r   z4TestRegularGridInterpolator.test_nan_x_2d.<locals>.f  s    a4!Q$;r/   rc   Tr   Fr   r   r   r   r8   ra   r2   rk   r   r   r   r   r   r      r   )r"   r   rn   r	   r   r   r   r   r   r   r   r   )r&   r   rh   ri   r   rp   rq   r   rI   r   r   i1i2r   r   s                  r-   test_nan_x_2dz)TestRegularGridInterpolator.test_nan_x_2d  s   xx	"BHHY$71	 QD>BRy(!Q06UL [[* 	23-!Q01C	2A.xxA ii##J/JJCJ "1$JJCJ "ZZSZ!C'ZZSZ!C'G""HHaV[[* 	
 )C	 	SVRVV$S!WfQrUm,/	2 	2	 	s   >G/&	G</G9<H)ndimsfuncr2   c                 $    d| dz  z  d|dz  z  z   S Nr2   rb   rf   rg   s     r-   rj   z$TestRegularGridInterpolator.<lambda>  s    Q!Va!q&j0 r/   rb   c                 *    d| dz  z  d|dz  z  z   |z
  S r  rf   )rh   ri   r   s      r-   rj   z$TestRegularGridInterpolator.<lambda>  s     AQJQ!V3a7 r/   r   c                 0    d| dz  z  d|dz  z  z   |z
  |z   S r  rf   rh   ri   r   as       r-   rj   z$TestRegularGridInterpolator.<lambda>  s%    q16zAQJ6:Q> r/   r   c                 6    d| dz  z  d|dz  z  z   |z
  ||z  z   S r  rf   )rh   ri   r   r
  bs        r-   rj   z$TestRegularGridInterpolator.<lambda>  s)    !a1f*q16z"9A"=A"E r/   c                    t         j                  j                  d      }d}d}|j                  ||d|f      }t	        |      D cg c]  }t        j
                  ||d       }	} |t        j                  |	ddd	 }
t        |	|
|
      } ||      }|	D cg c]
  }|d d d    }} |t        j                  |ddd	 }t        |||
      } ||      }t        ||       y c c}w c c}w )N*   ra   r   r2   r      rc   Tr   rF   r   )	r"   r   r   uniformranger   rn   r	   r   )r&   r   r  r  r   
sample_lowsample_hightest_points_ascending_pointsascending_valuesascending_interpascending_resultxidescending_pointsdescending_valuesdescending_interpdescending_results                     r-   test_descending_points_ndz5TestRegularGridInterpolator.test_descending_points_nd  s&    ii##B'
kk*kE
kK &+5\3 ! KK
KD 3 3  .>6:48": ; 33C3C:@B ,K80@A"R"XAA "++/@7;59#; < 44E4E;AC .k:+->?+3 Bs   C'C,c                    d }t        j                  g d      }t        j                  g d      }||f} |t        j                  |ddd }d}t        j                  t
        |      5  t        ||       d d d        y # 1 sw Y   y xY w)	Nc                 $    d| dz  z  d|dz  z  z   S r  rf   rg   s     r-   val_func_2dzJTestRegularGridInterpolator.test_invalid_points_order.<locals>.val_func_2d  s    qAv:AF
**r/   r   r9   r         @      @r   r9   r;   r$  r%  rc   Tr   (must be strictly ascending or descendingrN   )r"   r   rn   rP   r   rQ   r	   )r&   r"  rh   ri   r'   r(   rO   s          r-   test_invalid_points_orderz5TestRegularGridInterpolator.test_invalid_points_order  s~    	+ HH*+HH*+Qbkk6D157 8:]]:U3 	4#FF3	4 	4 	4s   ,BBc                     t        t        j                  d      gt        j                  d      |d      }t        j                   |dg            sJ y )Nr   Fr   r   )r	   r"   r   r   r   )r&   r   rI   s      r-   test_fill_valuez+TestRegularGridInterpolator.test_fill_value  s@    ("))A,06ULxxt%%%r/   c                    dgdz  dgdz  z   }t         j                  j                  d      }|j                  d      }|j                  d      }t        |||d      } ||      }t	        |j
                  d	|
       g }t        d      D ]-  }	t        ||d|	f   |d      }|j                   ||             / t        j                  |      j                  ddd      }
t        ||
d|       y Nr   r   r   r8   r9   r:   r2   )r   r3   r4         .@r         9@r   )r   r   r   r   r   )r   rb   r   Fr   )r   rb   r   err_msgr   .ra   r   rk   rl   r1  )r"   r   r   r	   r   r   r  appendr   	transposer   )r&   r   r'   r   r(   rH   rI   vvsjrK   s              r-   test_nonscalar_valuesz1TestRegularGridInterpolator.test_nonscalar_values  s     11A5,9
9  ii##D)O,I&(6;=6NQWWi8q 	&A,VVCF^4::?AF IIfVn%		&
 XXb\##Aq!,2E6:r/   flip_pointsFTc           	         g d}|r!|D cg c]  }t        t        |             }}t        j                  j	                  d      }d}|j                  ddddg|      }|j                  d      }t        |||d	
      }	 |	|      }
|
j                  dg|k(  sJ t        j                  |j                  dd        }t        |j                  d         D ]O  }t        |j                  d         D ]2  }t        ||d||f   |d	
      }	 |	|      j                         |||f<   4 Q t        j                  |d      }t        |
|d|       y c c}w )Nr-  r7   )r   r3   r4   r.  r   r/       A@      B@)	r   r3   r4   r.  r   r/  r<  r=  /   r   rb   r2   r   r   r   	   r   Fr   ra   r   .r   axisrk   r2  )tuplereversedr"   r   r   r	   r   emptyr  itemexpand_dimsr   )r&   r   r9  r'   r   r   trailing_pointsr(   rH   rI   r5  r6  r   r7  rK   s                  r-   test_nonscalar_values_2z3TestRegularGridInterpolator.test_nonscalar_values_2  s[   
D 289QeHQK(9F9ii##D) Q1a:/:;A(6;=6N ww1///// XXfll23'(v||B'( 	1A6<<+, 10Q	9J8>>CE "&>..01a4	1	1 ^^BQ'2E6:3 :s   Ec           	      \   d}ddg}t         j                  j                  d      }d}|j                  ddg|      }|j                  d      }t        |||d	
      } ||      }|j                  dg|k(  sJ t        j
                  |j                  dd        }	t        |j                  d         D ]O  }
t        |j                  d         D ]2  }t        ||d|
|f   |d	
      } ||      j                         |	|
|f<   4 Q t        j                  |	d      }t        ||d|       y )Nr   r-  r7   r   )rb   r   r   r   r2   Fr   ra   rA  r   .r   rB  rk   r2  )
r"   r   r   r	   r   rF  r  rG  rH  r   )r&   r   r'   r   rI  r(   rH   rI   r5  r6  r   r7  rK   s                r-   test_nonscalar_values_linear_2Dz;TestRegularGridInterpolator.test_nonscalar_values_linear_2D6  s=   059 ii##D) Q4O45A(6;=6N ww1///// XXfll23'(v||B'( 	1A6<<+, 10Q	9J8>>CE "&>..01a4	1	1 ^^BQ'2E6:r/   r   xi_dtypec                 T   d }t        j                  ddd      }t        j                  ddd      }t        j                  ||dd	      \  }} |||      }|j                  |      }t	        ||f|      }	t        j
                  d
dgddgg|      }
t         |	|
      ddgd       y )Nc                 $    d| dz  z  d|dz  z  z   S r  rf   rg   s     r-   r   z:TestRegularGridInterpolator.test_float32_values.<locals>.f\  s    q!t8a!Q$h&&r/   ra   r   r   r      rc   Tr   r   g@ffffff
@g@r   g Y`@g{,c@gHz>r   )r"   r   rn   astyper	   r   r   )r&   r   rM  r   rh   ri   rp   rq   r   rI   ptss              r-   test_float32_valuesz/TestRegularGridInterpolator.test_float32_valuesU  s    	' KK1b!KK1b!QD>BRy{{5!(!Q6hhc
c
$+35 	slL%AMr/   )1__name__
__module____qualname__r.   r5   r<   r>   parametrize_rgi_interp_methodsrL   rP   markparametrizerR   r"   r#   rW   r_   rt   rz   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r(  r*  r8  rJ  rL  float32float64	complex64
complex128rT  rf   r/   r-   r   r      s   				 $  $   [[X'DE* F* [[ 

)*)+ zrzz*?@A
	
   $  $ 
K:: [[RZZ,-v6RZZ,-s3RZZ,-s3RZZ,-v6RZZ,-v6	
	:	:
:,$2	K	K:
H
H [[X	8'<=  > 7?)$V [[\D"&&"%%+@A[[X)'<=, > B,4 [[X	8'<=( >(< [[X	8'<="- >"-H $[[.	
01	
78	
>?	
EF	1 @ $@:4 $& $&
 $; $;2 $[[]UDM:#; ; $#;J;> [[	RZZr}}= [[Z"**bjj)ABN C	
Nr/   r   c                   (    e Zd ZdZd Zd Zd Zd Zy)r   z"
    Minimal indexable object
    c                     d| _         || _        t        j                  t        j                  |            j                  |      | _        y r   )ndimr   r"   r   prodr   r   )r&   r   s     r-   __init__zMyValue.__init__w  s3    	
))BGGEN+33E:r/   c                      | j                   |   S r   )r   )r&   idxs     r-   __getitem__zMyValue.__getitem__|  s    wws|r/   c                      y r   rf   r&   s    r-   __array_interface__zMyValue.__array_interface__  s    r/   c                     t        d      )NzNo array representation)RuntimeErrorrh  s    r-   	__array__zMyValue.__array__  s    455r/   N)rU  rV  rW  __doc__rc  rf  ri  rl  rf   r/   r-   r   r   r  s    ;
6r/   r   c                   n   e Zd Zd Zd Zed        Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zed        Zed        Zed        Zd Zed        Zd Zej,                  j/                  dddg      d        Zed        Zd Zd Zd Zd Zd Zd Zd Z ej,                  j/                  ddd g      d!        Z!y")#TestInterpNc           	          t        j                  g d      }t        j                  g d      }t        j                  g dg dg dg dg dg dg      }|||fS )N)r   r9   r;   r$  r%  g      @)ra   r2   ra   r2   ra   ra   )ra   r2   rb   r2   ra   ra   )ra   r2   r2   r2   ra   ra   )r"   r   )r&   rh   ri   r   s       r-   _sample_2d_datazTestInterpN._sample_2d_data  sR    HH./HH./HH""""""	
 !Qwr/   c           	         | j                         \  }}}t        |||      }t        j                  g dg dg      j                  }t        t        ||f||d      |j                  |d d df   |d d df                y )Nra   ffffff@r   r   rQ  333333?rb   ra   rQ  ru  r$  r3   r   rb   	splinef2drF   r   ra   )rq  r   r"   r   r   r   r
   ev)r&   rh   ri   r   lutr  s         r-   test_spline_2dzTestInterpN.test_spline_2d  s|    &&(1a!!Q*XX668 99: 	!'1a&!R"L"%&&AqD2ad8"<	>r/   c                 F   | j                         \  }}}t        j                  g dg dg      j                  }t	        ||f|||      }t	        |j                         |j                         f|j                         |j                         |      }t        |||       y )Nrs  rv  rF   r0  )rq  r"   r   r   r
   rG   r   )r&   r   rh   ri   r   r  rJ   rK   s           r-   rL   zTestInterpN.test_list_input  s    &&(1aXX668 99: 	 aVQ62XXZ$ahhj"))+f
 	B/r/   c           
         t        j                  g d      }t        j                  g d      }t        j                  g dg dg dg dg dg      }t        |||      }t        j                  g dg dg      j                  }t	        ||f||ddd	
      }|j                  |d d df   |d d df         }d	|dd t        ||       t        t        t        ||f||ddd 
       y )Nr&  ra   r2   ra   r2   ra   ra   r2   rb   r2   ra   ra   r2   r2   r2   ra   ra   rt  r   r   rQ  ru  rb   ra   rQ  ru  g      r3   r   rb   rw  FR?@r   r   ra   r2   r   )	r"   r   r   r   r
   rx  r   r   rQ   )r&   rh   ri   r   ry  r  actualexpecteds           r-   test_spline_2d_outofboundsz&TestInterpN.test_spline_2d_outofbounds  s    HH*+HH*+HHo%8 9!!Q*XX679 ::;! 	!QB{&+@66"QT(Bq!tH-1!&(3 	j'Aq61b#(T	;r/   c                 "   dgdz  dgdz  z   }t        j                  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z  z   |dz  z   |dz  z   }||fS r1   r!   r%   s          r-   _sample_4d_datazTestInterpN._sample_4d_data  s    !#}o&99L)BJJ

BJJ>?Q

BJJ>?RZZBJJ>?RZZQ>?GbL(7S=87T>Iv~r/   c                     | j                         \  }}t        ||      }t        j                  g dg      }t	        |||d      }t         ||      |       y )NrS   r   rF   r  r	   r"   r#   r
   r   r&   r'   r(   	interp_rgrH   ry   s         r-   test_linear_4dzTestInterpN.test_linear_4d  sQ    --/+FF;	012A!)F"3V<r/   c                     | j                         \  }}t        j                  g dg      }d}t        |||ddd      }t	        ||       y )NrA   r   g333333$@rT   r  r   Fr   r  r"   r#   r
   r   r&   r'   r(   rH   ry   r  s         r-   test_4d_linear_outofboundsz&TestInterpN.test_4d_linear_outofbounds  sM    --/234&+@!&&1r/   c                     | j                         \  }}t        ||d      }t        j                  g dg      }t	        |||d      }t         ||      |       y )Nr   rF   rS   r  r  s         r-   test_nearest_4dzTestInterpN.test_nearest_4d  sS    --/+FF9M	012	B!)F"3V<r/   c                     | j                         \  }}t        j                  g dg      }d}t        |||ddd      }t	        ||       y )Nr  r  r   Fr   r  r  s         r-   test_4d_nearest_outofboundsz'TestInterpN.test_4d_nearest_outofbounds  sM    --/234	&+@!&&1r/   c                     | j                         \  }}t        j                  g d      }t        |||d      }t        |||d d d f   d      }t	        ||       y )NrS   F)r   )r  r"   r#   r
   r   r&   r'   r(   rH   rJ   rK   s         r-   
test_xi_1dzTestInterpN.test_xi_1d  sU    --//0VVV%@VVVDF^%HBr/   c                    | j                         \  }}t        j                  j                  d       t        j                  j	                  ddd      }t        |||dd      }t        |j                  d       t        |||j                  d	d      dd      }t        ||j                  |j                               y )
Nr   r2   rb   r   r   Fr   r2   rb   r   )
r  r"   r   r   r   r
   r   r   r   r   r  s         r-   
test_xi_ndzTestInterpN.test_xi_nd  s    --/
		t1a(VVVI"')RXXv&VVV^^B%:%E;BJJrxx01r/   c                 &   | j                         \  }}}||f}t        j                  ddd      }t        j                  ddd      }|d d d f   |d d d f   f}t        ||||d      }	t	        |	j
                  d       t        j                  ||      \  }
}t        j                  |
j                  j                         |j                  j                         f   }t        ||||d      }t        |	|j                  |	j
                               y )Nr   ra   r2   rb   Fr   r  )rq  r"   r   r
   r   r   rn   c_r   ravelr   r   )r&   r   rh   ri   r(   r'   r  yirH   rJ   xxyyrK   s                r-   test_xi_broadcastzTestInterpN.test_xi_broadcast  s     ++-1fQ[[Aq![[Aq!QW+r$'{+VVVFORXXv&R$Brttzz|RTTZZ\12VVV"8BJJrxx01r/   c           
         dgdz  dgdz  z   }t         j                  j                  d      }|j                  d      }|j                  d      }t        ||||d      }t	        |j
                  d	|
       t        d      D cg c]  }t        ||d|f   ||d       }}t        j                  |      j                  ddd      }	t        ||	d|       y c c}w r,  )
r"   r   r   r
   r   r   r  r   r4  r   )
r&   r   r'   r   r(   rH   r5  r7  r6  rK   s
             r-   r8  z!TestInterpN.test_nonscalar_values  s     11A5,9
9  ii##D)O,I&FFF6!&(QWWi8 498=./ ffS!VnfV#(* = =XXb\##Aq!,2E6:	=s   Cc                    g d}t         j                  j                  d      }d}|j                  ddddg|      }|j                  d      }t        ||||d	
      }|j                  dg|k(  sJ t        |j                  d         D 	cg c]<  }t        |j                  d         D 	cg c]  }	t        ||d|	|f   ||d	
       c}	> }
}}	t        |t        j                  |
      j                  d|       y c c}	w c c}	}w )Nr;  r   r?  r   r   r   r@  r   Fr   ra   r   rA  .rk   r2  )	r"   r   r   r
   r   r  r   r#   r   )r&   r   r'   r   rI  r(   rH   r5  r7  r   r6  s              r-   rJ  z#TestInterpN.test_nonscalar_values_2*  s   D
 ii##D) Q1a:/:;AFFF6N ww1///// v||B/02  6;6<<;K5L01 sAqy 16&%*, 2 2
 	2::b>++%H 2s   D.D D Dc                 "   | j                         \  }}t        j                  j                  d       t        j                  j	                  ddddd      }t        j                  j	                  ddd      }t        t        t        |||d       y )	Nr   rb   r   r   r   r   rw  rF   )r  r"   r   r   r   r   rQ   r
   )r&   r'   r(   rH   s       r-    test_non_scalar_values_splinef2dz,TestInterpN.test_non_scalar_values_splinef2dG  si    --/
		t1aA.2q)j'666(	*r/   c                 8   | j                         \  }}}||f}|d|z  z
  }t        j                  g dg dg      j                  }t	        ||||      }t	        ||j
                  ||      }t	        ||j                  ||      }	|d|	z  z   }
t        ||
       y )NrY   rs  rv  rF   rZ   )rq  r"   r   r   r
   r[   r\   r   )r&   r   rh   ri   r(   r'   rH   rJ   v2rv2irK   s              r-   r_   zTestInterpN.test_complexQ  s    ++-1fQ"V)#::< ==>Q 	 VVVF;ffkk6&Affkk6&A2c6\Br/   c                    | j                         \  }}}||f}|d|z  z
  }t        j                  g dg dg      j                  }t	        t        j
                        5  t        |||d       d d d        y # 1 sw Y   y xY w)NrY   rs  rv  rw  rF   )rq  r"   r   r   r   ComplexWarningr
   )r&   rh   ri   r(   r'   rH   s         r-   test_complex_spline2fdz"TestInterpN.test_complex_spline2fd`  s    ++-1fQ"V)#::< ==>Q 	"++, 	@FFF;?	@ 	@ 	@s   A88Br   r   r   c                     t        j                  ddd      }t        j                  ddd      }t        d      }t        ||f|ddg|	      }t        ||f|j                  ddg|	      }t        ||       y )
Nr   r2   r   ra   r   r   r   r   rF   )r"   r   r   r
   r   r   )r&   r   rh   ri   r(   rJ   rK   s          r-   r   z"TestInterpN.test_duck_typed_valuesk  so    
 KK1a KK1a aVVc3Z?aVVYYc
6BBr/   c                 v   t        j                  ddd      }t        j                  ddd      }t        t         j                  j	                  dd            }t         j                  j	                  ddd      }t        ||f|||      }t        ||ft        j                  |      ||      }t        ||       y )Nr   r2   r   ra   r   rb   rF   )r"   r   r   r   r   r
   r#   r   )r&   r   rh   ri   r(   rH   rJ   rK   s           r-   test_matrix_inputzTestInterpN.test_matrix_inputy  s    KK1a KK1a 		q!,-1a(aVVVF;aVRZZ/GBr/   c                 :   t        j                  g dg      }t        j                  ddgddgddgg      }t        dgg df||      }g d}t        ||d	       t        j                  d
dgddgddgg      }t        dgg df||dd       }t        ||d	       y )N)rA   ra   r   ra   g@g	@gffffff@)r2   rb   r   )gQ?gffffff@gffffff @r   r   r   r8   gffffffFr   )r"   r   r
   r   )r&   r(   r  r   ry   s        r-   r   z TestInterpN.test_length_one_axis  s    
 <.)XX3x!SAs845sI&3 	V%0 XXSzC:c{;<sI&#(T; 	V%0r/   c           	      P   d }t        j                  g d      }t        j                  g d      }t        j                  g d      }t        j                  g d      }||||f} |t        j                  |ddd }dd	t        j                  t        j                  d
dd            t        j                  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        |	|       y )Nc                 0    d| dz  z  d|dz  z  z   |z
  |z
  S r  rf   r	  s       r-   value_func_4dz9TestInterpN.test_descending_points.<locals>.value_func_4d  s'    qAv:AF
*Q.22r/   )r   ra   r2   rb   )r   r   r   r   )r   rA   rD   r   rc   Tr   rA   r   r   r   r   r   )r"   r   rn   r4  r   r
   r   )r&   r  x1x2x3x4r'   r(   rS  correct_result
x1_descend
x2_descend
x3_descend
x4_descendpoints_shuffledvalues_shuffledtest_results                    r-   test_descending_pointsz"TestInterpN.test_descending_points  s!   	3 XXl#XXo&XXo&XX&'b"b![[&4=?Cbkk!R&;<{{1c1%' 5"X
"X
"X
"X
%z:zJ'[[/DFHoD>;7r/   c                 t   t        j                  g d      }t        j                  g d      }t        j                  g dg dg dg dg dg      }t        j                  g dg dg      j                  }d}t        j                  t
        |	      5  t        ||f||       d d d        y # 1 sw Y   y xY w)
Nr#  r&  r}  r~  r  r  r  r'  rN   )r"   r   r   rP   r   rQ   r
   )r&   rh   ri   r   r  rO   s         r-   r(  z%TestInterpN.test_invalid_points_order  s    HH*+HH*+HHo%8 9XX679 ::;! 	 ;]]:U3 	#QFAr"	# 	# 	#s   B..B7c                     dg}ddg}t        j                  d      }d}t        t        |      5  t	        |||       d d d        y # 1 sw Y   y xY w)N)r   ra   r   ra   )ra   ra   rb   zaThe requested sample points xi have dimension 3, but this RegularGridInterpolator has dimension 1rN   )r"   r   r   rQ   r
   )r&   r'   r(   r  msgs        r-   test_invalid_xi_dimensionsz&TestInterpN.test_invalid_xi_dimensions  sR    QWWY9:S1 	(FFB'	( 	( 	(s   AAc                    t        j                  ddd      }t        j                  ddd      }t        j                  ddd      }|||f}t        j                  d      }t        j                  g d      }|D ]  }d|j                  _         d|j                  _        d|j                  _        t        |||        t        ||      |       y )	Nr   r   r   r   r   r   r   r   Gz@(\@gffffff?Fr"   r   r   r   flags	writeabler
   r	   )r&   rh   ri   r   r'   r(   pointds           r-   test_readonly_gridzTestInterpN.test_readonly_grid  s    KK1a KK1a KK1a Q#+, 	&A %AGG	&!& %&//6r/   c                 r   t        j                  ddd      }t        j                  ddd      }||f}t        j                  d      }t        j                  ddg      }|D ]  }d|j                  _         d|j                  _        d|j                  _        t        |||        t        ||      |       y )	Nr   r   r   r   r   r   r  r  Fr  )r&   rh   ri   r'   r(   r  r  s          r-   test_2d_readonly_gridz!TestInterpN.test_2d_readonly_grid  s     KK1a KK1a Q$& 	&A %AGG	&!& %&//6r/   c                    t        j                  ddd      }t        j                  |t        j                  |      f      j                  j                         d d df   }|j                  j                  rJ t        j                  ddd      }t        j                  ddd      }|||f}t        j                  d      }t        j                  g d      }t        |||        t        ||      |       y )Nr   r   r   r   r   r  r  )r"   r   r   
empty_liker   copyr  c_contiguousr   r   r
   r	   )r&   rh   ri   r   r'   r(   r  s          r-   test_non_c_contiguous_gridz&TestInterpN.test_non_c_contiguous_grid  s    KK1a IIq"--*+,..335ad;77''''KK1a KK1a Q#+,&//6r/   r   z>f8z<f8c                    t        j                  ddd|      }t        j                  ddd|      }||f}t        j                  d|      }t        j                  ddg|      }t	        |||        t        ||      |       y )	Nr   r   r   r   r   r  r  r  )r"   r   r   r   r
   r	   )r&   r   rh   ri   r'   r(   r  s          r-   test_endiannesszTestInterpN.test_endianness  sw     KK1au-KK1au-Qu-$U3&//6r/   N)"rU  rV  rW  rq  rz  rX  rL   r  r  r  r  r  r  r  r  r  r8  rJ  r  r_   r  rP   rY  rZ  r   r  r   r  r(  r  r  r  r  r  rf   r/   r-   ro  ro    s3   > $	0 $	0;&=2=2 2 $2 $2& $; $;( $I $I8* $  $ 	@ [[	9 	  $
  $
 1,84
#(777 [[Wuen5	7 6	7r/   ro  )r   rP   numpyr"   numpy.testingr   r   r   r   r   r   r   scipy.interpolater	   r
   r   r   r   scipy.sparse._sputilsr   rY  rZ  rX  r   r   ro  rf   r/   r-   <module>r     sn      J J *L L )!'!8!8K" [	N [	N|6 6({7 {7r/   