
    Owgۅ                         d dl Zd dlZd dlmc mZ d dlZd dlm	Z	m
Z
mZmZmZ d dlmZ  ej"                  g d      d        Z ej"                  g d      d        Z G d d	      Zy)
    N)Index
MultiIndexSeries
date_rangeisna)linearindexvaluesnearestslinearzero	quadraticcubicbarycentrickrogh
polynomialsplinepiecewise_polynomialfrom_derivativespchipakimacubicspline)paramsc                 6    | j                   }|dv rddini }||fS )a	  Fixture that returns an (method name, required kwargs) pair.

    This fixture does not include method 'time' as a parameterization; that
    method requires a Series with a DatetimeIndex, and is generally tested
    separately from these non-temporal methods.
    r   r   order   paramrequestmethodkwargss      c/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/tests/series/methods/test_interpolate.pynontemporal_methodr%      s*    8 ]]F#'??gq\RF6>    )r   r   r   r   r   r   r   r   r   r   r   r   r   r   c                 6    | j                   }|dv rddini }||fS )zFixture that returns a (method name, required kwargs) pair to
    be tested for various Index types.

    This fixture does not include methods - 'time', 'index', 'nearest',
    'values' as a parameterization
    r   r   r   r   r    s      r$   interp_methods_indr(   2   s*    2 ]]F#'??gq\RF6>r&   c                      e Zd Zej                  j                  d      d        Zd Zd Zd Z	d Z
d Zd	 Zd
 Zej                  j                  di  ej                  ddd ej"                  d            g      d        Zd Zd Zej                  j                  di  ej                  ddd ej"                  d            g      d        Zd Zd Zd Zd Zd Zej                  j                  dddg      d        Zd Zej                  j                  dd d!g      d"        Zd# Zd$ Zd% Z d& Z!d' Z"ej                  j                  d(g d)      d*        Z#ej                  j                  d+e$jJ                  e$jJ                  d,e$jJ                  e$jJ                  e$jJ                  d-e$jJ                  e$jJ                  g	e$jJ                  e$jJ                  d.d.d.d.d/e$jJ                  e$jJ                  g	d0d1d2fe$jJ                  e$jJ                  d,e$jJ                  e$jJ                  e$jJ                  d-e$jJ                  e$jJ                  g	e$jJ                  e$jJ                  d.d.e$jJ                  e$jJ                  d/e$jJ                  e$jJ                  g	d0d1dd3fe$jJ                  e$jJ                  d,e$jJ                  e$jJ                  e$jJ                  d-e$jJ                  e$jJ                  g	e$jJ                  e$jJ                  d.e$jJ                  e$jJ                  e$jJ                  d/d/d/g	d0d4d2fe$jJ                  e$jJ                  d,e$jJ                  e$jJ                  e$jJ                  d-e$jJ                  e$jJ                  g	e$jJ                  e$jJ                  d.e$jJ                  e$jJ                  e$jJ                  d/d/e$jJ                  g	d0d4dd3fe$jJ                  e$jJ                  e$jJ                  e$jJ                  e$jJ                  e$jJ                  e$jJ                  ge$jJ                  e$jJ                  e$jJ                  e$jJ                  e$jJ                  e$jJ                  e$jJ                  gd0d4dd3f e&d5       e&d5      d0d4dd3ff      d6        Z'ej                  j                  d+e$jJ                  e$jJ                  d,e$jJ                  e$jJ                  e$jJ                  d-e$jJ                  e$jJ                  g	e$jJ                  e$jJ                  d.d/d/d/d/e$jJ                  e$jJ                  g	d7d1d2fe$jJ                  e$jJ                  d,e$jJ                  e$jJ                  e$jJ                  d-e$jJ                  e$jJ                  g	e$jJ                  e$jJ                  d.e$jJ                  e$jJ                  d/d/e$jJ                  e$jJ                  g	d7d1dd3fe$jJ                  e$jJ                  d,e$jJ                  e$jJ                  e$jJ                  d-e$jJ                  e$jJ                  g	d.d.d.e$jJ                  e$jJ                  e$jJ                  d/e$jJ                  e$jJ                  g	d7d4d2fe$jJ                  e$jJ                  d,e$jJ                  e$jJ                  e$jJ                  d-e$jJ                  e$jJ                  g	e$jJ                  d.d.e$jJ                  e$jJ                  e$jJ                  d/e$jJ                  e$jJ                  g	d7d4dd3ff      d8        Z(d9 Z)d: Z*d; Z+d< Z,ej                  j                  d=d> ej                  d? ej"                  d            g      d@        Z-dA Z.ej                  j                  dBdCd0g      dD        Z/dE Z0dF Z1ej                  j                  dBddGg      dH        Z2ej                  j                  dIddJddKe$jJ                  g      dL        Z3dM Z4dN Z5dO Z6dP Z7dQ Z8dR Z9dS Z:ej                  j                  dTg dU e;jx                  dVdWX       e;jz                  ddWY      g      dZ        Z>d[ Z?ej                  j                  d\d?g d]fd>g d^fg      d_        Z@d` ZAda ZBy )bTestSeriesInterpolateDataz)EA.fillna does not handle 'linear' methodreasonc                 .   t        t        dd            }|j                         }t        j                  |d<   |j
                  j                  d      }|j                         }|j
                  j                  d      }t        j                  ||       y )Nz
