
    Piy                         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dS )
    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                 ,    | 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      /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/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                 ,    | 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                            d          d             Zd Zd Zd Z	d Z
d Zd	 Zd
 Zej                            di  ej        ddd ej        d                    g          d             Zd Zd Ze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                            dddg          d             Zd Zej                            dd d!g          d"             Zd# Zd$ Zd% Z d& Z!ej                            d'e"j#        e"j#        d(e"j#        e"j#        e"j#        d)e"j#        e"j#        g	d*d+d,fe"j#        e"j#        d(e"j#        e"j#        e"j#        d)e"j#        e"j#        g	d*d+dd-fe"j#        e"j#        d(e"j#        e"j#        e"j#        d)e"j#        e"j#        g	d*d.d,fe"j#        e"j#        d(e"j#        e"j#        e"j#        d)e"j#        e"j#        g	d*d.dd-fe"j#        e"j#        e"j#        e"j#        e"j#        e"j#        e"j#        gd*d.dd-f e$d/          d*d.dd-ff          d0             Z%ej                            d'e"j#        e"j#        d(e"j#        e"j#        e"j#        d)e"j#        e"j#        g	d1d+d,fe"j#        e"j#        d(e"j#        e"j#        e"j#        d)e"j#        e"j#        g	d1d+dd-fe"j#        e"j#        d(e"j#        e"j#        e"j#        d)e"j#        e"j#        g	d1d.d,fe"j#        e"j#        d(e"j#        e"j#        e"j#        d)e"j#        e"j#        g	d1d.dd-ff          d2             Z&d3 Z'd4 Z(d5 Z)d6 Z*ej                            d7d8 ej        d9 ej        d                    g          d:             Z+d; Z,ej                            d<d=d*g          d>             Z-d? Z.d@ Z/ej                            d<ddAg          dB             Z0ej                            dCddDddEe"j#        g          dF             Z1dG Z2dH Z3dI Z4dJ Z5dK Z6dL Z7dM Z8ej                            dNg dO e9j:        dPdQR           e9j;        ddQS          g          dT             Z<dU Z=ej                            dVd9g dWfd8g dXfg          dY             Z>dZ Z?d[ Z@d S )\TestSeriesInterpolateDataz)EA.fillna does not handle 'linear' methodreasonc                 B   t          t          dd                    }|                                }t          j        |d<   |j                            d          }|                                }|j                            d          }t          j	        ||           d S )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   s    jq999::iikkA &""3''%%''w((--
w55555r&   c                 X   t          t          j        t          |          t                    |j                  }|                                }t          j        |dd<   t          j        |dd<   |                    d          }t          j
        ||           t          d |j        D             |j        	                              t                    }|                                }t          j        |d
d<   |                    d          }t          j
        ||           d S )Ndtyper         	   r   r"   c                 6    g | ]}|                                 S  )	toordinal).0ds     r$   
<listcomp>z>TestSeriesInterpolateData.test_interpolate.<locals>.<listcomp>l   s     :::qQ[[]]:::r&   r	   r.   
   time)r   nparangelenfloatr	   r2   nanr7   r8   r9   astype)r:   datetime_serieststs_copylinear_interpord_tsord_ts_copytime_interps           r$   test_interpolatez*TestSeriesInterpolateData.test_interpolate]   s
   BIc/22%@@@/BWXX''))
 v!v!++8+<<
}b111::O$9:::/BW
 
 

&-- 	 kkmmFAbD!--V-<<
{F33333r&   c                     t          dddt          j        g          }d}t          j        t
          |          5  |                    d           d d d            d S # 1 swxY w Y   d S )Nr   r   r0   zGtime-weighted interpolation only works on Series.* with a DatetimeIndexmatchrP   rG   r   rQ   rU   pytestraises
ValueErrorr7   )r:   non_tsmsgs      r$   /test_interpolate_time_raises_for_non_timeserieszITestSeriesInterpolateData.test_interpolate_time_raises_for_non_timeseriesu   s     Aq"&)**W]:S111 	. 	.f---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   AA#&A#c                    t          j        d           t          g d          }t          g dt          g d                    }|j                            t          g d                                        t                    }|                    |          	                    d          j
        d	d
         }t          j        ||           d S )NscipyrO            	      &@g     &@g      '@g     '@      (@g     (@g      )@g     )@      *@	      ?      ?      ?      ?       @      @      @      @      @rN   ru   rv   rw   ry   rz   r{   r   rG   r      )rc   importorskipr   r   r	   unionrV   rT   reindexr7   locr8   r9   )r:   r<   expected	new_indexresults        r$   test_interpolate_cubicsplinez6TestSeriesInterpolateData.test_interpolate_cubicspline}   s    G$$$%%%&&KKKIIIJJ
 
 

 IOOE*L*L*L$M$MNNUU
 
	 Y''33=3IIMaPQcR
