o
    ŀgۅ                     @   s   d dl Zd dlZd dlm  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dd Zejg dddd	 ZG d
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                 C   "   | 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kwargs r#   `/var/www/html/myenv/lib/python3.10/site-packages/pandas/tests/series/methods/test_interpolate.pynontemporal_method   s   r%   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   c                 C   r   )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   r#   r#   r$   interp_methods_ind2   s   r&   c                   @   s  e Zd Zejjdddd Zdd Zdd Zd	d
 Z	dd Z
dd Zdd Zdd Zejdi ejdddeddgdd Zdd Zdd Zejdi ejdddeddgdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zejd+d,d-gd.d/ Zd0d1 Zejd2d3d4gd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"ejdAg dBdCdD Z#ejdEe$j%e$j%dFe$j%e$j%e$j%dGe$j%e$j%g	e$j%e$j%dHdHdHdHdIe$j%e$j%g	dJdKdLfe$j%e$j%dFe$j%e$j%e$j%dGe$j%e$j%g	e$j%e$j%dHdHe$j%e$j%dIe$j%e$j%g	dJdKddMfe$j%e$j%dFe$j%e$j%e$j%dGe$j%e$j%g	e$j%e$j%dHe$j%e$j%e$j%dIdIdIg	dJdNdLfe$j%e$j%dFe$j%e$j%e$j%dGe$j%e$j%g	e$j%e$j%dHe$j%e$j%e$j%dIdIe$j%g	dJdNddMfe$j%e$j%e$j%e$j%e$j%e$j%e$j%ge$j%e$j%e$j%e$j%e$j%e$j%e$j%gdJdNddMfe&dOe&dOdJdNddMffdPdQ Z'ejdEe$j%e$j%dFe$j%e$j%e$j%dGe$j%e$j%g	e$j%e$j%dHdIdIdIdIe$j%e$j%g	dRdKdLfe$j%e$j%dFe$j%e$j%e$j%dGe$j%e$j%g	e$j%e$j%dHe$j%e$j%dIdIe$j%e$j%g	dRdKddMfe$j%e$j%dFe$j%e$j%e$j%dGe$j%e$j%g	dHdHdHe$j%e$j%e$j%dIe$j%e$j%g	dRdNdLfe$j%e$j%dFe$j%e$j%e$j%dGe$j%e$j%g	e$j%dHdHe$j%e$j%e$j%dIe$j%e$j%g	dRdNddMffdSdT Z(dUdV Z)dWdX Z*dYdZ Z+d[d\ Z,ejd]d^ejd_eddgd`da Z-dbdc Z.ejdddedJgdfdg Z/dhdi Z0djdk Z1ejddddlgdmdn Z2ejdod,dpd-dqe$j%gdrds Z3dtdu Z4dvdw Z5dxdy Z6dzd{ Z7d|d} Z8d~d Z9dd Z:ejdg de;j<ddde;j=d-ddgdd Z>dd Z?ejdd_g dfd^g dfgdd Z@dd ZAdd ZBd3S )TestSeriesInterpolateDataz)EA.fillna does not handle 'linear' methodreasonc                 C   sR   t tddd}| }tj|d< |jd}| }|jd}t	|| 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_perr#   r#   r$   test_interpolate_period_valuesQ   s   
z8TestSeriesInterpolateData.test_interpolate_period_valuesc                 C   s   t tjt|td|j}| }tj|dd< |jdd}t	
|| t dd |jD |jdt}| }tj|dd< |jd	d}t	
|| d S )
Ndtyper*   
   r   r!   c                 S   s   g | ]}|  qS r#   )	toordinal).0dr#   r#   r$   
