@@ -774,85 +774,34 @@ def test_take_fill_value(self):
774774
775775
776776class 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-
807777 @pytest .mark .parametrize ("freq" , ["H" , "D" ])
808778 def test_get_value_datetime_hourly (self , freq ):
809779 # 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?
810782 dti = date_range ("2016-01-01" , periods = 3 , freq = "MS" )
811783 pi = dti .to_period (freq )
812784 ser = Series (range (7 , 10 ), index = pi )
813785
814786 ts = dti [0 ]
815787
816788 assert pi .get_loc (ts ) == 0
817- with tm .assert_produces_warning (FutureWarning ):
818- assert pi .get_value (ser , ts ) == 7
819789 assert ser [ts ] == 7
820790 assert ser .loc [ts ] == 7
821791
822792 ts2 = ts + Timedelta (hours = 3 )
823793 if freq == "H" :
824794 with pytest .raises (KeyError , match = "2016-01-01 03:00" ):
825795 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 )
829796 with pytest .raises (KeyError , match = "2016-01-01 03:00" ):
830797 ser [ts2 ]
831798 with pytest .raises (KeyError , match = "2016-01-01 03:00" ):
832799 ser .loc [ts2 ]
833800 else :
834801 assert pi .get_loc (ts2 ) == 0
835- with tm .assert_produces_warning (FutureWarning ):
836- assert pi .get_value (ser , ts2 ) == 7
837802 assert ser [ts2 ] == 7
838803 assert ser .loc [ts2 ] == 7
839804
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-
856805
857806class TestContains :
858807 def test_contains (self ):
@@ -864,7 +813,6 @@ def test_contains(self):
864813
865814 ps0 = [p0 , p1 , p2 ]
866815 idx0 = PeriodIndex (ps0 )
867- ser = Series (range (6 , 9 ), index = idx0 )
868816
869817 for p in ps0 :
870818 assert p in idx0
@@ -876,9 +824,6 @@ def test_contains(self):
876824 assert key not in idx0
877825 with pytest .raises (KeyError , match = key ):
878826 idx0 .get_loc (key )
879- with pytest .raises (KeyError , match = key ):
880- with tm .assert_produces_warning (FutureWarning ):
881- idx0 .get_value (ser , key )
882827
883828 assert "2017-09" in idx0
884829
0 commit comments