vx00000r&   c                    t          j        d           t          t          j        t          j                            d                              d                              }|j        	                    t          g d                                        t                    }|                    |                              d          }|j        dd	          d S )
Nrj   r0   d   )size)g     H@g     H@g     H@g      I@g     @I@g     `I@r   rG   1   3   )rc   r   r   rQ   sortrandomdefault_rnguniformr	   r   r   rV   rT   r   r7   r   )r:   r<   r   interp_ss       r$   test_interpolate_pchipz0TestSeriesInterpolateData.test_interpolate_pchip   s    G$$$RWRY22155==3=GGHHII IOO:::;;
 

&-- 	 ;;y))55W5EERUr&   c                 
   t          j        d           t          g d          }t          g dt          g d                    }|j                            t          g d                                        t                    }|                    |          	                    d          }t          j        |j        d	d
         |           t          g dt          g d                    }|j                            t          g d                                        t                    }|                    |          	                    dd	          }t          j        |j        d	d
         |           d S )Nrj   rk   ro   rs   rN   r}   r   rG   r   r~   )	rp   rt   rt   rt   rq   rt   rt   rt   rr   )r"   derrc   r   r   r   r	   r   rV   rT   r   r7   r8   r9   r   r:   r<   r   r   r   s        r$   test_interpolate_akimaz0TestSeriesInterpolateData.test_interpolate_akima   s   G$$$%%%&& KKKIIIJJ
 
 
 IOOE*L*L*L$M$MNNUU
 
	 ;;y))55W5EE
x|AaC0(;;; <<<IIIJJ
 
 
 IOOE*L*L*L$M$MNNUU
 
	 ;;y))55W!5LL
x|AaC0(;;;;;r&   c                    t          j        d           t          g d          }t          g dt          g d                    }|j                            t          g d                                        t                    }|                    |          	                    d          }t          j        |j        d	d
         |           d S )Nrj   rk   ro   rs   rN   r}   r   rG   r   r~   r   r   s        r$   %test_interpolate_piecewise_polynomialz?TestSeriesInterpolateData.test_interpolate_piecewise_polynomial   s    G$$$%%%&&KKKIIIJJ
 
 

 IOOE*L*L*L$M$MNNUU
 
	 ;;y))55=S5TT
x|AaC0(;;;;;r&   c                    t          j        d           t          g d          }t          g dt          g d                    }|j                            t          g d                                        t                    }|                    |          	                    d          }t          j        |j        d	d
         |           d S )Nrj   rk   ro   rs   rN   r}   r   rG   r   r~   r   r   s        r$   !test_interpolate_from_derivativesz;TestSeriesInterpolateData.test_interpolate_from_derivatives   s    G$$$%%%&&KKKIIIJJ
 
 

 IOOE*L*L*L$M$MNNUU
 
	 ;;y))55=O5PP
x|AaC0(;;;;;r&   r#   r   r   r"   r   rj   )marksc                     t          t          j        t          j        g          }t          j         |j        di ||           t          g t                                                    }t          j         |j        di ||           d S )NrB   rI   )r   rQ   rU   r8   r9   r7   object)r:   r#   ss      r$   test_interpolate_cornersz2TestSeriesInterpolateData.test_interpolate_corners   s     BFBF#$$
}q}66v66:::2V$$$0022
}q}66v66:::::r&   c                 "   t          t          j        t          j        t          j                            d                              d                              }t          j                            d                              d          |j        d d d<   |j        j	        
                    t                    }|                    d          }t          |          }| }t          t          j        ||         ||         |j	        |                   |j        |                   }t          j        ||         |           |                    d          }t          j        ||           t          j        ||         |           d S )	Nr0      rN   rO   r~   r	   rG   r
   )r   rQ   rU   r   r   r   standard_normalr   r	   r
   rV   rT   r7   r   interpr8   r9   )r:   r   valsr   badgoodr   other_results           r$   test_interpolate_index_valuesz7TestSeriesInterpolateData.test_interpolate_index_values   sC   26)>)>q)A)A)H)H)L)L!M!MNNNY**1--==bAAccc
w~$$U++g..1ggtId3idQXd^<<AGCL
 
 
 	vc{H555 }}H}55
|V444
|C0(;;;;;r&   c                    t          ddt          j        t          j        t          j        dg          }d}t          j        t
          |          5  |                    d           d d d            d S # 1 swxY w Y   d S )Nr   r~   rl   zStime-weighted interpolation only works on Series or DataFrames with a DatetimeIndexr`   rP   rG   rb   r:   r   rg   s      r$   test_interpolate_non_tsz1TestSeriesInterpolateData.test_interpolate_non_ts   s    Aq"&"&"&"566# 	 ]:S111 	) 	)MMM(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   A55A9<A9c                     t          ddt          j        dg          } |j        di |}t          g d          }t	          j        ||           d S )Nr   r   r~           rt   rx   r|   rI   r   rQ   rU   r7   r8   r9   )r:   r#   r   r   r   s        r$   test_nan_interpolatez.TestSeriesInterpolateData.test_nan_interpolate   s`     Aq"&!$%%((((...//