<listcomp>g   s    z>TestSeriesInterpolateData.test_interpolate.<locals>.<listcomp>r   time)r   nparangelenfloatr   r.   nanr3   r4   r5   astype)r6   datetime_serieststs_copylinear_interpord_tsord_ts_copytime_interpr#   r#   r$   test_interpolate]   s   z*TestSeriesInterpolateData.test_interpolatec                 C   sV   t dddtjg}d}tjt|d |jdd W d    d S 1 s$w   Y  d S )Nr   r   r,   zGtime-weighted interpolation only works on Series.* with a DatetimeIndexmatchrF   r@   r   rG   rK   pytestraises
ValueErrorr3   )r6   non_tsmsgr#   r#   r$   /test_interpolate_time_raises_for_non_timeseriesp   s
   "zITestSeriesInterpolateData.test_interpolate_time_raises_for_non_timeseriesc                 C   st   t d tg d}tg dtg dd}|jtg dt}||j	ddj
d	d
 }t|| d S )Nscipyr?            	      &@g     &@g      '@g     '@      (@g     (@g      )@g     )@      *@	      ?      ?      ?      ?       @      @      @      @      @rE   ri   rj   rk   rm   rn   ro   r   r@   r      )rX   importorskipr   r   r   unionrL   rJ   reindexr3   locr4   r5   )r6   r8   expected	new_indexresultr#   r#   r$   test_interpolate_cubicsplinex   s   

z6TestSeriesInterpolateData.test_interpolate_cubicsplinec                 C   sf   t d tttjdjdd}|j	t
g dt}||jdd}|jdd	  d S )
Nr^   r,   d   )size)g     H@g     H@g     H@g      I@g     @I@g     `I@r   r@   1   3   )rX   rs   r   rG   sortrandomdefault_rnguniformr   rt   r   rL   rJ   ru   r3   rv   )r6   r8   rx   interp_sr#   r#   r$   test_interpolate_pchip   s   

z0TestSeriesInterpolateData.test_interpolate_pchipc                 C   s   t d tg d}tg dtg dd}|jtg dt}||j	dd}t
|jd	d
 | tg dtg dd}|jtg dt}||j	dd	d}t
|jd	d
 | d S )Nr^   r_   rc   rg   rE   rq   r   r@   r   rr   )	rd   rh   rh   rh   re   rh   rh   rh   rf   )r!   derrX   rs   r   r   r   rt   rL   rJ   ru   r3   r4   r5   rv   r6   r8   rw   rx   r   r#   r#   r$   test_interpolate_akima   s(   


z0TestSeriesInterpolateData.test_interpolate_akimac                 C   t   t d tg d}tg dtg dd}|jtg dt}||j	dd}t
|jd	d
 | d S )Nr^   r_   rc   rg   rE   rq   r   r@   r   rr   r   r   r#   r#   r$   %test_interpolate_piecewise_polynomial      

z?TestSeriesInterpolateData.test_interpolate_piecewise_polynomialc                 C   r   )Nr^   r_   rc   rg   rE   rq   r   r@   r   rr   r   r   r#   r#   r$   !test_interpolate_from_derivatives   r   z;TestSeriesInterpolateData.test_interpolate_from_derivativesr"   r   r   r!   r   r^   )marksc                 C   sT   t tjtjg}t|jdi || t g td }t|jdi || d S )Nr=   r#   )r   rG   rK   r4   r5   r3   object)r6   r"   sr#   r#   r$   test_interpolate_corners   s   
z2TestSeriesInterpolateData.test_interpolate_cornersc                 C   s   t tjttjddd}tjdd|jd d d< |jj	
t}|jdd}| }t|j	}| }t t|| || |j	| |j| d}t|| | |jdd}t|| t|| | d S )	Nr,      rE   r?   rr   r   r@   r	   )r   rG   rK   r   r   r   standard_normalrv   r   r	   rL   rJ   r3   r.   r   interpr4   r5   )r6   r   valsry   rw   badgoodother_resultr#   r#   r$   test_interpolate_index_values   s   "
"z7TestSeriesInterpolateData.test_interpolate_index_valuesc                 C   s^   t ddtjtjtjdg}d}tjt|d |jdd W d    d S 1 s(w   Y  d S )Nr   rr   r`   zStime-weighted interpolation only works on Series or DataFrames with a DatetimeIndexrU   rF   r@   rW   r6   r   r\   r#   r#   r$   test_interpolate_non_ts   s   "z1TestSeriesInterpolateData.test_interpolate_non_tsc                 C   s>   t ddtjdg}|jdi |}t g d}t|| d S )Nr   r   rr           rh   rl   rp   r#   r   rG   rK   r3   r4   r5   )r6   r"   r   ry   rw   r#   r#   r$   test_nan_interpolate   s   
z.TestSeriesInterpolateData.test_nan_interpolatec                 C   sF   t ddtjdgg dd}| }t g dg dd}t|| d S )Nr   r,      )r   rr   r*   	   rE   )rh   rl   rp         @r   r6   r   ry   rw   r#   r#   r$   test_nan_irregular_index
     z2TestSeriesInterpolateData.test_nan_irregular_indexc                 C   sF   t dddtjgtdd}| }t g dtdd}t|| d S )Nr   r   r,   abcdrE   )r   rh   rl   rl   )r   rG   rK   listr3   r4   r5   r   r#   r#   r$   test_nan_str_index  r   z,TestSeriesInterpolateData.test_nan_str_indexc                 C   sT   t d tddtjdgg dd}|jdd}tg d	g dd}t|| d S )