2012-01-01   )periods   D)
r   r   copypdNaTdt	to_periodinterpolatetmassert_series_equal)selforigserser_perres_perexpected_pers         r$   test_interpolate_period_valuesz8TestSeriesInterpolateData.test_interpolate_period_valuesQ   ss    jq9:iikA &&""3'%%'ww((-
w5r&   c                 J   t        t        j                  t        |      t              |j
                        }|j                         }t        j                  |dd |j                  d      }t        j                  ||       t        |j
                  D cg c]  }|j                          c}|j
                        j                  t              }|j                         }t        j                  |dd |j                  d      }t        j                  ||       y c c}w )Ndtyper.   
   r   r"   r	   time)r   nparangelenfloatr	   r2   nanr7   r8   r9   	toordinalastype)	r:   datetime_serieststs_copylinear_interpdord_tsord_ts_copytime_interps	            r$   test_interpolatez*TestSeriesInterpolateData.test_interpolate]   s    BIIc/2%@/BWBWX'')"++8+<
}b1$3$9$9:qQ[[]:/BWBW

&- 	 kkmFFAb!--V-<
{F3 ;s   D c                     t        dddt        j                  g      }d}t        j                  t
        |      5  |j                  d       d d d        y # 1 sw Y   y xY w)Nr   r   r0   zGtime-weighted interpolation only works on Series.* with a DatetimeIndexmatchrG   rE   r   rH   rL   pytestraises
ValueErrorr7   )r:   non_tsmsgs      r$   /test_interpolate_time_raises_for_non_timeserieszITestSeriesInterpolateData.test_interpolate_time_raises_for_non_timeseriesp   sT     Aq"&&)*W]]:S1 	.f-	. 	. 	.s   AA c                 v   t        j                  d       t        g d      }t        g dt        g d            }|j                  j                  t        g d            j                  t              }|j                  |      j                  d      j                  d	d
 }t        j                  ||       y )NscipyrD            	      &@g     &@g      '@g     '@      (@g     (@g      )@g     )@      *@	      ?      ?      ?      ?       @      @      @      @      @rF   rn   ro   rp   rr   rs   rt   r   rE   r      )r\   importorskipr   r   r	   unionrN   rK   reindexr7   locr8   r9   )r:   r<   expected	new_indexresults        r$   test_interpolate_cubicsplinez6TestSeriesInterpolateData.test_interpolate_cubicsplinex   s    G$%&KIJ

 IIOOE*L$MNUU
	 Y'33=3IMMaPQR
vx0r&   c                    t        j                  d       t        t        j                  t        j
                  j                  d      j                  d                  }|j                  j                  t        g d            j                  t              }|j                  |      j                  d      }|j                  dd	  y )