vx00000r&   c                     t          ddt          j        dgg d          }|                                }t          g dg d          }t	          j        ||           d S )Nr   r0   rD   )r   r~   r.   rF   rN   )rt   rx   r|         @r   r:   r   r   r   s       r$   test_nan_irregular_indexz2TestSeriesInterpolateData.test_nan_irregular_index  sf    Aq"&!$LLL999...lllCCC
vx00000r&   c                     t          dddt          j        gt          d                    }|                                }t          g dt          d                    }t          j        ||           d S )Nr   r   r0   abcdrN   )r   rt   rx   rx   )r   rQ   rU   listr7   r8   r9   r   s       r$   test_nan_str_indexz,TestSeriesInterpolateData.test_nan_str_index  sj    Aq!RV$DLL999...d6llCCC
vx00000r&   c                     t          j        d           t          ddt          j        dgg d          }|                    d          }t          g d	g d          }t          j        ||           d S )
Nrj   r   rD      )r   r0   r~   rD   rN   r   rG   )rt   r         "@g      0@rc   r   r   rQ   rU   r7   r8   r9   )r:   sqr   r   s       r$   test_interp_quadz*TestSeriesInterpolateData.test_interp_quad  s}    G$$$Q262&lll;;;{33///|||DDD
vx00000r&   c                 |   t          j        d           t          ddt          j        dt          j        dg          }t          g d          }|                    d          }t          j        ||           |                    d          }t          j        ||           t          g d	          }|                    d
          }t          j        ||                    d                     |                    d
          }t          j        ||           t          g d	          }|                    d          }t          j        ||                    d                     |                    d          }t          j        ||           t          g d          }|                    d          }t          j        ||           |                    d          }t          j        ||           t          g d          }|                    d          }t          j        ||           d S )Nrj   r   r~   rm      )rt   r|   g      @rq   g     2@      9@r   rG   )r   r~   r~   rm   rm   r   r   rT   r   )r   r|   g:/KK@rq   gL82@r   r   )rt   r|   g333333@rq   g3333332@r   r   )	rc   r   r   rQ   rU   r7   r8   r9   rV   r:   r   r   r   s       r$   test_interp_scipy_basicz1TestSeriesInterpolateData.test_interp_scipy_basic!  s   G$$$Aq"&"bfb122;;;<<i00
vx000i00
vx00011122i00
vxw'?'?@@@i00
vx00011122f--
vxw'?'?@@@f--
vx000 CCCDDk22
vx000k22
vx000;;;<<g..
vx00000r&   c                    t          ddt          j        t          j        t          j        dg          }t          ddddt          j        dg          }|                    d	d
          }t	          j        ||           d S )Nr   r~   rl   rt   r|         @      @rp   r   r0   r"   limitr   r   s       r$   test_interp_limitz+TestSeriesInterpolateData.test_interp_limitE  sl    Aq"&"&"&"5663S#rvt<==ha88
