def _td_array_cmp(cls, op):
opname = '<STR_LIT>'.format(name=op.__name__)<EOL>nat_result = opname == '<STR_LIT>'<EOL>def wrapper(self, other):<EOL><INDENT>if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):<EOL><INDENT>return NotImplemented<EOL><DEDENT>if _is_convertible_to_td(other) or other is NaT:<EOL><INDENT>try:<EOL><INDENT>other = Timedelta(other)<EOL><DEDENT>except ValueError:<EOL><INDENT>return ops.invalid_comparison(self, other, op)<EOL><DEDENT>result = op(self.view('<STR_LIT>'), other.value)<EOL>if isna(other):<EOL><INDENT>result.fill(nat_result)<EOL><DEDENT><DEDENT>elif not is_list_like(other):<EOL><INDENT>return ops.invalid_comparison(self, other, op)<EOL><DEDENT>elif len(other) != len(self):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>other = type(self)._from_sequence(other)._data<EOL><DEDENT>except (ValueError, TypeError):<EOL><INDENT>return ops.invalid_comparison(self, other, op)<EOL><DEDENT>result = op(self.view('<STR_LIT>'), other.view('<STR_LIT>'))<EOL>result = com.values_from_object(result)<EOL>o_mask = np.array(isna(other))<EOL>if o_mask.any():<EOL><INDENT>result[o_mask] = nat_result<EOL><DEDENT><DEDENT>if self._hasnans:<EOL><INDENT>result[self._isnan] = nat_result<EOL><DEDENT>return result<EOL><DEDENT>return compat.set_function_name(wrapper, opname, cls)<EOL>
Wrap comparison operations to convert timedelta-like to timedelta64