Nr^   r   r      )r   r,   rr   r   rE   r   r@   )rh   r         "@g      0@rX   rs   r   rG   rK   r3   r4   r5   )r6   sqry   rw   r#   r#   r$   test_interp_quad  s
   
z*TestSeriesInterpolateData.test_interp_quadc                 C   s
  t d tddtjdtjdg}tg d}|jdd}t|| d	}tjt	|d
 |jddd}W d    n1 s>w   Y  t|| tg d}|jdd}t||
d tjt	|d
 |jddd}W d    n1 sww   Y  t|| tg d}|jdd}t||
d tjt	|d
 |jddd}W d    n1 sw   Y  t|| tg d}|jdd}t|| tjt	|d
 |jddd}W d    n1 sw   Y  t|| tg d}|jdd}t|| d S )Nr^   r   rr   ra      )rh   rp   g      @re   g     2@      9@r   r@   z:The 'downcast' keyword in Series.interpolate is deprecatedrU   infer)r!   downcast)r   rr   rr   ra   ra   r   r
   rJ   r   )r   rp   g:/KK@re   gL82@r   r   )rh   rp   g333333@re   g3333332@r   r   )rX   rs   r   rG   rK   r3   r4   r5   assert_produces_warningFutureWarningrL   r6   r   rw   ry   r\   r#   r#   r$   test_interp_scipy_basic  sD   
