33import numpy as np
44import pytest
55
6+ from pandas .compat .numpy import _np_version_under1p20
7+
68import pandas as pd
79import pandas ._testing as tm
810from pandas .core import ops
@@ -116,9 +118,15 @@ def _check_logical_ops(self, a, b, a_dense, b_dense):
116118 @pytest .mark .parametrize ("scalar" , [0 , 1 , 3 ])
117119 @pytest .mark .parametrize ("fill_value" , [None , 0 , 2 ])
118120 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
120122 ):
121123 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+
122130 values = self ._base ([np .nan , 1 , 2 , 0 , np .nan , 0 , 1 , 2 , 1 , np .nan ])
123131
124132 a = self ._klass (values , kind = kind , fill_value = fill_value )
@@ -142,15 +150,11 @@ def test_float_scalar_comparison(self, kind):
142150 self ._check_comparison_ops (a , 0 , values , 0 )
143151 self ._check_comparison_ops (a , 3 , values , 3 )
144152
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+ ):
146156 # when sp_index are the same
147157 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 )
154158
155159 values = self ._base ([0.0 , 1.0 , 2.0 , 6.0 , 0.0 , 0.0 , 1.0 , 2.0 , 1.0 , 0.0 ])
156160 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):
159163 b = self ._klass (rvalues , kind = kind , fill_value = 0 )
160164 self ._check_numeric_ops (a , b , values , rvalues , mix , op )
161165
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+
162184 def test_float_same_index_comparison (self , kind ):
163185 # when sp_index are the same
164186 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):
324346 b = self ._klass (rvalues , kind = kind , dtype = np .bool_ , fill_value = fill_value )
325347 self ._check_logical_ops (a , b , values , rvalues )
326348
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 ):
328350 op = all_arithmetic_functions
329351
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+
330357 rdtype = "int64"
331358
332359 values = self ._base ([np .nan , 1 , 2 , 0 , np .nan , 0 , 1 , 2 , 1 , np .nan ])
0 commit comments