@@ -508,6 +508,12 @@ def test_take_fill_valid(self, datetime_index, tz_naive_fixture):
508
508
# require NaT, not iNaT, as it could be confused with an integer
509
509
arr .take ([- 1 , 1 ], allow_fill = True , fill_value = value )
510
510
511
+ value = np .timedelta64 ("NaT" , "ns" )
512
+ msg = f"'fill_value' should be a { self .dtype } . Got '{ str (value )} '."
513
+ with pytest .raises (ValueError , match = msg ):
514
+ # require appropriate-dtype if we have a NA value
515
+ arr .take ([- 1 , 1 ], allow_fill = True , fill_value = value )
516
+
511
517
def test_concat_same_type_invalid (self , datetime_index ):
512
518
# different timezones
513
519
dti = datetime_index
@@ -669,6 +675,12 @@ def test_take_fill_valid(self, timedelta_index):
669
675
# fill_value Period invalid
670
676
arr .take ([0 , 1 ], allow_fill = True , fill_value = value )
671
677
678
+ value = np .datetime64 ("NaT" , "ns" )
679
+ msg = f"'fill_value' should be a { self .dtype } . Got '{ str (value )} '."
680
+ with pytest .raises (ValueError , match = msg ):
681
+ # require appropriate-dtype if we have a NA value
682
+ arr .take ([- 1 , 1 ], allow_fill = True , fill_value = value )
683
+
672
684
673
685
class TestPeriodArray (SharedTests ):
674
686
index_cls = pd .PeriodIndex
@@ -697,6 +709,22 @@ def test_astype_object(self, period_index):
697
709
assert asobj .dtype == "O"
698
710
assert list (asobj ) == list (pi )
699
711
712
+ def test_take_fill_valid (self , period_index ):
713
+ pi = period_index
714
+ arr = PeriodArray (pi )
715
+
716
+ value = pd .NaT .value
717
+ msg = f"'fill_value' should be a { self .dtype } . Got '{ value } '."
718
+ with pytest .raises (ValueError , match = msg ):
719
+ # require NaT, not iNaT, as it could be confused with an integer
720
+ arr .take ([- 1 , 1 ], allow_fill = True , fill_value = value )
721
+
722
+ value = np .timedelta64 ("NaT" , "ns" )
723
+ msg = f"'fill_value' should be a { self .dtype } . Got '{ str (value )} '."
724
+ with pytest .raises (ValueError , match = msg ):
725
+ # require appropriate-dtype if we have a NA value
726
+ arr .take ([- 1 , 1 ], allow_fill = True , fill_value = value )
727
+
700
728
@pytest .mark .parametrize ("how" , ["S" , "E" ])
701
729
def test_to_timestamp (self , how , period_index ):
702
730
pi = period_index
0 commit comments