z1TestSeriesInterpolateData.test_interp_scipy_basicc                 C   sN   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|| d S )Nr   rr   r`   rh   rp         @      @rd   r   r,   r!   limitr   r6   r   rw   ry   r#   r#   r$   test_interp_limitG  s   z+TestSeriesInterpolateData.test_interp_limitr   r   c                 C   sd   t ddtjdg}|\}}tjtdd |jd||d| W d    d S 1 s+w   Y  d S )Nr   r,   r   zLimit must be greater than 0rU   r   r!   r#   rW   )r6   r%   r   r   r!   r"   r#   r#   r$   *test_interpolate_invalid_nonpositive_limitN  s
   "zDTestSeriesInterpolateData.test_interpolate_invalid_nonpositive_limitc                 C   sh   t ddtjdg}|\}}d}tjtdd |jd||d| W d    d S 1 s-w   Y  d S )	Nr   r,   r   rl   zLimit must be an integerrU   r   r#   rW   )r6   r%   r   r!   r"   r   r#   r#   r$   $test_interpolate_invalid_float_limitV  s   "z>TestSeriesInterpolateData.test_interpolate_invalid_float_limitinvalid_methodNnonexistent_methodc                 C   s   t ddtjdtjdg}d| d}|d u rd}tjt|d |j|d	 W d    n1 s0w   Y  tjt|d |j|d
d W d    d S 1 sOw   Y  d S )Nr   rr   ra   r   zmethod must be one of.* Got 'z	' insteadz%'method' should be a string, not NonerU   r@   r   r   rW   )r6   r   r   r\   r#   r#   r$   test_interp_invalid_method^  s   "z4TestSeriesInterpolateData.test_interp_invalid_methodc              	   C   s   t ddtjdtjdg}d}d}tjt|d/ tjt|d |j	ddd	 W d    n1 s1w   Y  W d    d S W d    d S 1 sIw   Y  d S )
Nr   rr   ra   r   z:'fill_value' is not a valid keyword for Series.interpolate"Series.interpolate with method=padrU   pad)
fill_valuer!   )
r   rG   rK   rX   rY   rZ   r4   r   r   r3   )r6   r8   r\   msg2r#   r#   r$   $test_interp_invalid_method_and_valuem  s   "z>TestSeriesInterpolateData.test_interp_invalid_method_and_valuec                 C   sl   t ddtjtjtjdg}t ddddtjdg}|jd	d
dd}t|| |jd	d
dd}t|| d S )Nr   rr   r`   rh   rp   r   r   rd   r   r,   forwardr!   r   limit_directionFORWARDr   r   r#   r#   r$   test_interp_limit_forwardw  s   z3TestSeriesInterpolateData.test_interp_limit_forwardc              	   C   s   t tjddtjtjtjdtjg}t g d}|jddd}t|| t tjdddd	d
ddg}|jddd}t|| t ddddd	d
dtjg}|jddd}t|| d S )Nrh   rp   rd   )rh   rh   rp   r   r   r   rd   rd   r   bothr!   r   r   r   r   r   backwardr   r   r#   r#   r$   test_interp_unlimited  s   "z/TestSeriesInterpolateData.test_interp_unlimitedc                 C   s   t ddtjtjtjdg}d}tjt|d |jdddd	 W d    n1 s)w   Y  tjt|d |jddd
 W d    d S 1 sHw   Y  d S )Nr   rr   r`   zVInvalid limit_direction: expecting one of \['forward', 'backward', 'both'\], got 'abc'rU   r   r,   abcr   r   rW   r   r#   r#   r$   test_interp_limit_bad_direction  s   "z9TestSeriesInterpolateData.test_interp_limit_bad_directionc              
   C   s2  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	d
}t|| t tjtjddtjtjdtjtjg	}|jdd	dd}t|| t tjtjddtjddtjtjg	}|jdd	ddd}t|| t tjtjdtjtjtjdddg	}|jddd
}t|| t tjtjdtjtjtjddtjg	}|jdddd}t|| t tjddtjtjtjddtjg	}|jddddd}t|| t dddtjtjtjdtjtjg	}|jdddd}t|| d}tjt|d |jddd
 W d    d S 1 sw   Y  d S )Nrr      rp   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 abcrU   r   )	r   rG   rK   r3   r4   r5   rX   rY   rZ   r   r#   r#   r$   test_interp_limit_area  sH   (" $$ $$$z0TestSeriesInterpolateData.test_interp_limit_areaz!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              	   C   s   t g d}d| d| d}d}tjt|d/ tjt|d |j||d W d    n1 s2w   Y  W d    d S W d    d S 1 sJw   Y  d S )Nr   r,   rr   z`limit_direction` must be 'z' for method ``zSeries.interpolate with method=rU   r   )r   rX   rY   rZ   r4   r   r   r3   )r6   r!   r   rw   r   r\   r   r#   r#   r$   "test_interp_limit_direction_raises  s   "z<TestSeriesInterpolateData.test_interp_limit_direction_raiseszdata, expected_data, kwargsrr   r   rp   r   r   r   r   r   r   r*   c                 C   b   t |}t |}d}tjt|d |jdi |}W d    n1 s$w   Y  t|| d S )Nr   rU   r#   r   r4   r   r   r3   r5   r6   dataexpected_datar"   r   rw   r\   ry   r#   r#   r$   test_interp_limit_area_with_pad  s   &z9TestSeriesInterpolateData.test_interp_limit_area_with_padr   c                 C   r   )Nz$Series.interpolate with method=bfillrU   r#   r   r   r#   r#   r$   $test_interp_limit_area_with_backfill  s   z>TestSeriesInterpolateData.test_interp_limit_area_with_backfillc                 C   s  t ddtjtjtjdg}t ddtjdddg}|jd	d
dd}t|| t dddtjddg}|jd	ddd}t|| 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d}t|| t dddtjdddddddg}|jd	ddd}t|| d S )Nr   rr   r`   rh   rp   r   r   rd   r   r,   r   r   r   r   r   r   ra   )rh   rp   r   r   r   r   r         $@rd   re   re   r   r   r   re   r   r   r#   r#   r$   test_interp_limit_direction7  s    *z5TestSeriesInterpolateData.test_interp_limit_directionc                 C   sx   t tjtjdddtjg}t dddddtjg}|jddd	d
}t|| t g d}|jdddd
}t|| d S )Nr*   r   r   r   r   r   r   r,   r   r   )r   r   r   r   r   r   r   r   r   r#   r#   r$   test_interp_limit_to_endsP  s   z3TestSeriesInterpolateData.test_interp_limit_to_endsc                 C   s   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d}t|| t tjdddtjtjg}|jddd	d}t|| t tjddddtjg}|jddd
d}t|| d S )Nr*   r   r   r   r   r   r   r   r   r   r   r   r#   r#   r$   test_interp_limit_before_ends\  s   z7TestSeriesInterpolateData.test_interp_limit_before_endsc                 C   sH   t d tg d}|jddd}t|| | }t|| d S )Nr^   r   r   r   r   )rX   rs   r   r3   r4   r5   )r6   r   ry   r#   r#   r$   test_interp_all_goodl  s   
z.TestSeriesInterpolateData.test_interp_all_goodcheck_scipyFTc                 C   s   t g d}tddtjg|d}| }d|jd< | }t	|| d}|rIt
jt|d |jddd W d    d S 1 sBw   Y  d S d S )	N))r   a)r   b)r,   cr   r,   rE   z?Only `method=linear` interpolation is supported on MultiIndexesrU   r   r   )r   from_tuplesr   rG   rK   r.   rv   r3   r4   r5   rX   rY   rZ   )r6   r   idxr   rw   ry   r\   r#   r#   r$   test_interp_multiIndexv  s   
"z0TestSeriesInterpolateData.test_interp_multiIndexc                 C   sf   t d tdtjdgg dd}d}t jt|d |jdd	 W d    d S 1 s,w   Y  d S )
Nr^   r   rr   )r   r,   r   rE   z8krogh interpolation requires that the index be monotonicrU   r   r@   rX   rs   r   rG   rK   rY   rZ   r3   r   r#   r#   r$   test_interp_nonmono_raise  s   
"z3TestSeriesInterpolateData.test_interp_nonmono_raiser!   r
   c           	      C   s   t d tdtjdgtdd|dd}|dkrd nt}d}tj||d	 |j	|d
}W d    n1 s6w   Y  |d urI|
 }t|| tg dtdd|dd}t|| d S )Nr^   r   rr   1/1/2000r+   tzrE   r
   0Series.interpolate with method=pad is deprecatedrU   r@   )rh   rh   rp   )rX   rs   r   rG   rK   r   r   r4   r   r3   r   r5   )	r6   r!   tz_naive_fixturedfwarnr\   ry   altrw   r#   r#   r$   test_interp_datetime64  s"   