Nrc   r0   d   )size)g     H@g     H@g     H@g      I@g     @I@g     `I@r   rE   1   3   )r\   rx   r   rH   sortrandomdefault_rnguniformr	   ry   r   rN   rK   rz   r7   r{   )r:   r<   r}   interp_ss       r$   test_interpolate_pchipz0TestSeriesInterpolateData.test_interpolate_pchip   s    G$RWWRYY2215==3=GHI IIOO:;

&- 	 ;;y)55W5ERr&   c                    t        j                  d       t        g d      }t        g dt        g d            }|j                  j                  t        g d            j                  t              }|j                  |      j                  d      }t        j                  |j                  d	d
 |       t        g dt        g d            }|j                  j                  t        g d            j                  t              }|j                  |      j                  dd	      }t        j                  |j                  d	d
 |       y )Nrc   rd   rh   rl   rF   rv   r   rE   r   rw   )	ri   rm   rm   rm   rj   rm   rm   rm   rk   )r"   derr\   rx   r   r   r	   ry   rN   rK   rz   r7   r8   r9   r{   r:   r<   r|   r}   r   s        r$   test_interpolate_akimaz0TestSeriesInterpolateData.test_interpolate_akima   s   G$%& KIJ
 IIOOE*L$MNUU
	 ;;y)55W5E
x||Aa0(; <IJ
 IIOOE*L$MNUU
	 ;;y)55W!5L
x||Aa0(;r&   c                 v   t        j                  d       t        g d      }t        g dt        g d            }|j                  j                  t        g d            j                  t              }|j                  |      j                  d      }t        j                  |j                  d	d
 |       y )Nrc   rd   rh   rl   rF   rv   r   rE   r   rw   r   r   s        r$   %test_interpolate_piecewise_polynomialz?TestSeriesInterpolateData.test_interpolate_piecewise_polynomial   s    G$%&KIJ

 IIOOE*L$MNUU
	 ;;y)55=S5T
x||Aa0(;r&   c                 v   t        j                  d       t        g d      }t        g dt        g d            }|j                  j                  t        g d            j                  t              }|j                  |      j                  d      }t        j                  |j                  d	d
 |       y )Nrc   rd   rh   rl   rF   rv   r   rE   r   rw   r   r   s        r$   !test_interpolate_from_derivativesz;TestSeriesInterpolateData.test_interpolate_from_derivatives   s    G$%&KIJ

 IIOOE*L$MNUU
	 ;;y)55=O5P
x||Aa0(;r&   r#   r   r   r"   r   rc   )marksc                 ,   t        t        j                  t        j                  g      }t        j                   |j
                  di ||       t        g t              j                         }t        j                   |j
                  di ||       y )NrB    )r   rH   rL   r8   r9   r7   object)r:   r#   ss      r$   test_interpolate_cornersz2TestSeriesInterpolateData.test_interpolate_corners   sl     BFFBFF#$
}q}}6v6:2V$002
}q}}6v6:r&   c                 2   t        t        j                  t        j                  t        j                  j                  d      j	                  d                  }t        j                  j                  d      j                  d      |j                  d d d<   |j                  j                  j                  t              }|j                  d      }|j                         }t        |j                        }| }t        t        j                  ||   ||   |j                  |         |j                  |         }t!        j"                  ||   |       |j                  d      }t!        j"                  ||       t!        j"                  ||   |       y )	Nr0      rF   rD   rw   r	   rE   r
   )r   rH   rL   r   r   r   standard_normalr{   r	   r
   rN   rK   r7   r2   r   interpr8   r9   )r:   r   valsr~   r|   badgoodother_results           r$   test_interpolate_index_valuesz7TestSeriesInterpolateData.test_interpolate_index_values   s)   266)>)>q)A)H)H)L!MNYY**1-==bAcc
ww~~$$U+g.6688??#tIId3idQXXd^<AGGCL
 	vc{H5 }}H}5
|V4
|C0(;r&   c                    t        ddt        j                  t        j                  t        j                  dg      }d}t        j                  t
        |      5  |j                  d       d d d        y # 1 sw Y   y xY w)Nr   rw   re   zStime-weighted interpolation only works on Series or DataFrames with a DatetimeIndexrY   rG   rE   r[   r:   r   r`   s      r$   test_interpolate_non_tsz1TestSeriesInterpolateData.test_interpolate_non_ts   sb    Aq"&&"&&"&&"56# 	 ]]:S1 	)MMM(	) 	) 	)s   A55A>c                     t        ddt        j                  dg      } |j                  di |}t        g d      }t	        j
                  ||       y )Nr   r   rw           rm   rq   ru   r   r   rH   rL   r7   r8   r9   )r:   r#   r   r~   r|   s        r$   test_nan_interpolatez.TestSeriesInterpolateData.test_nan_interpolate   sI     Aq"&&!$%((./
vx0r&   c                     t        ddt        j                  dgg d      }|j                         }t        g dg d      }t	        j
                  ||       y )Nr   r0      )r   rw   r.   	   rF   )rm   rq   ru         @r   r:   r   r~   r|   s       r$   test_nan_irregular_indexz2TestSeriesInterpolateData.test_nan_irregular_index
  sC    Aq"&&!$L9.lC
vx0r&   c                     t        dddt        j                  gt        d            }|j	                         }t        g dt        d            }t        j                  ||       y )Nr   r   r0   abcdrF   )r   rm   rq   rq   )r   rH   rL   listr7   r8   r9   r   s       r$   test_nan_str_indexz,TestSeriesInterpolateData.test_nan_str_index  sK    Aq!RVV$DL9.d6lC
vx0r&   c                     t        j                  d       t        ddt        j                  dgg d      }|j                  d      }t        g d	g d      }t        j                  ||       y )
Nrc   r   r      )r   r0   rw   r   rF   r   rE   )rm   r         "@g      0@r\   rx   r   rH   rL   r7   r8   r9   )r:   sqr~   r|   s       r$   test_interp_quadz*TestSeriesInterpolateData.test_interp_quad  sV    G$Q2662&l;{3/|D
vx0r&   c                    t        j                  d       t        ddt        j                  dt        j                  dg      }t        g d      }|j                  d      }t        j                  ||       d	}t        j                  t        |
      5  |j                  dd      }d d d        t        j                  ||       t        g d      }|j                  d      }t        j                  ||j                  d             t        j                  t        |
      5  |j                  dd      }d d d        t        j                  ||       t        g d      }|j                  d      }t        j                  ||j                  d             t        j                  t        |
      5  |j                  dd      }d d d        t        j                  ||       t        g d      }|j                  d      }t        j                  ||       t        j                  t        |
      5  |j                  dd      }d d d        t        j                  ||       t        g d      }|j                  d      }t        j                  ||       y # 1 sw Y   xY w# 1 sw Y   vxY w# 1 sw Y   xY w# 1 sw Y   {xY w)Nrc   r   rw   rf      )rm   ru   g      @rj   g     2@      9@r   rE   z:The 'downcast' keyword in Series.interpolate is deprecatedrY   infer)r"   downcast)r   rw   rw   rf   rf   r   r   rK   r   )r   ru   g:/KK@rj   gL82@r   r   )rm   ru   g333333@rj   g3333332@r   r   )r\   rx   r   rH   rL   r7   r8   r9   assert_produces_warningFutureWarningrN   r:   r   r|   r~   r`   s        r$   test_interp_scipy_basicz1TestSeriesInterpolateData.test_interp_scipy_basic  sK   G$Aq"&&"bffb12;<i0
