@@ -774,85 +774,34 @@ def test_take_fill_value(self):
774
774
775
775
776
776
class TestGetValue :
777
- def test_get_value (self ):
778
- # GH 17717
779
- p0 = Period ("2017-09-01" )
780
- p1 = Period ("2017-09-02" )
781
- p2 = Period ("2017-09-03" )
782
-
783
- idx0 = PeriodIndex ([p0 , p1 , p2 ])
784
- input0 = Series (np .array ([1 , 2 , 3 ]), index = idx0 )
785
- expected0 = 2
786
-
787
- with tm .assert_produces_warning (FutureWarning ):
788
- result0 = idx0 .get_value (input0 , p1 )
789
- assert result0 == expected0
790
-
791
- idx1 = PeriodIndex ([p1 , p1 , p2 ])
792
- input1 = Series (np .array ([1 , 2 , 3 ]), index = idx1 )
793
- expected1 = input1 .iloc [[0 , 1 ]]
794
-
795
- with tm .assert_produces_warning (FutureWarning ):
796
- result1 = idx1 .get_value (input1 , p1 )
797
- tm .assert_series_equal (result1 , expected1 )
798
-
799
- idx2 = PeriodIndex ([p1 , p2 , p1 ])
800
- input2 = Series (np .array ([1 , 2 , 3 ]), index = idx2 )
801
- expected2 = input2 .iloc [[0 , 2 ]]
802
-
803
- with tm .assert_produces_warning (FutureWarning ):
804
- result2 = idx2 .get_value (input2 , p1 )
805
- tm .assert_series_equal (result2 , expected2 )
806
-
807
777
@pytest .mark .parametrize ("freq" , ["H" , "D" ])
808
778
def test_get_value_datetime_hourly (self , freq ):
809
779
# get_loc and get_value should treat datetime objects symmetrically
780
+ # TODO: this test used to test get_value, which is removed in 2.0.
781
+ # should this test be moved somewhere, or is what's left redundant?
810
782
dti = date_range ("2016-01-01" , periods = 3 , freq = "MS" )
811
783
pi = dti .to_period (freq )
812
784
ser = Series (range (7 , 10 ), index = pi )
813
785
814
786
ts = dti [0 ]
815
787
816
788
assert pi .get_loc (ts ) == 0
817
- with tm .assert_produces_warning (FutureWarning ):
818
- assert pi .get_value (ser , ts ) == 7
819
789
assert ser [ts ] == 7
820
790
assert ser .loc [ts ] == 7
821
791
822
792
ts2 = ts + Timedelta (hours = 3 )
823
793
if freq == "H" :
824
794
with pytest .raises (KeyError , match = "2016-01-01 03:00" ):
825
795
pi .get_loc (ts2 )
826
- with pytest .raises (KeyError , match = "2016-01-01 03:00" ):
827
- with tm .assert_produces_warning (FutureWarning ):
828
- pi .get_value (ser , ts2 )
829
796
with pytest .raises (KeyError , match = "2016-01-01 03:00" ):
830
797
ser [ts2 ]
831
798
with pytest .raises (KeyError , match = "2016-01-01 03:00" ):
832
799
ser .loc [ts2 ]
833
800
else :
834
801
assert pi .get_loc (ts2 ) == 0
835
- with tm .assert_produces_warning (FutureWarning ):
836
- assert pi .get_value (ser , ts2 ) == 7
837
802
assert ser [ts2 ] == 7
838
803
assert ser .loc [ts2 ] == 7
839
804
840
- def test_get_value_integer (self ):
841
- msg = "index 16801 is out of bounds for axis 0 with size 3"
842
- dti = date_range ("2016-01-01" , periods = 3 )
843
- pi = dti .to_period ("D" )
844
- ser = Series (range (3 ), index = pi )
845
- with pytest .raises (IndexError , match = msg ):
846
- with tm .assert_produces_warning (FutureWarning ):
847
- pi .get_value (ser , 16801 )
848
-
849
- msg = "index 46 is out of bounds for axis 0 with size 3"
850
- pi2 = dti .to_period ("Y" ) # duplicates, ordinals are all 46
851
- ser2 = Series (range (3 ), index = pi2 )
852
- with pytest .raises (IndexError , match = msg ):
853
- with tm .assert_produces_warning (FutureWarning ):
854
- pi2 .get_value (ser2 , 46 )
855
-
856
805
857
806
class TestContains :
858
807
def test_contains (self ):
@@ -864,7 +813,6 @@ def test_contains(self):
864
813
865
814
ps0 = [p0 , p1 , p2 ]
866
815
idx0 = PeriodIndex (ps0 )
867
- ser = Series (range (6 , 9 ), index = idx0 )
868
816
869
817
for p in ps0 :
870
818
assert p in idx0
@@ -876,9 +824,6 @@ def test_contains(self):
876
824
assert key not in idx0
877
825
with pytest .raises (KeyError , match = key ):
878
826
idx0 .get_loc (key )
879
- with pytest .raises (KeyError , match = key ):
880
- with tm .assert_produces_warning (FutureWarning ):
881
- idx0 .get_value (ser , key )
882
827
883
828
assert "2017-09" in idx0
884
829
0 commit comments