@@ -673,21 +673,24 @@ def test_get_value(self):
673
673
input0 = pd .Series (np .array ([1 , 2 , 3 ]), index = idx0 )
674
674
expected0 = 2
675
675
676
- result0 = idx0 .get_value (input0 , p1 )
676
+ with tm .assert_produces_warning (FutureWarning ):
677
+ result0 = idx0 .get_value (input0 , p1 )
677
678
assert result0 == expected0
678
679
679
680
idx1 = PeriodIndex ([p1 , p1 , p2 ])
680
681
input1 = pd .Series (np .array ([1 , 2 , 3 ]), index = idx1 )
681
682
expected1 = input1 .iloc [[0 , 1 ]]
682
683
683
- result1 = idx1 .get_value (input1 , p1 )
684
+ with tm .assert_produces_warning (FutureWarning ):
685
+ result1 = idx1 .get_value (input1 , p1 )
684
686
tm .assert_series_equal (result1 , expected1 )
685
687
686
688
idx2 = PeriodIndex ([p1 , p2 , p1 ])
687
689
input2 = pd .Series (np .array ([1 , 2 , 3 ]), index = idx2 )
688
690
expected2 = input2 .iloc [[0 , 2 ]]
689
691
690
- result2 = idx2 .get_value (input2 , p1 )
692
+ with tm .assert_produces_warning (FutureWarning ):
693
+ result2 = idx2 .get_value (input2 , p1 )
691
694
tm .assert_series_equal (result2 , expected2 )
692
695
693
696
@pytest .mark .parametrize ("freq" , ["H" , "D" ])
@@ -700,7 +703,8 @@ def test_get_value_datetime_hourly(self, freq):
700
703
ts = dti [0 ]
701
704
702
705
assert pi .get_loc (ts ) == 0
703
- assert pi .get_value (ser , ts ) == 7
706
+ with tm .assert_produces_warning (FutureWarning ):
707
+ assert pi .get_value (ser , ts ) == 7
704
708
assert ser [ts ] == 7
705
709
assert ser .loc [ts ] == 7
706
710
@@ -709,14 +713,16 @@ def test_get_value_datetime_hourly(self, freq):
709
713
with pytest .raises (KeyError , match = "2016-01-01 03:00" ):
710
714
pi .get_loc (ts2 )
711
715
with pytest .raises (KeyError , match = "2016-01-01 03:00" ):
712
- pi .get_value (ser , ts2 )
716
+ with tm .assert_produces_warning (FutureWarning ):
717
+ pi .get_value (ser , ts2 )
713
718
with pytest .raises (KeyError , match = "2016-01-01 03:00" ):
714
719
ser [ts2 ]
715
720
with pytest .raises (KeyError , match = "2016-01-01 03:00" ):
716
721
ser .loc [ts2 ]
717
722
else :
718
723
assert pi .get_loc (ts2 ) == 0
719
- assert pi .get_value (ser , ts2 ) == 7
724
+ with tm .assert_produces_warning (FutureWarning ):
725
+ assert pi .get_value (ser , ts2 ) == 7
720
726
assert ser [ts2 ] == 7
721
727
assert ser .loc [ts2 ] == 7
722
728
@@ -726,13 +732,15 @@ def test_get_value_integer(self):
726
732
pi = dti .to_period ("D" )
727
733
ser = pd .Series (range (3 ), index = pi )
728
734
with pytest .raises (IndexError , match = msg ):
729
- pi .get_value (ser , 16801 )
735
+ with tm .assert_produces_warning (FutureWarning ):
736
+ pi .get_value (ser , 16801 )
730
737
731
738
msg = "index 46 is out of bounds for axis 0 with size 3"
732
739
pi2 = dti .to_period ("Y" ) # duplicates, ordinals are all 46
733
740
ser2 = pd .Series (range (3 ), index = pi2 )
734
741
with pytest .raises (IndexError , match = msg ):
735
- pi2 .get_value (ser2 , 46 )
742
+ with tm .assert_produces_warning (FutureWarning ):
743
+ pi2 .get_value (ser2 , 46 )
736
744
737
745
738
746
class TestContains :
@@ -758,7 +766,8 @@ def test_contains(self):
758
766
with pytest .raises (KeyError , match = key ):
759
767
idx0 .get_loc (key )
760
768
with pytest .raises (KeyError , match = key ):
761
- idx0 .get_value (ser , key )
769
+ with tm .assert_produces_warning (FutureWarning ):
770
+ idx0 .get_value (ser , key )
762
771
763
772
assert "2017-09" in idx0
764
773
0 commit comments