16
16
from pandas .util .testing import assert_series_equal , assert_frame_equal
17
17
18
18
import pandas .util .testing as tm
19
+ import pandas .util ._test_decorators as td
19
20
from pandas .tests .frame .common import TestData , _check_mixed_float
20
21
21
22
@@ -646,9 +647,8 @@ def test_interp_nan_idx(self):
646
647
with pytest .raises (NotImplementedError ):
647
648
df .interpolate (method = 'values' )
648
649
650
+ @td .skip_if_no_scipy
649
651
def test_interp_various (self ):
650
- tm ._skip_if_no_scipy ()
651
-
652
652
df = DataFrame ({'A' : [1 , 2 , np .nan , 4 , 5 , np .nan , 7 ],
653
653
'C' : [1 , 2 , 3 , 5 , 8 , 13 , 21 ]})
654
654
df = df .set_index ('C' )
@@ -695,8 +695,8 @@ def test_interp_various(self):
695
695
expected .A .loc [13 ] = 5
696
696
assert_frame_equal (result , expected , check_dtype = False )
697
697
698
+ @td .skip_if_no_scipy
698
699
def test_interp_alt_scipy (self ):
699
- tm ._skip_if_no_scipy ()
700
700
df = DataFrame ({'A' : [1 , 2 , np .nan , 4 , 5 , np .nan , 7 ],
701
701
'C' : [1 , 2 , 3 , 5 , 8 , 13 , 21 ]})
702
702
result = df .interpolate (method = 'barycentric' )
@@ -739,8 +739,6 @@ def test_interp_rowwise(self):
739
739
expected [4 ] = expected [4 ].astype (np .float64 )
740
740
assert_frame_equal (result , expected )
741
741
742
- # scipy route
743
- tm ._skip_if_no_scipy ()
744
742
result = df .interpolate (axis = 1 , method = 'values' )
745
743
assert_frame_equal (result , expected )
746
744
@@ -753,17 +751,20 @@ def test_rowwise_alt(self):
753
751
1 : [1 , 2 , 3 , 4 , 3 , 2 , 1 , 0 , - 1 ]})
754
752
df .interpolate (axis = 0 )
755
753
756
- def test_interp_leading_nans (self ):
754
+ @pytest .mark .parametrize ("check_scipy" , [
755
+ False , pytest .param (True , marks = td .skip_if_no_scipy )
756
+ ])
757
+ def test_interp_leading_nans (self , check_scipy ):
757
758
df = DataFrame ({"A" : [np .nan , np .nan , .5 , .25 , 0 ],
758
759
"B" : [np .nan , - 3 , - 3.5 , np .nan , - 4 ]})
759
760
result = df .interpolate ()
760
761
expected = df .copy ()
761
762
expected ['B' ].loc [3 ] = - 3.75
762
763
assert_frame_equal (result , expected )
763
764
764
- tm . _skip_if_no_scipy ()
765
- result = df .interpolate (method = 'polynomial' , order = 1 )
766
- assert_frame_equal (result , expected )
765
+ if check_scipy :
766
+ result = df .interpolate (method = 'polynomial' , order = 1 )
767
+ assert_frame_equal (result , expected )
767
768
768
769
def test_interp_raise_on_only_mixed (self ):
769
770
df = DataFrame ({'A' : [1 , 2 , np .nan , 4 ],
0 commit comments