z0TestSeriesInterpolateData.test_interp_datetime64c                 C   s   t dddd}t|}tj|d< d}tjt|d |jdd	}W d    n1 s*w   Y  | }t	|| t|}|d
 |d< t	|| d S )Nz
2015-04-05rr   z
US/Centralr   r   r   rU   r   r@   r   )
r   r   r/   r0   r4   r   r   r3   r   r5   )r6   dtir8   r\   ry   r   rw   r#   r#   r$   #test_interp_pad_datetime64tz_values  s   
z=TestSeriesInterpolateData.test_interp_pad_datetime64tz_valuesc                 C   s,   t g d}|jdd}|}t|| d S )Nrh   rl   rp   r   )r   )r   r3   r4   r5   r   r#   r#   r$   test_interp_limit_no_nans  s   z3TestSeriesInterpolateData.test_interp_limit_no_nansr   c                 C   s`   t d tddtjdg}d}t jt|d |j|d W d    d S 1 s)w   Y  d S )Nr^   r   r   rr   z6You must specify the order of the spline or polynomialrU   r@   r   )r6   r!   r   r\   r#   r#   r$   test_no_order  s   
"z'TestSeriesInterpolateData.test_no_orderr   g      r   c                 C   sb   t d tddtjdg}d}t jt|d |jd|d W d    d S 1 s*w   Y  d S )	Nr^   r   r   rr   z.order needs to be specified and greater than 0rU   r   r   r   )r6   r   r   r\   r#   r#   r$   %test_interpolate_spline_invalid_order  s   
"z?TestSeriesInterpolateData.test_interpolate_spline_invalid_orderc                 C   sN   t d tddtjddtjdg}|jddd}tg d	}t|| d S )
Nr^   r   r,   r   r*   r   r   r   rh   rl   rp   r   r   r   r   r   r   r#   r#   r$   test_spline  s
   
