3
3
import numpy as np
4
4
import pytest
5
5
6
+ from pandas .compat .numpy import _np_version_under1p20
7
+
6
8
import pandas as pd
7
9
import pandas ._testing as tm
8
10
from pandas .core import ops
@@ -116,9 +118,15 @@ def _check_logical_ops(self, a, b, a_dense, b_dense):
116
118
@pytest .mark .parametrize ("scalar" , [0 , 1 , 3 ])
117
119
@pytest .mark .parametrize ("fill_value" , [None , 0 , 2 ])
118
120
def test_float_scalar (
119
- self , kind , mix , all_arithmetic_functions , fill_value , scalar
121
+ self , kind , mix , all_arithmetic_functions , fill_value , scalar , request
120
122
):
121
123
op = all_arithmetic_functions
124
+
125
+ if not _np_version_under1p20 :
126
+ if op in [operator .floordiv , ops .rfloordiv ]:
127
+ mark = pytest .mark .xfail (strict = False , reason = "GH#38172" )
128
+ request .node .add_marker (mark )
129
+
122
130
values = self ._base ([np .nan , 1 , 2 , 0 , np .nan , 0 , 1 , 2 , 1 , np .nan ])
123
131
124
132
a = self ._klass (values , kind = kind , fill_value = fill_value )
@@ -142,15 +150,11 @@ def test_float_scalar_comparison(self, kind):
142
150
self ._check_comparison_ops (a , 0 , values , 0 )
143
151
self ._check_comparison_ops (a , 3 , values , 3 )
144
152
145
- def test_float_same_index (self , kind , mix , all_arithmetic_functions ):
153
+ def test_float_same_index_without_nans (
154
+ self , kind , mix , all_arithmetic_functions , request
155
+ ):
146
156
# when sp_index are the same
147
157
op = all_arithmetic_functions
148
- values = self ._base ([np .nan , 1 , 2 , 0 , np .nan , 0 , 1 , 2 , 1 , np .nan ])
149
- rvalues = self ._base ([np .nan , 2 , 3 , 4 , np .nan , 0 , 1 , 3 , 2 , np .nan ])
150
-
151
- a = self ._klass (values , kind = kind )
152
- b = self ._klass (rvalues , kind = kind )
153
- self ._check_numeric_ops (a , b , values , rvalues , mix , op )
154
158
155
159
values = self ._base ([0.0 , 1.0 , 2.0 , 6.0 , 0.0 , 0.0 , 1.0 , 2.0 , 1.0 , 0.0 ])
156
160
rvalues = self ._base ([0.0 , 2.0 , 3.0 , 4.0 , 0.0 , 0.0 , 1.0 , 3.0 , 2.0 , 0.0 ])
@@ -159,6 +163,24 @@ def test_float_same_index(self, kind, mix, all_arithmetic_functions):
159
163
b = self ._klass (rvalues , kind = kind , fill_value = 0 )
160
164
self ._check_numeric_ops (a , b , values , rvalues , mix , op )
161
165
166
+ def test_float_same_index_with_nans (
167
+ self , kind , mix , all_arithmetic_functions , request
168
+ ):
169
+ # when sp_index are the same
170
+ op = all_arithmetic_functions
171
+
172
+ if not _np_version_under1p20 :
173
+ if op in [operator .floordiv , ops .rfloordiv ]:
174
+ mark = pytest .mark .xfail (strict = False , reason = "GH#38172" )
175
+ request .node .add_marker (mark )
176
+
177
+ values = self ._base ([np .nan , 1 , 2 , 0 , np .nan , 0 , 1 , 2 , 1 , np .nan ])
178
+ rvalues = self ._base ([np .nan , 2 , 3 , 4 , np .nan , 0 , 1 , 3 , 2 , np .nan ])
179
+
180
+ a = self ._klass (values , kind = kind )
181
+ b = self ._klass (rvalues , kind = kind )
182
+ self ._check_numeric_ops (a , b , values , rvalues , mix , op )
183
+
162
184
def test_float_same_index_comparison (self , kind ):
163
185
# when sp_index are the same
164
186
values = self ._base ([np .nan , 1 , 2 , 0 , np .nan , 0 , 1 , 2 , 1 , np .nan ])
@@ -324,9 +346,14 @@ def test_bool_array_logical(self, kind, fill_value):
324
346
b = self ._klass (rvalues , kind = kind , dtype = np .bool_ , fill_value = fill_value )
325
347
self ._check_logical_ops (a , b , values , rvalues )
326
348
327
- def test_mixed_array_float_int (self , kind , mix , all_arithmetic_functions ):
349
+ def test_mixed_array_float_int (self , kind , mix , all_arithmetic_functions , request ):
328
350
op = all_arithmetic_functions
329
351
352
+ if not _np_version_under1p20 :
353
+ if op in [operator .floordiv , ops .rfloordiv ] and mix :
354
+ mark = pytest .mark .xfail (strict = True , reason = "GH#38172" )
355
+ request .node .add_marker (mark )
356
+
330
357
rdtype = "int64"
331
358
332
359
values = self ._base ([np .nan , 1 , 2 , 0 , np .nan , 0 , 1 , 2 , 1 , np .nan ])
0 commit comments