def _comp_method_SERIES(cls, op, special):
op_name = _get_op_name(op, special)<EOL>masker = _gen_eval_kwargs(op_name).get('<STR_LIT>', False)<EOL>def na_op(x, y):<EOL><INDENT>assert not (is_categorical_dtype(y) and not is_scalar(y))<EOL>if is_object_dtype(x.dtype):<EOL><INDENT>result = _comp_method_OBJECT_ARRAY(op, x, y)<EOL><DEDENT>elif is_datetimelike_v_numeric(x, y):<EOL><INDENT>return invalid_comparison(x, y, op)<EOL><DEDENT>else:<EOL><INDENT>assert not needs_i8_conversion(x)<EOL>mask = None<EOL>if not is_scalar(y) and needs_i8_conversion(y):<EOL><INDENT>mask = isna(x) | isna(y)<EOL>y = y.view('<STR_LIT>')<EOL>x = x.view('<STR_LIT>')<EOL><DEDENT>method = getattr(x, op_name, None)<EOL>if method is not None:<EOL><INDENT>with np.errstate(all='<STR_LIT:ignore>'):<EOL><INDENT>result = method(y)<EOL><DEDENT>if result is NotImplemented:<EOL><INDENT>return invalid_comparison(x, y, op)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>result = op(x, y)<EOL><DEDENT>if mask is not None and mask.any():<EOL><INDENT>result[mask] = masker<EOL><DEDENT><DEDENT>return result<EOL><DEDENT>def wrapper(self, other, axis=None):<EOL><INDENT>if axis is not None:<EOL><INDENT>self._get_axis_number(axis)<EOL><DEDENT>res_name = get_op_result_name(self, other)<EOL>if isinstance(other, list):<EOL><INDENT>other = np.asarray(other)<EOL><DEDENT>if isinstance(other, ABCDataFrame):  <EOL><INDENT>return NotImplemented<EOL><DEDENT>elif isinstance(other, ABCSeries) and not self._indexed_same(other):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>elif is_categorical_dtype(self):<EOL><INDENT>res_values = dispatch_to_index_op(op, self, other, pd.Categorical)<EOL>return self._constructor(res_values, index=self.index,<EOL>name=res_name)<EOL><DEDENT>elif is_datetime64_dtype(self) or is_datetime64tz_dtype(self):<EOL><INDENT>if (isinstance(other, datetime.date) and<EOL>not isinstance(other, datetime.datetime)):<EOL><INDENT>msg = (<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL>if op in {operator.lt, operator.le, operator.gt, operator.ge}:<EOL><INDENT>future = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>future = (<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>msg = '<STR_LIT:\n>'.join(textwrap.wrap(msg.format(future=future)))<EOL>warnings.warn(msg, FutureWarning, stacklevel=<NUM_LIT:2>)<EOL>other = pd.Timestamp(other)<EOL><DEDENT>res_values = dispatch_to_index_op(op, self, other,<EOL>pd.DatetimeIndex)<EOL>return self._constructor(res_values, index=self.index,<EOL>name=res_name)<EOL><DEDENT>elif is_timedelta64_dtype(self):<EOL><INDENT>res_values = dispatch_to_index_op(op, self, other,<EOL>pd.TimedeltaIndex)<EOL>return self._constructor(res_values, index=self.index,<EOL>name=res_name)<EOL><DEDENT>elif (is_extension_array_dtype(self) or<EOL>(is_extension_array_dtype(other) and not is_scalar(other))):<EOL><INDENT>return dispatch_to_extension_op(op, self, other)<EOL><DEDENT>elif isinstance(other, ABCSeries):<EOL><INDENT>res_values = na_op(self.values, other.values)<EOL>return self._constructor(res_values, index=self.index,<EOL>name=res_name).rename(res_name)<EOL><DEDENT>elif isinstance(other, (np.ndarray, pd.Index)):<EOL><INDENT>if other.ndim != <NUM_LIT:0> and len(self) != len(other):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>res_values = na_op(self.values, np.asarray(other))<EOL>result = self._constructor(res_values, index=self.index)<EOL>return result.__finalize__(self).rename(res_name)<EOL><DEDENT>elif is_scalar(other) and isna(other):<EOL><INDENT>if op is operator.ne:<EOL><INDENT>res_values = np.ones(len(self), dtype=bool)<EOL><DEDENT>else:<EOL><INDENT>res_values = np.zeros(len(self), dtype=bool)<EOL><DEDENT>return self._constructor(res_values, index=self.index,<EOL>name=res_name, dtype='<STR_LIT:bool>')<EOL><DEDENT>else:<EOL><INDENT>values = self.get_values()<EOL>with np.errstate(all='<STR_LIT:ignore>'):<EOL><INDENT>res = na_op(values, other)<EOL><DEDENT>if is_scalar(res):<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>.format(typ=type(other)))<EOL><DEDENT>res_values = com.values_from_object(res)<EOL>return self._constructor(res_values, index=self.index,<EOL>name=res_name, dtype='<STR_LIT:bool>')<EOL><DEDENT><DEDENT>wrapper.__name__ = op_name<EOL>return wrapper<EOL>
Wrapper function for Series arithmetic operations, to avoid
code duplication.