z%TestSeriesInterpolateData.test_splinec                 C   sx   t d tddddtjdtjg}|jdddd}tg d	}t|| |jddd
d}tg d}t|| d S )Nr^   r   r,   rr   r      r   )r!   r   ext)rh   rl   rp   r   r   r   r   r   r  r   )r6   r   result3	expected3result1	expected1r#   r#   r$   test_spline_extrapolate  s   
z1TestSeriesInterpolateData.test_spline_extrapolatec                 C   sR   t d tddtjddtjdg}|jddd	d
d |jdddd ks'J d S )Nr^   r   r,   r   gffffff@r   r   rr   r   )r!   r   r   r*   r   )rX   rs   r   rG   rK   r3   )r6   r   r#   r#   r$   test_spline_smooth  s
   
z,TestSeriesInterpolateData.test_spline_smoothc                 C   sh   t d ttdd dd}tj|tjdddd< |j	d	d
d}|j	d	d
d}t
|| d S )Nr^   r?   r,   rJ   r=   r   r   rr   r   r   r   )rX   rs   r   rG   rH   rK   r   r   integersr3   r4   r5   )r6   r   r  r  r#   r#   r$   test_spline_interpolation  s   
z3TestSeriesInterpolateData.test_spline_interpolationc                 C   s   t dtjdgtg dd}|jdd}t g dtg dd}t|| t dtjdgtg dd}|jdd}t g d	tg dd}t|| d S )
Nr   rr   r   rE   rF   r@   r  )r   r,   r   )rh   g(%?rp   )r   rG   rK   r/   to_timedeltar3   r4   r5   )r6   r   ry   rw   r#   r#   r$   test_interp_timedelta64  s   z1TestSeriesInterpolateData.test_interp_timedelta64c                 C   s`   t dddd}ttjdt||d}tj|d d d< |jdd}| }t	
|| d S )	Nr   z	1/20/2000r-   )freqr,   rE   r	   r@   )r   r   rG   r   r   r   rI   rK   r3   r4   r5   )r6   rngrN   ry   expr#   r#   r$   %test_series_interpolate_method_values  s   z?TestSeriesInterpolateData.test_series_interpolate_method_valuesc                 C   s   t dddd}tg d|}||tjdd  }||jdd	}t ddd
d}tg d|}||tjdd  }||jdd	}t	|j
|j
 d S )Nz1/1/2012r   12D)r+   r  )r   ra      $   r   )daysrF   r@   12h)hours)r   r   appendr/   
