def _arith_method_SPARSE_ARRAY(cls, op, special):
op_name = _get_op_name(op, special)<EOL>def wrapper(self, other):<EOL><INDENT>from pandas.core.arrays.sparse.array import (<EOL>SparseArray, _sparse_array_op, _wrap_result, _get_fill)<EOL>if isinstance(other, np.ndarray):<EOL><INDENT>if len(self) != len(other):<EOL><INDENT>raise AssertionError("<STR_LIT>"<EOL>.format(self=len(self), other=len(other)))<EOL><DEDENT>if not isinstance(other, SparseArray):<EOL><INDENT>dtype = getattr(other, '<STR_LIT>', None)<EOL>other = SparseArray(other, fill_value=self.fill_value,<EOL>dtype=dtype)<EOL><DEDENT>return _sparse_array_op(self, other, op, op_name)<EOL><DEDENT>elif is_scalar(other):<EOL><INDENT>with np.errstate(all='<STR_LIT:ignore>'):<EOL><INDENT>fill = op(_get_fill(self), np.asarray(other))<EOL>result = op(self.sp_values, other)<EOL><DEDENT>return _wrap_result(op_name, result, self.sp_index, fill)<EOL><DEDENT>else:  <EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>.format(other=type(other)))<EOL><DEDENT><DEDENT>wrapper.__name__ = op_name<EOL>return wrapper<EOL>
Wrapper function for Series arithmetic operations, to avoid
code duplication.