
    tKg<                         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 d dlmZ ej,                  j/                  dej0                        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)ComplexWarningmethodc                      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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jD                  ejF                  g      e	j                  j                  dd(d'g      d/               Z$e	j                  j                  dd'd(g      d0        Z%e	j                  j                  dd'd(g      d1        Z&e	j                  jO                  d2      ee	j                  j                  d3d4d5 fd6d7 fd8d9 fd2d: fg      d;                      Z(d< Z)ed=        Z*e	j                  jO                  d4      ed>               Z+ee	j                  j                  d?d@dAg      dB               Z,dC Z-e	j                  j                  dDej\                  ej^                  ej`                  ejb                  g      e	j                  j                  dEej\                  ej^                  g      dF               Z2dG Z3y.)H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          d/home/alanp/www/video.onchill/myenv/lib/python3.12/site-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_48   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皙?r<   r   ?皙?r<   g?g?r   r   r   r   r   )r7   r   r   r	   tolistr   )r!   r   r"   r#   sampleinterpv1v2s           r(   test_list_inputz+TestRegularGridInterpolator.test_list_inputC   s    ..0/1D/1 2 ))/068 FMMO$()/068 F^Br*   r   )cubicquinticpchipc                 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matchrA   r;   r>   r@   )r9   pytestr   
ValueErrorr	   r   r   )r!   r   r"   r#   rM   rD   rC   s          r(   test_spline_dim_errorz1TestRegularGridInterpolator.test_spline_dim_errorT   s    ..0% ]]:U3#FF6B 4 )8/1D/1 2]]:U36&) 43 43 43s   B!B-!B*-B6zpoints_values, sampler;   r>   r@   r<   r<   r/         "@c                      ||       \  }}t        ||d      } ||      }t        ||d      } ||      }t        ||       y )NlinearrA   slinear)r	   r   )r!   points_valuesrC   r"   r#   rD   rE   rF   s           r(   test_linear_and_slinear_closez9TestRegularGridInterpolator.test_linear_and_slinear_closed   sJ     't,(IF^(	JF^Br*   c                 n   | j                         \  }}t        j                  g dg dg dg      }t        ||d      }t	        t
              5   ||d       d d d        t         ||d      g d	d
       t         ||d      g dd
       t         ||d      g dd       y # 1 sw Y   RxY w)Nr;   r>   r@   rU   rA      )nu)rY   r   r   r   )rY   rY   rY   V瞯<atol)r   rY   r   r   )r   r   r   )r   rY   rY   r   )r   r   r   g-=)r)   r   arrayr	   assert_raisesrO   r   )r!   r"   r#   rC   rD   s        r(   test_derivativesz,TestRegularGridInterpolator.test_derivativesz   s    ,,.3335 6 )	J:&6a  ' 	v,7!	/v,7$5	2 	v,7!	/ '&s   B++B4c                 v   |dk(  rt        j                  d       | j                         \  }}|d|z  z
  }t        j                  g dg dg dg      }t        |||      }t        ||j                  |      }t        ||j                  |      } ||      } ||      d ||      z  z   }	t        ||	       y )	NrJ   *pchip does not make sense for complex data               @r;   r>   r@   rA                 ?)	rN   skipr7   r   r   r	   realimagr   )
r!   r   r"   r#   rC   rD   rinterpiinterprE   rF   s
             r(   test_complexz(TestRegularGridInterpolator.test_complex   s    WKKDE..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)rY   r-      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*   rH   rA   rJ   r3   r-   +=r   r]   rtol)r   meshgridr	   allclose)