DateOffsetsort_valuesru   r3   r4   assert_numpy_array_equalr	   )r6   r   rN   rx   r  ry   r#   r#   r$    test_series_interpolate_intraday  s   z:TestSeriesInterpolateData.test_series_interpolate_intradayind)r   r   r   rC   z
2019-01-01r   startr+   )r$  endc           	      C   s   t jddtjdg|d}|\}}|dkrtd |dkr8|d jdi |}tg dd|d	}t	|| d S d
| d}tj
t|d |d jdd|i| W d    d S 1 s]w   Y  d S )Nr   r   rr   rE   r   r^   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.rU   r!   r#   )r/   	DataFramerG   rK   rX   rs   r3   r   r4   r5   rY   rZ   )	r6   r&   r"  r   r!   r"   ry   rw   expected_errorr#   r#   r$   test_interp_non_timedelta_index  s   

"z9TestSeriesInterpolateData.test_interp_non_timedelta_indexc           	      C   s   t d tjddd}tjddtjdg|d}|\}}|dv r-|t jj	| d	d
 |d j
dd|i|}tg dd|d}t|| 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.
        r^   r   r   r#  r   rr   rE   >   r   r   z2 interpolation is not supported for TimedeltaIndexr(   r!   r   r&  Nr#   )rX   rs   r/   timedelta_ranger(  rG   rK   applymarkermarkxfailr3   r   r4   r5   )	r6   r    r&   r"  r   r!   r"   ry   rw   r#   r#   r$    test_interpolate_timedelta_index4  s   
z:TestSeriesInterpolateData.test_interpolate_timedelta_indexzascending, expected_values)r   r,   rr   r   r?   r?   r   rr   r,   r   c                 C   sN   t ddtjddgg dd}|j|djdd	}t ||td
}t|| d S )Nr?   r   r,   r   r0  )r   r   )	ascendingr   r@   )r   r   r>   )r   rG   rK   
sort_indexr3   rJ   r4   r5   )r6   r1  expected_valuesrN   ry   rw   r#   r#   r$   test_interpolate_unsorted_indexK  s   z9TestSeriesInterpolateData.test_interpolate_unsorted_indexc              	   C   s   t g dtd}d}d}tjt|d. tjt|d |jdd W d    n1 s,w   Y  W d    d S W d    d S 1 sDw   Y  d S )N)r   Nr   r=   z$Series.interpolate with object dtypezInvalid fill methodrU   asfreqr@   )	r   r   rX   rY   rZ   r4   r   r   r3   )r6   r8   r   r\   r#   r#   r$   test_interpolate_asfreq_raisesV  s   "z8TestSeriesInterpolateData.test_interpolate_asfreq_raisesc                 C   sX   t d ttjddtjdtjg}|jddd}ttjdddddg}t|| d S )Nr^   r   r   rr   r
   )r!   r   r   )r6   r8   ry   rw   r#   r#   r$   test_interpolate_fill_value^  s
   
z5TestSeriesInterpolateData.test_interpolate_fill_value)C__name__
__module____qualname__rX   r-  r.  r<   rT   r]   rz   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   rG   rK   ranger   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  r!  r/   period_rangeinterval_ranger*  r/  r4  r6  r7  r#   r#   r#   r$   r'   P   s   

		
	*


/

"" 
"" 



#
"" 
"" 







	

r'   )numpyrG   rX   pandas.util._test_decoratorsutil_test_decoratorsr<  pandasr/   r   r   r   r   r   pandas._testing_testingr4   fixturer%   r&   r'   r#   r#   r#   r$   <module>   s    