vx00000r&   r   r   c                     t          ddt          j        dg          }|\  }}t          j        t
          d          5   |j        d||d| d d d            d S # 1 swxY w Y   d S )Nr   r0   rD   zLimit must be greater than 0r`   r   r"   rI   rb   )r:   r%   r   r   r"   r#   s         r$   *test_interpolate_invalid_nonpositive_limitzDTestSeriesInterpolateData.test_interpolate_invalid_nonpositive_limitL  s     Aq"&!$%%+]:-KLLL 	@ 	@AM?f?????	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@s   AA #A c                     t          ddt          j        dg          }|\  }}d}t          j        t
          d          5   |j        d||d| d d d            d S # 1 swxY w Y   d S )	Nr   r0   rD   rx   zLimit must be an integerr`   r   rI   rb   )r:   r%   r   r"   r#   r   s         r$   $test_interpolate_invalid_float_limitz>TestSeriesInterpolateData.test_interpolate_invalid_float_limitT  s    Aq"&!$%%+]:-GHHH 	@ 	@AM?f?????	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@s    AA"%A"invalid_methodNnonexistent_methodc                    t          ddt          j        dt          j        dg          }d}|d}t          j        t
          |          5  |                    |           d d d            n# 1 swxY w Y   t          j        t
          |          5  |                    |d	
           d d d            d S # 1 swxY w Y   d S )Nr   r~   rm   r   z2Can not interpolate with method=nonexistent_methodz%'method' should be a string, not Noner`   rG   r   r   rb   )r:   r   r   rg   s       r$   test_interp_invalid_methodz4TestSeriesInterpolateData.test_interp_invalid_method\  s?   Aq"&"bfb122B!9C]:S111 	1 	1MMM000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1
 ]:S111 	; 	;MMrM:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s$   A..A25A2B99B= B=c                 ^   t          ddt          j        t          j        t          j        dg          }t          ddddt          j        dg          }|                    d	d
d          }t	          j        ||           |                    d	d
d          }t	          j        ||           d S )Nr   r~   rl   rt   r|   r   r   rp   r   r0   forwardr"   r   limit_directionFORWARDr   r   s       r$   test_interp_limit_forwardz3TestSeriesInterpolateData.test_interp_limit_forwardk  s    Aq"&"&"&"566 3S#rvt<==haSS
vx000haSS
vx00000r&   c           
      F   t          t          j        ddt          j        t          j        t          j        dt          j        g          }t          g d          }|                    dd          }t	          j        ||           t          t          j        dddd	d
ddg          }|                    dd          }t	          j        ||           t          ddddd	d
dt          j        g          }|                    dd          }t	          j        ||           d S )Nrt   r|   rp   )rt   rt   r|   r   r   r   rp   rp   r   bothr"   r   r   r   r   r   backwardr   r   s       r$   test_interp_unlimitedz/TestSeriesInterpolateData.test_interp_unlimitedw  s    BFCbfbfbfdBFKLLDDDEEhGG
vx000263S#sD$GHHh	JJ
vx0003S#sCrvFGGh
KK
vx00000r&   c                    t          ddt          j        t          j        t          j        dg          }d}t          j        t
          |          5  |                    ddd	           d d d            n# 1 swxY w Y   t          j        t
          |          5  |                    dd
           d d d            d S # 1 swxY w Y   d S )Nr   r~   rl   zVInvalid limit_direction: expecting one of \['forward', 'backward', 'both'\], got 'abc'r`   r   r0   abcr   r   rb   r   s      r$   test_interp_limit_bad_directionz9TestSeriesInterpolateData.test_interp_limit_bad_direction  sf   Aq"&"&"&"566/ 	 ]:S111 	K 	KMMEMJJJ	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K ]:S111 	B 	BMM5MAAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	Bs$   A66A:=A:CC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	          }|                    dd	
          }t	          j        ||           t          t          j        t          j        ddt          j        t          j        dt          j        t          j        g	          }|                    dd	d          }t	          j        ||           t          t          j        t          j        ddt          j        ddt          j        t          j        g	          }|                    dd	dd          }t	          j        ||           t          t          j        t          j        dt          j        t          j        t          j        dddg	          }|                    dd
          }t	          j        ||           t          t          j        t          j        dt          j        t          j        t          j        ddt          j        g	          }|                    ddd          }t	          j        ||           t          t          j        ddt          j        t          j        t          j        ddt          j        g	          }|                    dddd          }t	          j        ||           t          dddt          j        t          j        t          j        dt          j        t          j        g	          }|                    ddd          }t	          j        ||           d}t          j        t          |          5  |                    dd
           d d d            d S # 1 swxY w Y   d S )Nr~      r|   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 abcr`   r   )	r   rQ   rU   r7   r8   r9   rc   rd   re   )r:   r   r   r   rg   s        r$   test_interp_limit_areaz0TestSeriesInterpolateData.test_interp_limit_area  sD   BFBFArvrvrvq"&"&QRR26263S#sBFBFSTTh8DD