r!   rr   rs   xgygr#   rH   rJ   
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 )NrQ   H@r0   r	   r   r   r   r!   r"   r#   rD   rC   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;   r>   r@   r   gq@g     \@r)   r	   r   r   r   r   s         r(   test_linear_xi3dz,TestRegularGridInterpolator.test_linear_xi3d   sY    ,,.(8/1D/1 223!&.&9r*   z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                 j    | j                         \  }}t        ||d      }t         ||      |       y )NnearestrA   )r)   r	   r   )r!   rC   r   r"   r#   rD   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   r   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   undefmethodrA   )r   r   r   r_   rO   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_   rO   )r!   r"   r#   rD   rC   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   rA   )gfffff[gfffff@g     grT   r   r   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   rA   )g333333(g33333`@g     gyXrT   r   r   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   rA   rT   r;   r>   r@   r   )r)   r	   r   nanr   r   r   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   rA   r;   r>   r@   )	r)   r	   	itertoolsproductr   r   reshaper   r   	r!   r"   r#   rD   points_qhullpvalues_qhullinterp_qhullrC   s	            r(   test_nearest_compare_qhullz6TestRegularGridInterpolator.test_nearest_compare_qhull  s    ,,.(	J ((&1#/0<a<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;   r>   r@   )	r)   r	   r   r   r   r   r   r   r   r   s	            r(   test_linear_compare_qhullz5TestRegularGridInterpolator.test_linear_compare_qhull  s    ,,.(8 ((&1#/0<a<0zz,/~~b)+L,G/1D/1 2!&.,v2FG 1s   	B*r   rT   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   r-      rY      r   r   rA   r   ffffff?)r   linspaceMyValuer	   _vr   )r!   r   rr   rs   r#   rD   rE   rF   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   r-   r   rY   r   r   y      ?       @)r   randomseedr   randr	   r_   rO   )r!   rr   rs   r#   s       r(   test_invalid_fill_valuez3TestRegularGridInterpolator.test_invalid_fill_value6  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_typeC  sM    U3(.51"))A,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 Nrp   rq   s     r(   fz;TestRegularGridInterpolator.test_length_one_axis.<locals>.fO  s    q5Lr*   rY   r   rm   Trn   sparserT   Fe   r   r   r   r   )r-         ru   r\   gffffff?333333@)333333@333333@r   r   r   333333?g      '@g?g      )@r[   r3   gffffff?r   g?gffffff@rl   r   )r   r   rx   r	   r   r^   r   )r!   r   rr   rs   datarD   s         r(   test_length_one_axisz0TestRegularGridInterpolator.test_length_one_axisK  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   r-   r   r   rY   r   )
r   r   pisinr	   zerosvstackTr   r   )r!   r   r   optionsrr   zfafbx1azay1bzbs               r(   test_length_one_axis2z1TestRegularGridInterpolator.test_length_one_axis2v  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)rY   r-   rl   r   rY   Fr      lJ r   sizer   r   ignoreinvalid)rl   rY   )	r	   r   isnanr   r   default_rngerrstater   r   )	r!   r   r   rngrr   iresrs   r   s	            r(   test_nan_x_1dz)TestRegularGridInterpolator.test_nan_x_1d  sI    $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   rY   r-   )rY   rl   r   c                     | dz  |dz  z   S Nr-   rp   rq   s     r(   r   z4TestRegularGridInterpolator.test_nan_x_2d.<locals>.f  s    a4!Q$;r*   rm   Tr   Fr   r   r   r   r3   rY   r-   ru   r\   r   r   r   r   r      r   )r   r^   rx   r	   r   r   r   r   r   r   r   r   )r!   r   rr   rs   r   rz   r{   r   rD   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 [[*3-!Q01C +A.xxA ii##J/JJCJ "1$JJCJ "ZZSZ!C'ZZSZ!C'G""HHaV[[*
 )C + 	SVRVV$S!WfQrUm,/ +* +*s   >G/&	G</G9<Hr   )ndimsfuncr-   c                 $    d| dz  z  d|dz  z  z   S Nr-   rl   rp   rq   s     r(   rt   z$TestRegularGridInterpolator.<lambda>  s    Q!Va!q&j0r*   rl   c                 *    d| dz  z  d|dz  z  z   |z
  S r  rp   )rr   rs   r   s      r(   rt   z$TestRegularGridInterpolator.<lambda>  s    AQJQ!V3a7r*   r   c                 0    d| dz  z  d|dz  z  z   |z
  |z   S r  rp   rr   rs   r   as       r(   rt   z$TestRegularGridInterpolator.<lambda>  s#    q16zAQJ6:Q>r*   c                 6    d| dz  z  d|dz  z  z   |z
  ||z  z   S r  rp   )rr   rs   r   r  bs        r(   rt   z$TestRegularGridInterpolator.<lambda>  s'    !a1f*q16z"9A"=A"Er*   c                    |dk\  r|dv rt        j                  d       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 )Nr   >   rH   rI   z-too slow; OOM (quintic); or nearly so (cubic)*   rY   r   r-   r      rm   Tr   rA   r   )rN   re   r   r   r   uniformranger   rx   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  sG    A:&$88KKGHii##B'
kk*kE
kK &+5\3%1 KK
KD%1 	 3  .>6:48": ; 33C3C:@B ,K80@A0@"R"X0@A "++/@7;59#; < 44E4E;AC .k:+->?+3 Bs   %D8D
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  rp   rq   s     r(   val_func_2dzJTestRegularGridInterpolator.test_invalid_points_order.<locals>.val_func_2d   s    qAv:AF
**r*   r   r4   r         @      @r   r4   r6   r+  r,  rm   Tr   (must be strictly ascending or descendingrL   )r   r^   rx   rN   r   rO   r	   )r!   r)  rr   rs   r"   r#   rM   s          r(   test_invalid_points_orderz5TestRegularGridInterpolator.test_invalid_points_order  su    	+ HH*+HH*+Qbkk6D157 8:]]:U3#FF3 433s   ,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   rD   s      r(   test_fill_valuez+TestRegularGridInterpolator.test_fill_value  s@    ("))A,06ULxxt%%%r*   c                    |dk(  rt        j                  d       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 NrI   Way too slow.r   r   r   r3   r4   r5   r-   )r   r.   r/         .@r         9@r   )r   r   r   r   r  )r   rl   r   Fr  )r   rl   r  err_msgr  .rY   r   ru   r]   r9  )rN   re   r   r   r   r	   r   r   r  appendr^   	transposer   )r!   r   r"   r   r#   rC   rD   vvsjrF   s              r(   test_nonscalar_valuesz1TestRegularGridInterpolator.test_nonscalar_values  s    YKK( 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           	         |dv rt        j                  d       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>   rH   rI   r4  r5  r2   )r   r.   r/   r6  r   r7       A@      B@)	r   r.   r/   r6  r   r7  rD  rE  /   r   rl   r-   r   r   r  	   r   Fr  rY   r   .r   axisru   r:  )rN   re   tuplereversedr   r   r   r	   r   emptyr  itemexpand_dimsr   )r!   r   rA  r"   r   r   trailing_pointsr#   rC   rD   r=  r>  r   r?  rF   s                  r(   test_nonscalar_values_2z3TestRegularGridInterpolator.test_nonscalar_values_21  si    ))KK(D 289&QeHQK(&F9ii##D) Q1a:/:;A(6;=6N ww1///// XXfll23'(v||B'(A6<<+,0Q	9J8>>CE "&>..01a4	 - ) ^^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 )NrT   r5  r2   r   )rl   r   r   r   r-   Fr  rY   rI  r   .r   rJ  ru   r:  )
r   r   r   r	   r   rN  r  rO  rP  r   )r!   r   r"   r   rQ  r#   rC   rD   r=  r>  r   r?  rF   s                r(   test_nonscalar_values_linear_2Dz;TestRegularGridInterpolator.test_nonscalar_values_linear_2D\  s3   059 ii##D) Q4O45A(6;=6N ww1///// XXfll23'(v||B'(A6<<+,0Q	9J8>>CE "&>..01a4	 - ) ^^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  rp   rq   s     r(   r   z:TestRegularGridInterpolator.test_float32_values.<locals>.f  s    q!t8a!Q$h&&r*   rY   r   r   r      rm   Tr   r   g@ffffff
@g@r   g Y`@g{,c@gHz>r\   )r   r   rx   astyper	   r^   r   )r!   r   rU  r   rr   rs   rz   r{   r   rD   ptss              r(   test_float32_valuesz/TestRegularGridInterpolator.test_float32_values{  s    	' KK1b!KK1b!QD>BRy{{5!(!Q6hhc
c
$+35 	slL%AMr*   c                 T   t        j                  ddd      }t        j                  ddd      }t        j                  ||dd      \  }}||z   }t        t              5  t        ||f|d        d d d        t        t              5  t        ||f|d	d
        d d d        t        t              5  t        ||f|d	d d       d d d        t        t              5  t        ||f|d	ddi       d d d        y # 1 sw Y   xY w# 1 sw Y   lxY w# 1 sw Y   MxY w# 1 sw Y   y xY w)Nr   rl   r   rm   Tr   c                     | S r   rp   rr   s    r(   rt   z=TestRegularGridInterpolator.test_bad_solver.<locals>.<lambda>  s    1r*   )solverrU   c                     | S r   rp   r_  s    r(   rt   z=TestRegularGridInterpolator.test_bad_solver.<locals>.<lambda>      r*   )r   r`  c                     | S r   rp   r_  s    r(   rt   z=TestRegularGridInterpolator.test_bad_solver.<locals>.<lambda>  rb  r*   woof)r   r`  rd  r  )r   solver_args)r   r   rx   r_   rO   r	   	TypeError)r!   rr   rs   rz   r{   r   s         r(   test_bad_solverz+TestRegularGridInterpolator.test_bad_solver  s    KK1a KK1a QD>BBw :&#QFDE ' 9%#AY{ & 9%#AY{ & 9%#AYfb\ &% '& &% &% &%s0   C:D2DD:DDDD')4__name__
__module____qualname__r)   r0   r7   r9   parametrize_rgi_interp_methodsrG   rN   markparametrizerP   r   r   rW   r`   rj   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  	fail_slowr&  r/  r1  r@  rR  rT  float32float64	complex64
complex128r\  rg  rp   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 [[1#[[.	
01	
78	
>?	
EF	1 @ $ @B4 $& $&
 [[1#; $ ;: $[[]UDM:'; ; $';R;> [[	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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__  s3    	
))BGGEN+33E:r*   c                      | j                   |   S r   )r   )r!   idxs     r(   __getitem__zMyValue.__getitem__  s    wws|r*   c                      y r   rp   )r!   s    r(   __array_interface__zMyValue.__array_interface__  s    r*   Nc                     t        d      )NzNo array representation)RuntimeError)r!   r   copys      r(   	__array__zMyValue.__array__  s    455r*   )NN)rh  ri  rj  __doc__rw  rz  r|  r  rp   r*   r(   r   r     s    ;
6r*   r   c                      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j"                  j%                  d      ed               Zed        Zd Zed        Zd Zd Zej"                  j3                  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"                  j3                  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   r4   r6   r+  r,  g      @)rY   r-   rY   r-   rY   rY   )rY   r-   rl   r-   rY   rY   )rY   r-   r-   r-   rY   rY   )r   r^   )r!   rr   rs   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rY   ffffff@r   r   rY  333333?rl   rY   rY  r  r+  r.   r   rl   	splinef2drA   r   rY   )r  r   r   r^   r   r   r
   ev)r!   rr   rs   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 )Nr  r  rA   r8  )r  r   r^   r   r
   rB   r   )r!   r   rr   rs   r   r!  rE   rF   s           r(   rG   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-  rY   r-   rY   r-   rY   rY   r-   rl   r-   rY   rY   r-   r-   r-   rY   rY   r  r   r   rY  r  rl   rY   rY  r  g      r.   r   rl   r  FR?@r   r   rY   r-   r   )	r   r^   r   r   r
   r  r   r_   rO   )r!   rr   rs   r   r  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 r,   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 )NrQ   rT   rA   r  r	   r   r   r
   r   r!   r"   r#   	interp_rgrC   r   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r<   r   g333333$@rR   r  rT   Fr   r  r   r   r
   r   r!   r"   r#   rC   r   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   rA   rQ   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 )NrQ   F)r   )r  r   r   r
   r   r!   r"   r#   rC   rE   rF   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   r-   rl   r   r   Fr  r-   rl   r   )