vx0J''SA 	G]])g]FF	G
vx0/0i0
vxw'?@''SA 	G]])g]FF	G
vx0/0f-
vxw'?@''SA 	D]]&7]CF	D
vx0 CDk2
vx0''SA 	I]]+]HF	I
vx0;<g.
vx0?	G 	G	G 	G	D 	D	I 	Is0   J!&J.7J;9K!J+.J8;KKc                 
   t        ddt        j                  t        j                  t        j                  dg      }t        ddddt        j                  dg      }|j                  d	d
      }t	        j
                  ||       y )Nr   rw   re   rm   ru         @      @ri   r   r0   r"   limitr   r:   r   r|   r~   s       r$   test_interp_limitz+TestSeriesInterpolateData.test_interp_limitG  sb    Aq"&&"&&"&&"563S#rvvt<=ha8
vx0r&   r   r   c                     t        ddt        j                  dg      }|\  }}t        j                  t
        d      5   |j                  d||d| d d d        y # 1 sw Y   y xY w)Nr   r0   r   zLimit must be greater than 0rY   r   r"   r   r[   )r:   r%   r   r   r"   r#   s         r$   *test_interpolate_invalid_nonpositive_limitzDTestSeriesInterpolateData.test_interpolate_invalid_nonpositive_limitN  sd     Aq"&&!$%+]]:-KL 	@AMM?f??	@ 	@ 	@s   AA&c                     t        ddt        j                  dg      }|\  }}d}t        j                  t
        d      5   |j                  d||d| d d d        y # 1 sw Y   y xY w)	Nr   r0   r   rq   zLimit must be an integerrY   r   r   r[   )r:   r%   r   r"   r#   r   s         r$   $test_interpolate_invalid_float_limitz>TestSeriesInterpolateData.test_interpolate_invalid_float_limitV  sg    Aq"&&!$%+]]:-GH 	@AMM?f??	@ 	@ 	@s    AA(invalid_methodNnonexistent_methodc                 |   t        ddt        j                  dt        j                  dg      }d| d}|d}t        j                  t
        |      5  |j                  |	       d d d        t        j                  t
        |      5  |j                  |d
       d d d        y # 1 sw Y   AxY w# 1 sw Y   y xY w)Nr   rw   rf   r   zmethod must be one of.* Got 'z	' insteadz%'method' should be a string, not NonerY   rE   r   r   r[   )r:   r   r   r`   s       r$   test_interp_invalid_methodz4TestSeriesInterpolateData.test_interp_invalid_method^  s    Aq"&&"bffb12-n-=YG!9C]]:S1 	1MMM0	1
 ]]:S1 	;MMrM:	; 	;	1 	1
	; 	;s   B&	B2&B/2B;c                 L   t        ddt        j                  dt        j                  dg      }d}d}t        j                  t
        |      5  t        j                  t        |      5  |j                  dd	       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)
Nr   rw   rf   r   z:'fill_value' is not a valid keyword for Series.interpolate"Series.interpolate with method=padrY   pad)
fill_valuer"   )
r   rH   rL   r\   r]   r^   r8   r   r   r7   )r:   r<   r`   msg2s       r$   $test_interp_invalid_method_and_valuez>TestSeriesInterpolateData.test_interp_invalid_method_and_valuem  s    aBFFB34J3]]:S1 	<++MF <1U;<	< 	<< <	< 	<s$   B)B=BB	BB#c                 `   t        ddt        j                  t        j                  t        j                  dg      }t        ddddt        j                  dg      }|j                  d	d
d      }t	        j
                  ||       |j                  d	d
d      }t	        j
                  ||       y )Nr   rw   re   rm   ru   r   r   ri   r   r0   forwardr"   r   limit_directionFORWARDr   r   s       r$   test_interp_limit_forwardz3TestSeriesInterpolateData.test_interp_limit_forwardw  s    Aq"&&"&&"&&"56 3S#rvvt<=haS
vx0haS
vx0r&   c           
      J   t        t        j                  ddt        j                  t        j                  t        j                  dt        j                  g      }t        g d      }|j                  dd      }t	        j
                  ||       t        t        j                  dddd	d
ddg      }|j                  dd      }t	        j
                  ||       t        ddddd	d
dt        j                  g      }|j                  dd      }t	        j
                  ||       y )Nrm   ru   ri   )rm   rm   ru   r   r   r   ri   ri   r   bothr"   r   r   r   r   r   backwardr   r   s       r$   test_interp_unlimitedz/TestSeriesInterpolateData.test_interp_unlimited  s    BFFCbffbffbffdBFFKLDEhG