vx000VRVS#rvrvsBFBFK
 
 h81MM
vx00026263RVS#rvrvVWW&PQ  
 
 	vx00026263SRUVWWh9EE
vx000VRVS"&"&"&#sBFK
 
 h9ANN
vx000263RVRVRVS#rvVWW	6QR  
 
 	vx0003S"&"&"&#rvrvVWW	:  
 
 	vx000 W]:S111 	= 	=MMeM<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=s   O,,O03O0zdata, kwargsr~   r   padr   r   r   r   r.   c                     t          |          }d}t          j        t          |          5   |j        di | d d d            d S # 1 swxY w Y   d S )N#Can not interpolate with method=padr`   rI   r   rc   rd   re   r7   r:   datar#   r   rg   s        r$   test_interp_limit_area_with_padz9TestSeriesInterpolateData.test_interp_limit_area_with_pad  s    @ 4LL3]:S111 	$ 	$AM##F###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$   AAAbfillc                     t          |          }d}t          j        t          |          5   |j        di | d d d            d S # 1 swxY w Y   d S )Nz%Can not interpolate with method=bfillr`   rI   r   r   s        r$   $test_interp_limit_area_with_backfillz>TestSeriesInterpolateData.test_interp_limit_area_with_backfill  s    . 4LL5]:S111 	$ 	$AM##F###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$r   c                 f   t          ddt          j        t          j        t          j        dg          }t          ddt          j        dddg          }|                    d	d
d          }t	          j        ||           t          dddt          j        ddg          }|                    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          }|                    d	d
d          }t	          j        ||           t          dddt          j        dddddddg          }|                    d	dd          }t	          j        ||           d S )Nr   r~   rl   rt   r|   r   r   rp   r   r0   r   r   r   r   r   rF   rm   )rt   r|   r   r   r   r   r         $@rp   rq   rq   r   r   r   rq   r   r   s       r$   test_interp_limit_directionz5TestSeriesInterpolateData.test_interp_limit_direction  s{   Aq"&"&"&"5663RVS#t<==haTT
vx0003S"&#t<==haPP
vx000 Aq"&"&"&!QBFSTTUUUVVhaPP
vx000#sBFCc4tTJ
 
 haPP
vx00000r&   c                    t          t          j        t          j        dddt          j        g          }t          dddddt          j        g          }|                    ddd	
          }t	          j        ||           t          g d          }|                    ddd
          }t	          j        ||           d S )Nr.   r   rF   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_ends  s    BFBFAq!RV4553S#sBF;<<haTT
vx00088899haPP
vx0000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          }|                    ddd          }t	          j        ||           t          t          j        dddt          j        t          j        g          }|                    ddd	          }t	          j        ||           t          t          j        ddddt          j        g          }|                    ddd
          }t	          j        ||           d S )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   BFBFAq"&"&9::26263S"&ABBhaSS