r  r   r   r   r   r
   r   r   r   r   r  s         r(   
test_xi_ndzTestInterpN.test_xi_nd3  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   rY   r-   rl   Fr  r  )r  r   r   r
   r   r   rx   c_r   ravelr   r   )r!   r   rr   rs   r#   r"   r!  yirC   rE   xxyyrF   s                r(   test_xi_broadcastzTestInterpN.test_xi_broadcastB  s     ++-1fQ[[Aq![[Aq!QW+r$'{+VVVFORXXv&R$Brttzz|RTTZZ\12VVV"8BJJrxx01r*   r-   c           
         |dk(  rt        j                  d       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 r3  )rN   re   r   r   r   r
   r   r   r  r^   r<  r   )
r!   r   r"   r   r#   rC   r=  r?  r>  rF   s
             r(   r@  z!TestInterpN.test_nonscalar_valuesV  s     YKK( 11A5,9
9  ii##D)O,I&FFF6!&(QWWi8 498=3;a ffS!VnfV#(*3; 	 =XXb\##Aq!,2E6:	=s   C2c                 H   |dv rt        j                  d       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 )N>   rH   rI   r4  rC  r   rG  r   r   r  rH  r   Fr  rY   r   rI  .ru   r:  )rN   re   r   r   r   r
   r   r  r   r   r   )r!   r   r"   r   rQ  r#   rC   r=  r?  r   r>  s              r(   rR  z#TestInterpN.test_nonscalar_values_2p  s0    ))KK(D
 ii##D) Q1a:/:;AFFF6N ww1///// v||B/02 1A 6;6<<;K5L5L sAqy 16&%*,5L 1 	 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   rl   r   r   r   r   r  rA   )r  r   r   r   r   r_   rO   r
   )r!   r"   r#   rC   s       r(    test_non_scalar_values_splinef2dz,TestInterpN.test_non_scalar_values_splinef2d  si    --/
		t1aA.2q)j'666(	*r*   c                 l   |dk(  rt        j                  d       | j                         \  }}}||f}|d|z  z
  }t        j                  g dg dg      j
                  }t        ||||      }t        ||j                  ||      }t        ||j                  ||      }	|d|	z  z   }