vx02663S#sD$GHh	J
vx03S#sCrvvFGh
K
vx0r&   c                    t        ddt        j                  t        j                  t        j                  dg      }d}t        j                  t
        |      5  |j                  ddd	       d d d        t        j                  t
        |      5  |j                  dd
       d d d        y # 1 sw Y   AxY w# 1 sw Y   y xY w)Nr   rw   re   zVInvalid limit_direction: expecting one of \['forward', 'backward', 'both'\], got 'abc'rY   r   r0   abcr   r   r[   r   s      r$   test_interp_limit_bad_directionz9TestSeriesInterpolateData.test_interp_limit_bad_direction  s    Aq"&&"&&"&&"56/ 	 ]]:S1 	KMMEMJ	K ]]:S1 	BMM5MA	B 	B		K 	K	B 	Bs   B.B:.B7:Cc                    t        t        j                  t        j                  dt        j                  t        j                  t        j                  dt        j                  t        j                  g	      }t        t        j                  t        j                  dddddt        j                  t        j                  g	      }|j                  dd	
      }t	        j
                  ||       t        t        j                  t        j                  ddt        j                  t        j                  dt        j                  t        j                  g	      }|j                  dd	d      }t	        j
                  ||       t        t        j                  t        j                  ddt        j                  ddt        j                  t        j                  g	      }|j                  dd	dd      }t	        j
                  ||       t        t        j                  t        j                  dt        j                  t        j                  t        j                  dddg	      }|j                  dd
      }t	        j
                  ||       t        t        j                  t        j                  dt        j                  t        j                  t        j                  ddt        j                  g	      }|j                  ddd      }t	        j
                  ||       t        t        j                  ddt        j                  t        j                  t        j                  ddt        j                  g	      }|j                  dddd      }t	        j
                  ||       t        dddt        j                  t        j                  t        j                  dt        j                  t        j                  g	      }|j                  ddd      }t	        j
                  ||       d}t        j                  t        |      5  |j                  dd
       d d d        y # 1 sw Y   y xY w)Nrw      ru   r   r         @r   r   insider"   
limit_arear   r"   r   r   r   )r"   r   r   r   outsider   )r"   r   r   zEInvalid limit_area: expecting one of \['inside', 'outside'\], got abcrY   r   )	r   rH   rL   r7   r8   r9   r\   r]   r^   r   s        r$   test_interp_limit_areaz0TestSeriesInterpolateData.test_interp_limit_area  s   BFFBFFArvvrvvrvvq"&&"&&QR2662663S#sBFFBFFSTh8D
vx0VVRVVS#rvvrvvsBFFBFFK
 h81M
vx02662663RVVS#rvvrvvVW&PQ  
 	vx02662663SRUVWh9E
vx0VVRVVS"&&"&&"&&#sBFFK
 h9AN
vx02663RVVRVVRVVS#rvvVW	6QR  
 	vx03S"&&"&&"&&#rvvrvvVW	:  
 	vx0 W]]:S1 	=MMeM<	= 	= 	=s   >QQ$z!method, limit_direction, expected))r   r   r   )ffillr   r   )backfillr   r   )bfillr   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   c                    t        g d      }d| d| d}d}t        j                  t        |      5  t	        j
                  t        |      5  |j                  ||       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr   r0   rw   z`limit_direction` must be 'z' for method ``zSeries.interpolate with method=rY   r   )r   r\   r]   r^   r8   r   r   r7   )r:   r"   r   r|   r   r`   r   s          r$   "test_interp_limit_direction_raisesz<TestSeriesInterpolateData.test_interp_limit_direction_raises  s     9+H:^F81M0]]:S1 	N++MF NV_MN	N 	NN N	N 	Ns#   BA5$B5A>	:BB
zdata, expected_data, kwargsrw   r   ru   r   r   r   r   r   r   r.   c                     t        |      }t        |      }d}t        j                  t        |      5   |j                  di |}d d d        t        j
                  |       y # 1 sw Y    xY w)Nr   rY   r   r   r8   r   r   r7   r9   r:   dataexpected_datar#   r   r|   r`   r~   s           r$   test_interp_limit_area_with_padz9TestSeriesInterpolateData.test_interp_limit_area_with_pad  se    L 4L-(2''SA 	-"Q]],V,F	-
vx0	- 	-   A&&A/r   c                     t        |      }t        |      }d}t        j                  t        |      5   |j                  di |}d d d        t        j
                  |       y # 1 sw Y    xY w)Nz$Series.interpolate with method=bfillrY   r   r   r   s           r$   $test_interp_limit_area_with_backfillz>TestSeriesInterpolateData.test_interp_limit_area_with_backfill  sd    8 4L-(4''SA 	-"Q]],V,F	-
vx0	- 	-r   c                 |   t        ddt        j                  t        j                  t        j                  dg      }t        ddt        j                  dddg      }|j                  d	d
d      }t	        j
                  ||       t        dddt        j                  ddg      }|j                  d	dd      }t	        j
                  ||       t        ddt        j                  t        j                  t        j                  ddt        j                  t        j                  dt        j                  g      }t        g d      }|j                  d	d