vx000263S"&"&ABBhaTT
vx000263S#rv>??haPP
vx00000r&   c                     t          j        d           t          g d          }|                    dd          }t	          j        ||           |                                }t	          j        ||           d S )Nrj   r   r0   r~   r   r   r   )rc   r   r   r7   r8   r9   )r:   r   r   s      r$   test_interp_all_goodz.TestSeriesInterpolateData.test_interp_all_good;  st    G$$$999l!<<
vq))) 
vq)))))r&   check_scipyFTc                    t          j        g d          }t          ddt          j        g|          }|                                }d|j        d<   |                                }t          j	        ||           d}|rMt          j        t          |          5  |                    dd           d d d            d S # 1 swxY w Y   d S d S )	N))r   a)r   b)r0   cr   r0   rN   z?Only `method=linear` interpolation is supported on MultiIndexesr`   r   r   )r   from_tuplesr   rQ   rU   r2   r   r7   r8   r9   rc   rd   re   )r:   r  idxr   r   r   rg   s          r$   test_interp_multiIndexz0TestSeriesInterpolateData.test_interp_multiIndexE  s    $%C%C%CDDAq"&>---6688Q
vx000O 	<z555 < <\;;;< < < < < < < < < < < < < < < < < <	< 	<s   C  CCc                    t          j        d           t          dt          j        dgg d          }d}t          j        t          |          5  |                    d	           d d d            d S # 1 swxY w Y   d S )
Nrj   r   r~   )r   r0   r   rN   z8krogh interpolation requires that the index be monotonicr`   r   rG   rc   r   r   rQ   rU   rd   re   r7   r   s      r$   test_interp_nonmono_raisez3TestSeriesInterpolateData.test_interp_nonmono_raiseV  s    G$$$Arvq>333H]:S111 	* 	*MMM)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   A66A:=A:r"   r   c                    t          j        d           t          dt          j        dgt          dd|                    }|dk    rP|                    |          }t          g d	t          dd|                    }t          j        ||           d S d
}t          j	        t          |          5  |                    |           d d d            d S # 1 swxY w Y   d S )Nrj   r   r~   1/1/2000r/   tzrN   r   rG   )rt   rt   r|   r   r`   )rc   r   r   rQ   rU   r   r7   r8   r9   rd   re   )r:   r"   tz_naive_fixturedfr   r   rg   s          r$   test_interp_datetime64z0TestSeriesInterpolateData.test_interp_datetime64]  s?   G$$$N*ZGW"X"X"X
 
 
 Y^^6^22F Q;KLLL  H "68444447Cz555 . .f---. . . . . . . . . . . . . . . . . .s   6CC!Cc                     t          ddd          }t          |          }t          j        |d<   d}t	          j        t          |          5  |                    d	           d d d            d S # 1 swxY w Y   d S )
Nz
2015-04-05r~   z
US/Centralr  r   r   r`   r   rG   )r   r   r3   r4   rc   rd   re   r7   )r:   dtir<   rg   s       r$   #test_interp_pad_datetime64tz_valuesz=TestSeriesInterpolateData.test_interp_pad_datetime64tz_valuesp  s    q\BBBSkkA3]:S111 	* 	*OO5O)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   A22A69A6c                     t          g d          }|                    d          }|}t          j        ||           d S )Nrt   rx   r|   r   )r   )r   r7   r8   r9   r   s       r$   test_interp_limit_no_nansz3TestSeriesInterpolateData.test_interp_limit_no_nansz  sD    ???##Q''
vx00000r&   r   c                     t          j        d           t          ddt          j        dg          }d}t          j        t          |          5  |                    |           d d d            d S # 1 swxY w Y   d S )Nrj   r   r   r~   z6You must specify the order of the spline or polynomialr`   rG   r
  )r:   r"   r   rg   s       r$   test_no_orderz'TestSeriesInterpolateData.test_no_order  s     	G$$$Aq"&!$%%F]:S111 	) 	)MMM(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   A33A7:A7r   g      r   c                    t          j        d           t          ddt          j        dg          }d}t          j        t          |          5  |                    d|           d d d            d S # 1 swxY w Y   d S )	Nrj   r   r   r~   z.order needs to be specified and greater than 0r`   r   r   r
  )r:   r   r   rg   s       r$   %test_interpolate_spline_invalid_orderz?TestSeriesInterpolateData.test_interpolate_spline_invalid_order  s    G$$$Aq"&!$%%>]:S111 	8 	8MMM777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s   A44A8;A8c           	          t          j        d           t          ddt          j        ddt          j        dg          }|                    dd          }t          g d	          }t          j        ||           d S )
Nrj   r   r0   rD   r.   r   r   r   rt   rx   r|   r   r   r   r   r   r   s       r$   test_splinez%TestSeriesInterpolateData.test_spline  su    G$$$Aq"&!Q233ha88===>>
vx00000r&   c           	      z   t          j        d           t          ddddt          j        dt          j        g          }|                    ddd          }t          g d	          }t          j        ||           |                    ddd
          }t          g d          }t          j        ||           d S )Nrj   r   r0   r~   rD   rE   r   )r"   r   ext)rt   rx   r|   r   r   r   r   r   r  r   )r:   r   result3	expected3result1	expected1s         r$   test_spline_extrapolatez1TestSeriesInterpolateData.test_spline_extrapolate  s    G$$$Aq!Q26233--xqa-@@>>>??	