t        ||
       y )NrJ   rb   rc   r  r  rA   rd   )
rN   re   r  r   r^   r   r
   rf   rg   r   )r!   r   rr   rs   r#   r"   rC   rE   v2rv2irF   s              r(   rj   zTestInterpN.test_complex  s    WKKDE++-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	        j
                  d      5  t        |||d       d d d        y # 1 sw Y   y xY w)Nrc   r  r  complexrL   rJ   rA   )r  r   r^   r   rN   deprecated_callr
   r!   rr   rs   r#   r"   rC   s         r(   test_complex_pchipzTestInterpN.test_complex_pchip  sv    ++-1fQ"V)#::< ==>Q 	##)4FFF7; 544s   A55A>c                     | j                         \  }}}||f}|d|z  z
  }t        j                  g dg dg      j                  }t	        t
              5  t        |||d       d d d        y # 1 sw Y   y xY w)Nrc   r  r  r  rA   )r  r   r^   r   r   r   r
   r  s         r(   test_complex_spline2fdz"TestInterpN.test_complex_spline2fd  sp    ++-1fQ"V)#::< ==>Q 	.)FFF;? *))s   A..A7r   rT   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   r-   r   rY   r   r   r   r   rA   )r   r   r   r
   r   r   )r!   r   rr   rs   r#   rE   rF   s          r(   r   z"TestInterpN.test_duck_typed_values  so    
 KK1a KK1a aVVc3Z?aVVYYc