d      }t	        j
                  ||       t        dddt        j                  dddddddg      }|j                  d	dd      }t	        j
                  ||       y )Nr   rw   re   rm   ru   r   r   ri   r   r0   r   r   r   r   r   r   rf   )rm   ru   r   r   r   r   r         $@ri   rj   rj   r   r   r  rj   r   r   s       r$   test_interp_limit_directionz5TestSeriesInterpolateData.test_interp_limit_direction7  s[   Aq"&&"&&"&&"563RVVS#t<=haT
vx03S"&&#t<=haP
vx0 Aq"&&"&&"&&!QBFFSTUVhaP
vx0#sBFFCc4tTJ
 haP
vx0r&   c                 z   t        t        j                  t        j                  dddt        j                  g      }t        dddddt        j                  g      }|j                  ddd	
      }t	        j
                  ||       t        g d      }|j                  ddd
      }t	        j
                  ||       y )Nr.   r   r   r   r   r   r   r0   r   r   )r   r   r   r   r   r   r   r   r   s       r$   test_interp_limit_to_endsz3TestSeriesInterpolateData.test_interp_limit_to_endsP  s    BFFBFFAq!RVV453S#sBFF;<haT
vx089haP
vx0r&   c                    t        t        j                  t        j                  ddt        j                  t        j                  g      }t        t        j                  t        j                  dddt        j                  g      }|j                  ddd      }t	        j
                  ||       t        t        j                  dddt        j                  t        j                  g      }|j                  ddd	      }t	        j
                  ||       t        t        j                  ddddt        j                  g      }|j                  ddd
      }t	        j
                  ||       y )Nr.   r   r   r   r   r   r   r   r   r   r   r   s       r$   test_interp_limit_before_endsz7TestSeriesInterpolateData.test_interp_limit_before_ends\  s    BFFBFFAq"&&"&&9:2662663S"&&ABhaS
vx02663S"&&"&&ABhaT
vx02663S#rvv>?haP
vx0r&   c                     t        j                  d       t        g d      }|j                  dd      }t	        j
                  ||       |j                         }t	        j
                  ||       y )Nrc   r   r   r   r   )r\   rx   r   r7   r8   r9   )r:   r   r~   s      r$   test_interp_all_goodz.TestSeriesInterpolateData.test_interp_all_goodl  sY    G$9l!<
vq) 
vq)r&   check_scipyFTc                    t        j                  g d      }t        ddt        j                  g|      }|j                         }d|j                  d<   |j                         }t        j                  ||       d}|r8t        j                  t        |      5  |j                  dd       d d d        y y # 1 sw Y   y xY w)	N))r   a)r   b)r0   cr   r0   rF   z?Only `method=linear` interpolation is supported on MultiIndexesrY   r   r   )r   from_tuplesr   rH   rL   r2   r{   r7   r8   r9   r\   r]   r^   )r:   r  idxr   r|   r~   r`   s          r$   test_interp_multiIndexz0TestSeriesInterpolateData.test_interp_multiIndexv  s     $$%CDAq"&&>-668Q
vx0Oz5 <\;< < < <s   B88Cc                     t        j                  d       t        dt        j                  dgg d      }d}t        j
                  t        |      5  |j                  d	       d d d        y # 1 sw Y   y xY w)
Nrc   r   rw   )r   r0   r   rF   z8krogh interpolation requires that the index be monotonicrY   r   rE   r\   rx   r   rH   rL   r]   r^   r7   r   s      r$   test_interp_nonmono_raisez3TestSeriesInterpolateData.test_interp_nonmono_raise  s\    G$Arvvq>3H]]:S1 	*MMM)	* 	* 	*s   A//A8r"   r   c                    t        j                  d       t        dt        j                  dgt        dd|            }|dk(  rd nt        }d}t        j                  ||	      5  |j                  |
      }d d d        |&|j                         }t        j                  |       t        g dt        dd|            }t        j                  |       y # 1 sw Y   cxY w)Nrc   r   rw   1/1/2000r/   tzrF   r   0Series.interpolate with method=pad is deprecatedrY   rE   )rm   rm   ru   )r\   rx   r   rH   rL   r   r   r8   r   r7   r   r9   )	r:   r"   tz_naive_fixturedfwarnr`   r~   altr|   s	            r$   test_interp_datetime64z0TestSeriesInterpolateData.test_interp_datetime64  s    G$N*ZGW"X
 *t@''C8 	3^^6^2F	3((*C""63/Z7GH
 	vx0	3 	3s   &CC$c                    t        ddd      }t        |      }t        j                  |d<   d}t	        j
                  t        |      5  |j                  d	      }d d d        |j                         }t	        j                  |       t        |      }|d
   |d<   t	        j                  ||       y # 1 sw Y   YxY w)Nz
2015-04-05rw   z
US/Centralr  r   r  rY   r   rE   r   )
r   r   r3   r4   r8   r   r   r7   r   r9   )r:   dtir<   r`   r~   r  r|   s          r$   #test_interp_pad_datetime64tz_valuesz=TestSeriesInterpolateData.test_interp_pad_datetime64tz_values  s    q\BSkA@''SA 	3__E_2F	3 iik
vs+#;qk
vx0	3 	3s   
B55B>c                 r    t        g d      }|j                  d      }|}t        j                  ||       y )Nrm   rq   ru   r   )r   )r   r7   r8   r9   r   s       r$   test_interp_limit_no_nansz3TestSeriesInterpolateData.test_interp_limit_no_nans  s1    ?#Q'
vx0r&   r   c                     t        j                  d       t        ddt        j                  dg      }d}t        j
                  t        |      5  |j                  |       d d d        y # 1 sw Y   y xY w)Nrc   r   r   rw   z6You must specify the order of the spline or polynomialrY   rE   r  )r:   r"   r   r`   s       r$   test_no_orderz'TestSeriesInterpolateData.test_no_order  s_     	G$Aq"&&!$%F]]:S1 	)MMM(	) 	) 	)s   A,,A5r   g      r   c                     t        j                  d       t        ddt        j                  dg      }d}t        j
                  t        |      5  |j                  d|       d d d        y # 1 sw Y   y xY w)	Nrc   r   r   rw   z.order needs to be specified and greater than 0rY   r   r   r  )r:   r   r   r`   s       r$   %test_interpolate_spline_invalid_orderz?TestSeriesInterpolateData.test_interpolate_spline_invalid_order  s_    G$Aq"&&!$%>]]:S1 	8MMM7	8 	8 	8s   A--A6c           	          t        j                  d       t        ddt        j                  ddt        j                  dg      }|j                  dd      }t        g d	      }t        j                  ||       y )