w	222--xqa-@@>>>??	
w	22222r&   c           	          t          j        d           t          ddt          j        ddt          j        dg          }|                    ddd	
          d         |                    dd          d         k    sJ d S )Nrj   r   r0   rD   gffffff@r   r   r~   r   )r"   r   r   r.   r   )rc   r   r   rQ   rU   r7   )r:   r   s     r$   test_spline_smoothz,TestSeriesInterpolateData.test_spline_smooth  s    G$$$Aq"&!S"&!455MMaM88;}}HA}66q9: : : : : :r&   c                    t          j        d           t          t          j        d          dz  d          }t          j        |t          j                            d                              ddd          <   |	                    d	d
          }|	                    d	d
          }t          j        ||           d S )Nrj   rO   r0   rT   rB   r   rF   r~   r   r   r   )rc   r   r   rQ   rR   rU   r   r   integersr7   r8   r9   )r:   r   r$  r%  s       r$   test_spline_interpolationz3TestSeriesInterpolateData.test_spline_interpolation  s    G$$$29R==A%W5558:")


"
"
+
+Aq!
4
45--xq-99MMM;;	
w	22222r&   c                    t          dt          j        dgt          j        g d                    }|                    d          }t          g dt          j        g d                    }t          j        ||           t          dt          j        dgt          j        g d                    }|                    d          }t          g d	t          j        g d                    }t          j        ||           d S )
Nr   r~   r   rN   rP   rG   r  )r   r0   rD   )rt   g(%?r|   )r   rQ   rU   r3   to_timedeltar7   r8   r9   )r:   r  r   r   s       r$   test_interp_timedelta64z1TestSeriesInterpolateData.test_interp_timedelta64  s    QN"/)))*D*DEEEv..///1K1KLLL
vx000 QN"/)))*D*DEEEv.....boiii6P6PQQQ
vx00000r&   c                 h   t          ddd          }t          t          j                            d                              t          |                    |          }t          j        |d d d<   |                    d          }|                                }t          j
        ||           d S )	Nr  z	1/20/2000r1   )freqr0   rN   r
   rG   )r   r   rQ   r   r   r   rS   rU   r7   r8   r9   )r:   rngrX   r   exps        r$   %test_series_interpolate_method_valuesz?TestSeriesInterpolateData.test_series_interpolate_method_values  s    [s;;;BI))!,,<<SXXFFcRRR&33Q3x00nn
vs+++++r&   c                 l   t          ddd          }t          g d|          }|                    |t          j        d          z                                             }|                    |                              d	          }t          ddd
          }t          g d|          }|                    |t          j        d          z                                             }|                    |                              d	          }t          j	        |j
        |j
                   d S )Nz1/1/2012rD   12D)r/   r0  )r   rm      $   r   )daysrP   rG   12h)hours)r   r   appendr3   
DateOffsetsort_valuesr   r7   r8   assert_numpy_array_equalr
   )r:   r	   rX   r   r2  r   s         r$    test_series_interpolate_intradayz:TestSeriesInterpolateData.test_series_interpolate_intraday  s   :qu===OOOU++LLA)>)>)>!>??KKMM	jj##//v/>>:qu===OOOU++LLQ)?)?)?!?@@LLNN	I&&22&2AA
#FM3:>>>>>r&   ind)r  r  r  rL   z
2019-01-01rD   startr/   )rB  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	        ||           d S d
| d}t	          j
        t          |          5   |d         j        dd|i| d d d            d S # 1 swxY w Y   d S )Nr   r   r~   rN   r   rj   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.r`   r"   rI   )r3   	DataFramerQ   rU   rc   r   r7   r   r8   r9   rd   re   )	r:   r(   r@  r  r"   r#   r   r   expected_errors	            r$   test_interp_non_timedelta_indexz9TestSeriesInterpolateData.test_interp_non_timedelta_index  s\    \1a+3777+W(((X&RU&0000F222#FFFH"6844444!! ! !  z@@@ ; ;!1!:::6:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s   )CCCc                    t          j        d           t          j        dd          }t          j        ddt
          j        dg|          }|\  }}|dv r6|                    t           j        	                    | d	
                      |d         j
        dd|i|}t          g dd|          }t          j        ||           dS )z
        Tests for non numerical index types  - object, period, timedelta
        Note that all methods except time, index, nearest and values
        are tested here.
        rj   r   rD   rA  r   r~   rN   >   r   r   z2 interpolation is not supported for TimedeltaIndexr+   r"   r   rE  NrI   )rc   r   r3   timedelta_rangerG  rQ   rU   applymarkermarkxfailr7   r   r8   r9   )	r:   r!   r(   r@  r  r"   r#   r   r   s	            r$    test_interpolate_timedelta_indexz:TestSeriesInterpolateData.test_interpolate_timedelta_index  s     	G$$$ q!444\1a+3777+&&&!!$XXX "    
 #A";;&;F;;...QcBBB
