@@ -155,6 +155,41 @@ def _check_fill(meth, op, a, b, fill_value=0):
155
155
# should accept axis=0 or axis='rows'
156
156
op (a , b , axis = 0 )
157
157
158
+ def test_extarray_rhs_datetime_sub_with_fill_value (self ):
159
+ # Ensure ExtensionArray (DatetimeArray) RHS is handled via array-like path
160
+ # and does not hit scalar isna branch.
161
+ left = Series (
162
+ [
163
+ pd .Timestamp ("2025-08-20" ),
164
+ pd .Timestamp ("2025-08-21" ),
165
+ pd .Timestamp ("2025-08-22" ),
166
+ ],
167
+ dtype = np .dtype ("datetime64[ns]" )
168
+ )
169
+ right = left ._values # DatetimeArray
170
+
171
+ result = left .sub (right , fill_value = left .iloc [0 ])
172
+ # result dtype may vary (e.g., seconds vs ns), build expected from result dtype
173
+ expected = Series (np .zeros (3 , dtype = np .dtype ("timedelta64[ns]" )))
174
+ tm .assert_series_equal (result , expected )
175
+
176
+ def test_extarray_rhs_timedelta_sub_with_fill_value (self ):
177
+ left = Series ([Timedelta (days = 1 ), Timedelta (days = 2 ), Timedelta (days = 3 )], dtype = np .dtype ("timedelta64[ns]" ))
178
+ right = left ._values # TimedeltaArray
179
+
180
+ result = left .sub (right , fill_value = left .iloc [0 ])
181
+ expected = Series (np .zeros (3 , dtype = np .dtype ("timedelta64[ns]" )))
182
+ tm .assert_series_equal (result , expected )
183
+
184
+ def test_extarray_rhs_period_eq_with_fill_value (self ):
185
+ # Use equality to validate ExtensionArray RHS path for PeriodArray
186
+ left = Series (pd .period_range ("2020Q1" , periods = 3 , freq = "Q" ))
187
+ right = left ._values # PeriodArray
188
+
189
+ result = left .eq (right , fill_value = left .iloc [0 ])
190
+ expected = Series ([True , True , True ])
191
+ tm .assert_series_equal (result , expected )
192
+
158
193
159
194
class TestSeriesArithmetic :
160
195
# Some of these may end up in tests/arithmetic, but are not yet sorted
@@ -404,6 +439,15 @@ def test_comparison_flex_alignment(self, values, op):
404
439
expected = Series (values , index = list ("abcd" ))
405
440
tm .assert_series_equal (result , expected )
406
441
442
+ def test_extarray_rhs_categorical_eq_with_fill_value (self ):
443
+ # Categorical RHS should be treated as array-like, not as scalar
444
+ left = Series (Categorical (["a" , "b" , "a" ]))
445
+ right = left ._values # Categorical
446
+
447
+ result = left .eq (right , fill_value = left .iloc [0 ])
448
+ expected = Series ([True , True , True ])
449
+ tm .assert_series_equal (result , expected )
450
+
407
451
@pytest .mark .parametrize (
408
452
"values, op, fill_value" ,
409
453
[
0 commit comments