Nrc   r   r0   r   r.   r   r   r   rm   rq   ru   r   r   r   r   r   r   s       r$   test_splinez%TestSeriesInterpolateData.test_spline  s^    G$Aq"&&!Q23ha8=>
vx0r&   c           	      f   t        j                  d       t        ddddt        j                  dt        j                  g      }|j                  ddd      }t        g d	      }t        j                  ||       |j                  ddd
      }t        g d      }t        j                  ||       y )Nrc   r   r0   rw   r      r   )r"   r   ext)rm   rq   ru   r   r   r   r   r   r,  r   )r:   r   result3	expected3result1	expected1s         r$   test_spline_extrapolatez1TestSeriesInterpolateData.test_spline_extrapolate  s    G$Aq!Q26623--xqa-@>?	
w	2--xqa-@>?	
w	2r&   c           	          t        j                  d       t        ddt        j                  ddt        j                  dg      }|j                  ddd	
      d   |j                  dd      d   k7  sJ y )Nrc   r   r0   r   gffffff@r   r   rw   r   )r"   r   r   r.   r   )r\   rx   r   rH   rL   r7   )r:   r   s     r$   test_spline_smoothz,TestSeriesInterpolateData.test_spline_smooth  sl    G$Aq"&&!S"&&!45MMaM8;}}HA}6q9:	
:r&   c                 n   t        j                  d       t        t        j                  d      dz  d      }t        j
                  |t        j                  j                  d      j                  ddd      <   |j                  d	d
      }|j                  d	d
      }t        j                  ||       y )Nrc   rD   r0   rK   rB   r   r   rw   r   r   r   )r\   rx   r   rH   rI   rL   r   r   integersr7   r8   r9   )r:   r   r3  r4  s       r$   test_spline_interpolationz3TestSeriesInterpolateData.test_spline_interpolation  s    G$299R=A%W58:"))


"
+
+Aq!
45--xq-9MMM;	
w	2r&   c                     t        dt        j                  dgt        j                  g d            }|j                  d      }t        g dt        j                  g d            }t        j                  ||       t        dt        j                  dgt        j                  g d            }|j                  d      }t        g d	t        j                  g d            }t        j                  ||       y )
Nr   rw   r   rF   rG   rE   r%  )r   r0   r   )rm   g(%?ru   )r   rH   rL   r3   to_timedeltar7   r8   r9   )r:   r  r~   r|   s       r$   test_interp_timedelta64z1TestSeriesInterpolateData.test_interp_timedelta64  s    QN"//)*DEv./1KL
vx0 QN"//)*DEv..booi6PQ
vx0r&   c                 @   t        ddd      }t        t        j                  j	                  d      j                  t        |            |      }t        j                  |d d d<   |j                  d      }|j                         }t        j                  ||       y )	Nr  z	1/20/2000r1   )freqr0   rF   r
   rE   )r   r   rH   r   r   r   rJ   rL   r7   r8   r9   )r:   rngrP   r~   exps        r$   %test_series_interpolate_method_valuesz?TestSeriesInterpolateData.test_series_interpolate_method_values  sw    [s;BII))!,<<SXFcR&&3Q3x0nn
vs+r&   c                 $   t        ddd      }t        g d|      }|j                  |t        j                  d      z         j                         }|j                  |      j                  d	      }t        ddd
      }t        g d|      }|j                  |t        j                  d      z         j                         }|j                  |      j                  d	      }t        j                  |j                  |j                         y )Nz1/1/2012r   12D)r/   r?  )r   rf      $   r   )daysrG   rE   12h)hours)r   r   appendr3   
DateOffsetsort_valuesrz   r7   r8   assert_numpy_array_equalr
   )r:   r	   rP   r}   rA  r~   s         r$    test_series_interpolate_intradayz:TestSeriesInterpolateData.test_series_interpolate_intraday  s    :qu=OU+LLA)>!>?KKM	jj#//v/>:qu=OU+LLQ)?!?@LLN	I&22&2A
##FMM3::>r&   ind)r  r  r  rS   z
2019-01-01r   startr/   )rQ  endc                    t        j                  ddt        j                  dg|      }|\  }}|dk(  rt	        j
                  d       |dk(  r< |d   j                  di |}t        g dd|	      }t        j                  ||       y d