vx00000r&   zascending, expected_values)r   r0   r~   rF   rO   rO   rF   r~   r0   r   c                     t          ddt          j        ddgg d          }|                    |                              d	          }t          ||t
          
          }t          j        ||           d S )NrO   rF   r0   r   rP  )r   r	   )	ascendingr	   rG   )r   r	   rC   )r   rQ   rU   
sort_indexr7   rT   r8   r9   )r:   rR  expected_valuesrX   r   r   s         r$   test_interpolate_unsorted_indexz9TestSeriesInterpolateData.test_interpolate_unsorted_index  s{     "aA.6F6F6FGGG33??w?OOoUSSS
vx00000r&   c                     t          g dt                    }d}t          j        t          |          5  |                    d           d d d            d S # 1 swxY w Y   d S )N)r  Nr  rB   z&Can not interpolate with method=asfreqr`   asfreqrG   )r   r   rc   rd   re   r7   )r:   r<   rg   s      r$   test_interpolate_asfreq_raisesz8TestSeriesInterpolateData.test_interpolate_asfreq_raises  s    %%%V4446]:S111 	- 	-OO8O,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s   AA!Ac                 *   t          j        d           t          t          j        ddt          j        dt          j        g          }|                    dd          }t          t          j        dddddg          }t          j        ||           d S )Nrj   r   r   r~   r   )r"   
fill_valuer   )r:   r<   r   r   s       r$   test_interpolate_fill_valuez5TestSeriesInterpolateData.test_interpolate_fill_value"  s}    G$$$bfaBFArv677	a@@261aAq122
vx00000r&   )A__name__
__module____qualname__rc   rM  rN  r@   r^   rh   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   rQ   rU   ranger   r   r   r   r   r   r  r  r  r  r  r  r  r  r&  r(  r+  r.  r3  r?  r3   period_rangeinterval_rangerI  rO  rU  rX  r[  rI   r&   r$   r*   r*   P   s       [IJJ	6 	6 KJ	64 4 40. . .1 1 1
 
 
< < <4< < << < < [FL'!44MBM'<R<R  	
 ; ; ;< < <,) ) ) [FL'!44MBM'<R<R  	
 1 1 11 1 11 1 11 1 1"1 "1 "1H1 1 1 [Wr1g..@ @ /.@@ @ @ [-6J/KLL; ; ML;
1 
1 
11 1 1B B B-= -= -=^ [ BFBFBFArvrvN 99
 BFBFBFArvrvN 1EE
 BFBFBFArvrvN 	::
 BFBFBFArvrvN 	AFF
 H 	AFF
 a 	AFF+	
 :$ $; :$ [ BFBFBFArvrvN"(;;
 BFBFBFArvrvN"(QGG
 BFBFBFArvrvN")<<
 BFBFBFArvrvN")aHH	
 *$ $+ *$1 1 12
1 
1 
11 1 1 * * * [|v|Dg8N8NOOOP < < <* * * [X	5'9::. . ;:.$* * *1 1 1 [Xh'?@@) ) A@) [Wr4C&@AA8 8 BA81 1 1	3 	3 	3
 
 
3 3 31 1 1	, 	, 	,? ? ? [   BO,:::BA1---	
 ; ; ;,1 1 1. [$
   	!E+;+;+;#<= 1 1	 1- - -1 1 1 1 1r&   r*   )numpyrQ   rc   pandas.util._test_decoratorsutil_test_decoratorsr`  pandasr3   r   r   r   r   r   pandas._testing_testingr8   fixturer%   r(   r*   rI   r&   r$   <module>rm     sW        ) ) ) ) ) ) ) ) )                            *	 	+ *	     $	 	% $	X1 X1 X1 X1 X1 X1 X1 X1 X1 X1r&   