1
1
import numpy as np
2
2
import pytest
3
3
4
- from pandas .compat .numpy import np_percentile_argname
4
+ from pandas .compat .numpy import (
5
+ np_percentile_argname ,
6
+ np_version_under1p21 ,
7
+ )
5
8
6
9
import pandas as pd
7
10
from pandas import (
@@ -655,7 +658,7 @@ def compute_quantile(self, obj, qs):
655
658
result = obj .quantile (qs , numeric_only = False )
656
659
return result
657
660
658
- def test_quantile_ea (self , obj , index ):
661
+ def test_quantile_ea (self , request , obj , index ):
659
662
660
663
# result should be invariant to shuffling
661
664
indexer = np .arange (len (index ), dtype = np .intp )
@@ -665,6 +668,11 @@ def test_quantile_ea(self, obj, index):
665
668
qs = [0.5 , 0 , 1 ]
666
669
result = self .compute_quantile (obj , qs )
667
670
671
+ if np_version_under1p21 and index .dtype == "timedelta64[ns]" :
672
+ msg = "failed on Numpy 1.20.3; TypeError: data type 'Int64' not understood"
673
+ mark = pytest .mark .xfail (reason = msg , raises = TypeError )
674
+ request .node .add_marker (mark )
675
+
668
676
exp_dtype = index .dtype
669
677
if index .dtype == "Int64" :
670
678
# match non-nullable casting behavior
@@ -700,7 +708,7 @@ def test_quantile_ea_with_na(self, obj, index):
700
708
701
709
# TODO(GH#39763): filtering can be removed after GH#39763 is fixed
702
710
@pytest .mark .filterwarnings ("ignore:Using .astype to convert:FutureWarning" )
703
- def test_quantile_ea_all_na (self , obj , index ):
711
+ def test_quantile_ea_all_na (self , request , obj , index ):
704
712
obj .iloc [:] = index ._na_value
705
713
706
714
# TODO(ArrayManager): this casting should be unnecessary after GH#39763 is fixed
@@ -715,14 +723,19 @@ def test_quantile_ea_all_na(self, obj, index):
715
723
qs = [0.5 , 0 , 1 ]
716
724
result = self .compute_quantile (obj , qs )
717
725
726
+ if np_version_under1p21 and index .dtype == "timedelta64[ns]" :
727
+ msg = "failed on Numpy 1.20.3; TypeError: data type 'Int64' not understood"
728
+ mark = pytest .mark .xfail (reason = msg , raises = TypeError )
729
+ request .node .add_marker (mark )
730
+
718
731
expected = index .take ([- 1 , - 1 , - 1 ], allow_fill = True , fill_value = index ._na_value )
719
732
expected = Series (expected , index = qs , name = "A" )
720
733
if expected .dtype == "Int64" :
721
734
expected = expected .astype ("Float64" )
722
735
expected = type (obj )(expected )
723
736
tm .assert_equal (result , expected )
724
737
725
- def test_quantile_ea_scalar (self , obj , index ):
738
+ def test_quantile_ea_scalar (self , request , obj , index ):
726
739
# scalar qs
727
740
728
741
# result should be invariant to shuffling
@@ -733,6 +746,11 @@ def test_quantile_ea_scalar(self, obj, index):
733
746
qs = 0.5
734
747
result = self .compute_quantile (obj , qs )
735
748
749
+ if np_version_under1p21 and index .dtype == "timedelta64[ns]" :
750
+ msg = "failed on Numpy 1.20.3; TypeError: data type 'Int64' not understood"
751
+ mark = pytest .mark .xfail (reason = msg , raises = TypeError )
752
+ request .node .add_marker (mark )
753
+
736
754
exp_dtype = index .dtype
737
755
if index .dtype == "Int64" :
738
756
exp_dtype = "Float64"
0 commit comments