6969 notna ,
7070)
7171
72- from pandas .core import arraylike
72+ from pandas .core import (
73+ arraylike ,
74+ ops ,
75+ )
7376import pandas .core .algorithms as algos
7477from pandas .core .arraylike import OpsMixin
7578from pandas .core .arrays import ExtensionArray
@@ -1808,7 +1811,9 @@ def _arith_method(self, other, op):
18081811 return _wrap_result (op_name , result , self .sp_index , fill )
18091812
18101813 else :
1811- if not isinstance (other , (list , np .ndarray , ExtensionArray )):
1814+ if not isinstance (
1815+ other , (list , np .ndarray , ExtensionArray )
1816+ ) and not ops .has_castable_attr (other ):
18121817 warnings .warn (
18131818 f"Operation with { type (other ).__name__ } are deprecated. "
18141819 "In a future version these will be treated as scalar-like. "
@@ -1830,8 +1835,10 @@ def _arith_method(self, other, op):
18301835 return _sparse_array_op (self , other , op , op_name )
18311836
18321837 def _cmp_method (self , other , op ) -> SparseArray :
1833- if is_list_like (other ) and not isinstance (
1834- other , (list , np .ndarray , ExtensionArray )
1838+ if (
1839+ is_list_like (other )
1840+ and not isinstance (other , (list , np .ndarray , ExtensionArray ))
1841+ and not ops .has_castable_attr (other )
18351842 ):
18361843 warnings .warn (
18371844 f"Operation with { type (other ).__name__ } are deprecated. "
0 commit comments