6BBr*   c                    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                  |      ||      }|dk(  rt        ||d	d
       y t        ||       y )Nr   r-   r   rY   r   rl   rA   rI   g-C6
?g>rv   )r   r   r   r   r   r
   r   r   )r!   r   rr   rs   r#   rC   rE   rF   s           r(   test_matrix_inputzTestInterpN.test_matrix_input  s    KK1a KK1a 		q!,-1a(aVVVF;aVRZZ/GYBD9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)r<   rY   r   rY   g@g	@gffffff@)r-   rl   r   )gQ?gffffff@gffffff @r[   r\   r   r3   gffffffFr   )r   r^   r
   r   )r!   r#   r!  r   r   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  rp   r  s       r(   value_func_4dz9TestInterpN.test_descending_points.<locals>.value_func_4d  s'    qAv:AF
*Q.22r*   )r   rY   r-   rl   )r   r   r   r   )r   r<   r?   r   rm   Tr   r<   r   r   r   r   r   )r   r^   rx   r<  r   r
   r   )r!   r  x1x2x3x4r"   r#   r[  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.  rL   )r   r^   r   rN   r   rO   r
   )r!   rr   rs   r   r!  rM   s         r(   r/  z%TestInterpN.test_invalid_points_order  s    HH*+HH*+HHo%8 9XX679 ::;! 	 ;]]:U3QFAr" 433s   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   rY   r   rY   )rY   rY   rl   zaThe requested sample points xi have dimension 3, but this RegularGridInterpolator has dimension 1rL   )r   r   r_   rO   r
   )r!   r"   r#   r!  msgs        r(   test_invalid_xi_dimensionsz&TestInterpN.test_invalid_xi_dimensions  sI    QWWY9:S1FFB' 211s   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!   rr   rs   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!   rr   rs   r"   r#   r  r  s          r(   test_2d_readonly_gridz!TestInterpN.test_2d_readonly_grid8  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   r  r  c_contiguousr   r^   r
   r	   )r!   rr   rs   r   r"   r#   r  s          r(   test_non_c_contiguous_gridz&TestInterpN.test_non_c_contiguous_gridG  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   rr   rs   r"   r#   r  s          r(   test_endiannesszTestInterpN.test_endiannessT  sw     KK1au-KK1au-Qu-$U3&//6r*   N)$rh  ri  rj  r  r  rk  rG   r  r  r  r  r  r  r  r  r  rN   rl  rn  r@  rR  r  rj   r  r  rm  r   r  r   r  r/  r  r  r  r  r  rp   r*   r(   r  r    sP   > $0 $0;&=2=2 2 $2 $2& [[1#; $ ;0 $I $I@* $  $ $	<	@ [[	9 	  $$ $$ 1,84
#(777 [[Wuen5	7 6	7r*   r  )r   rN   numpyr   numpy.testingr   r   r   r   r   r   r_   scipy.interpolater	   r
   r   r   r   scipy.sparse._sputilsr   scipy._lib._utilr   rl  rm  _ALL_METHODSrk  r   r   r  rp   r*   r(   <module>r     sw      J J *L L ) + "(!8!8%22" [
 [
|6 6(V7 V7r*   