| d}t	        j                  t        |      5   |d   j                  dd|i| d d d        y # 1 sw Y   y xY w)Nr   r   rw   rF   r   rc   r   r   namer	   z9Index column must be numeric or datetime type when using z_ method other than linear. Try setting a numeric or datetime index column before interpolating.rY   r"   r   )r3   	DataFramerH   rL   r\   rx   r7   r   r8   r9   r]   r^   )	r:   r(   rO  r  r"   r#   r~   r|   expected_errors	            r$   test_interp_non_timedelta_indexz9TestSeriesInterpolateData.test_interp_non_timedelta_index  s     \\1a+37+W(X&RU&&00F2#FH""684 !!!  z@ ;!1!!::6:; ; ;s   +CCc                    t        j                  d       t        j                  dd      }t        j                  ddt
        j                  dg|      }|\  }}|dv r2|j                  t         j                  j                  | d	
              |d   j                  dd|i|}t        g dd|      }t        j                  ||       y)z
        Tests for non numerical index types  - object, period, timedelta
        Note that all methods except time, index, nearest and values
        are tested here.
        rc   r   r   rP  r   rw   rF   >   r   r   z2 interpolation is not supported for TimedeltaIndexr+   r"   r   rT  Nr   )r\   rx   r3   timedelta_rangerV  rH   rL   applymarkermarkxfailr7   r   r8   r9   )	r:   r!   r(   rO  r  r"   r#   r~   r|   s	            r$    test_interpolate_timedelta_indexz:TestSeriesInterpolateData.test_interpolate_timedelta_index4  s     	G$  q!4\\1a+37+&&!!$X%WX " 
 #A"";&;F;.QcB
vx0r&   zascending, expected_values)r   r0   rw   r   rD   rD   r   rw   r0   r   c                     t        ddt        j                  ddgg d      }|j                  |      j	                  d	      }t        ||t
        
      }t        j                  ||       y )NrD   r   r0   r   r_  )r   r	   )	ascendingr	   rE   )r   r	   rC   )r   rH   rL   
sort_indexr7   rK   r8   r9   )r:   ra  expected_valuesrP   r~   r|   s         r$   test_interpolate_unsorted_indexz9TestSeriesInterpolateData.test_interpolate_unsorted_indexK  s\     "aA.6FG3??w?OoUS
vx0r&   c                    t        g dt              }d}d}t        j                  t        |      5  t        j                  t        |      5  |j                  d       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)N)r  Nr  rB   z$Series.interpolate with object dtypezInvalid fill methodrY   asfreqrE   )	r   r   r\   r]   r^   r8   r   r   r7   )r:   r<   r   r`   s       r$   test_interpolate_asfreq_raisesz8TestSeriesInterpolateData.test_interpolate_asfreq_raisesV  st    %V45#]]:S1 	1++MF 1x01	1 	11 1	1 	1s#   A?A3"A?3A<	8A??Bc                 4   t        j                  d       t        t        j                  ddt        j                  dt        j                  g      }|j                  dd      }t        t        j                  dddddg      }t        j                  ||       y )Nrc   r   r   rw   r   )r"   r   r   )r:   r<   r~   r|   s       r$   test_interpolate_fill_valuez5TestSeriesInterpolateData.test_interpolate_fill_value^  sp    G$bffaBFFArvv67	a@2661aAq12
vx0r&   )C__name__
__module____qualname__r\   r\  r]  r@   rW   ra   r   r   r   r   r   parametrizer   td
skip_if_nor   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rH   rL   ranger   r  r  r  r	  r  r  r  r   r#  r&  r(  r*  r-  r5  r7  r:  r=  rB  rN  r3   period_rangeinterval_rangerX  r^  rd  rg  ri  r   r&   r$   r*   r*   P   s   [[IJ	6 K	64&.1
<4<< [[FLL'!4MBMM'<R	
;;<.) [[FLL'!4MBMM'<R	
11111(1T1 [[Wr1g.@ /@@ [[-6J/KL; M;<
11B-=^ [[+		
NN [[% BFFBFFBFFArvvrvvNc3S"&&"&&I 9 BFFBFFBFFArvvrvvNc2662663O 1E BFFBFFBFFArvvrvvNbffbffbffc3L 	: BFFBFFBFFArvvrvvNbffbffbffc3O 	AF HH 	AF aa 	AF5	
"F1G"F1 [[% BFFBFFBFFArvvrvvNc3S"&&"&&I"(; BFFBFFBFFArvvrvvNbffbffc3O"(QG BFFBFFBFFArvvrvvNc3RVVRVVL")< BFFBFFBFFArvvrvvNc2662662663O")aH!	
2132112
11 * [[|v||Dg8NOP<<* [[X	5'9:1 ;1(1"1 [[Xh'?@) A) [[Wr4C&@A8 B81	3
31	,? [[ BOO,:BA1-	
;;,1. [[$
 	!E+;#<=1	111r&   r*   )numpyrH   r\   pandas.util._test_decoratorsutil_test_decoratorsrn  pandasr3   r   r   r   r   r   pandas._testing_testingr8   fixturer%   r(   r*   r   r&   r$   <module>r{     sw      ) )    *	+*	 $	%$	T1 T1r&   