@@ -17,7 +17,8 @@ def test_unique(index_or_series_obj):
17
17
obj = np .repeat (obj , range (1 , len (obj ) + 1 ))
18
18
with tm .maybe_produces_warning (
19
19
PerformanceWarning ,
20
- pa_version_under2p0 and str (index_or_series_obj .dtype ) == "string[pyarrow]" ,
20
+ pa_version_under2p0
21
+ and getattr (index_or_series_obj .dtype , "storage" , "" ) == "pyarrow" ,
21
22
):
22
23
result = obj .unique ()
23
24
@@ -59,7 +60,8 @@ def test_unique_null(null_obj, index_or_series_obj):
59
60
obj = klass (repeated_values , dtype = obj .dtype )
60
61
with tm .maybe_produces_warning (
61
62
PerformanceWarning ,
62
- pa_version_under2p0 and str (index_or_series_obj .dtype ) == "string[pyarrow]" ,
63
+ pa_version_under2p0
64
+ and getattr (index_or_series_obj .dtype , "storage" , "" ) == "pyarrow" ,
63
65
):
64
66
result = obj .unique ()
65
67
@@ -88,10 +90,11 @@ def test_nunique(index_or_series_obj):
88
90
obj = np .repeat (obj , range (1 , len (obj ) + 1 ))
89
91
with tm .maybe_produces_warning (
90
92
PerformanceWarning ,
91
- pa_version_under2p0 and str (index_or_series_obj .dtype ) == "string[pyarrow]" ,
93
+ pa_version_under2p0
94
+ and getattr (index_or_series_obj .dtype , "storage" , "" ) == "pyarrow" ,
92
95
):
93
96
expected = len (obj .unique ())
94
- assert obj .nunique (dropna = False ) == expected
97
+ assert obj .nunique (dropna = False ) == expected
95
98
96
99
97
100
@pytest .mark .parametrize ("null_obj" , [np .nan , None ])
@@ -116,17 +119,20 @@ def test_nunique_null(null_obj, index_or_series_obj):
116
119
else :
117
120
with tm .maybe_produces_warning (
118
121
PerformanceWarning ,
119
- pa_version_under2p0 and str (index_or_series_obj .dtype ) == "string[pyarrow]" ,
122
+ pa_version_under2p0
123
+ and getattr (index_or_series_obj .dtype , "storage" , "" ) == "pyarrow" ,
120
124
):
121
125
num_unique_values = len (obj .unique ())
122
126
with tm .maybe_produces_warning (
123
127
PerformanceWarning ,
124
- pa_version_under2p0 and str (index_or_series_obj .dtype ) == "string[pyarrow]" ,
128
+ pa_version_under2p0
129
+ and getattr (index_or_series_obj .dtype , "storage" , "" ) == "pyarrow" ,
125
130
):
126
131
assert obj .nunique () == max (0 , num_unique_values - 1 )
127
132
with tm .maybe_produces_warning (
128
133
PerformanceWarning ,
129
- pa_version_under2p0 and str (index_or_series_obj .dtype ) == "string[pyarrow]" ,
134
+ pa_version_under2p0
135
+ and getattr (index_or_series_obj .dtype , "storage" , "" ) == "pyarrow" ,
130
136
):
131
137
assert obj .nunique (dropna = False ) == max (0 , num_unique_values )
132
138
0 commit comments