def invalid_comparison(left, right, op):
if op is operator.eq:<EOL><INDENT>res_values = np.zeros(left.shape, dtype=bool)<EOL><DEDENT>elif op is operator.ne:<EOL><INDENT>res_values = np.ones(left.shape, dtype=bool)<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>.format(dtype=left.dtype, typ=type(right).__name__))<EOL><DEDENT>return res_values<EOL>
If a comparison has mismatched types and is not necessarily meaningful,
follow python3 conventions by:

    - returning all-False for equality
    - returning all-True for inequality
    - raising TypeError otherwise

Parameters
----------
left : array-like
right : scalar, array-like
op : operator.{eq, ne, lt, le, gt}

Raises
------
TypeError : on inequality comparisons