@@ -52,13 +52,16 @@ def test_div(dtype):
5252
5353
5454@pytest .mark .parametrize ("zero, negative" , [(0 , False ), (0.0 , False ), (- 0.0 , True )])
55- def test_divide_by_zero (zero , negative ):
55+ def test_divide_by_zero (zero , negative , pdep16_nan_behavior ):
5656 # https://github.com/pandas-dev/pandas/issues/27398, GH#22793
5757 a = pd .array ([0 , 1 , - 1 , None ], dtype = "Int64" )
5858 result = a / zero
59+ exp_mask = np .array ([False , False , False , True ])
60+ if pdep16_nan_behavior :
61+ exp_mask [0 ] = True
5962 expected = FloatingArray (
6063 np .array ([np .nan , np .inf , - np .inf , 1 ], dtype = "float64" ),
61- np . array ([ False , False , False , True ]) ,
64+ exp_mask ,
6265 )
6366 if negative :
6467 expected *= - 1
@@ -99,7 +102,7 @@ def test_mod(dtype):
99102 tm .assert_extension_array_equal (result , expected )
100103
101104
102- def test_pow_scalar ():
105+ def test_pow_scalar (pdep16_nan_behavior ):
103106 a = pd .array ([- 1 , 0 , 1 , None , 2 ], dtype = "Int64" )
104107 result = a ** 0
105108 expected = pd .array ([1 , 1 , 1 , 1 , 1 ], dtype = "Int64" )
@@ -114,10 +117,13 @@ def test_pow_scalar():
114117 tm .assert_extension_array_equal (result , expected )
115118
116119 result = a ** np .nan
117- expected = FloatingArray (
118- np .array ([np .nan , np .nan , 1 , np .nan , np .nan ], dtype = "float64" ),
119- np .array ([False , False , False , True , False ]),
120- )
120+ if pdep16_nan_behavior :
121+ expected = expected .astype ("Float64" )
122+ else :
123+ expected = FloatingArray (
124+ np .array ([np .nan , np .nan , 1 , np .nan , np .nan ], dtype = "float64" ),
125+ np .array ([False , False , False , True , False ]),
126+ )
121127 tm .assert_extension_array_equal (result , expected )
122128
123129 # reversed
@@ -136,10 +142,13 @@ def test_pow_scalar():
136142 tm .assert_extension_array_equal (result , expected )
137143
138144 result = np .nan ** a
139- expected = FloatingArray (
140- np .array ([1 , np .nan , np .nan , np .nan ], dtype = "float64" ),
141- np .array ([False , False , True , False ]),
142- )
145+ if pdep16_nan_behavior :
146+ expected = expected .astype ("Float64" )
147+ else :
148+ expected = FloatingArray (
149+ np .array ([1 , np .nan , np .nan , np .nan ], dtype = "float64" ),
150+ np .array ([False , False , True , False ]),
151+ )
143152 tm .assert_extension_array_equal (result , expected )
144153
145154
@@ -212,7 +221,7 @@ def test_error_invalid_values(data, all_arithmetic_operators):
212221# TODO test unsigned overflow
213222
214223
215- def test_arith_coerce_scalar (data , all_arithmetic_operators ):
224+ def test_arith_coerce_scalar (data , all_arithmetic_operators , pdep16_nan_behavior ):
216225 op = tm .get_op_from_name (all_arithmetic_operators )
217226 s = pd .Series (data )
218227 other = 0.01
@@ -222,7 +231,7 @@ def test_arith_coerce_scalar(data, all_arithmetic_operators):
222231 expected = expected .astype ("Float64" )
223232
224233 # rmod results in NaN that wasn't NA in original nullable Series -> unmask it
225- if all_arithmetic_operators == "__rmod__" :
234+ if all_arithmetic_operators == "__rmod__" and not pdep16_nan_behavior :
226235 mask = (s == 0 ).fillna (False ).to_numpy (bool )
227236 expected .array ._mask [mask ] = False
228237
0 commit comments