def masked_arith_op(x, y, op):
<EOL>xrav = x.ravel()<EOL>assert isinstance(x, (np.ndarray, ABCSeries)), type(x)<EOL>if isinstance(y, (np.ndarray, ABCSeries, ABCIndexClass)):<EOL><INDENT>dtype = find_common_type([x.dtype, y.dtype])<EOL>result = np.empty(x.size, dtype=dtype)<EOL>yrav = y if is_period_dtype(y) else y.ravel()<EOL>mask = notna(xrav) & notna(yrav)<EOL>if yrav.shape != mask.shape:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if mask.any():<EOL><INDENT>with np.errstate(all='<STR_LIT:ignore>'):<EOL><INDENT>result[mask] = op(xrav[mask],<EOL>com.values_from_object(yrav[mask]))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>assert is_scalar(y), type(y)<EOL>assert isinstance(x, np.ndarray), type(x)<EOL>result = np.empty(x.size, dtype=x.dtype)<EOL>mask = notna(xrav)<EOL>if op == pow:<EOL><INDENT>mask = np.where(x == <NUM_LIT:1>, False, mask)<EOL><DEDENT>elif op == rpow:<EOL><INDENT>mask = np.where(y == <NUM_LIT:1>, False, mask)<EOL><DEDENT>if mask.any():<EOL><INDENT>with np.errstate(all='<STR_LIT:ignore>'):<EOL><INDENT>result[mask] = op(xrav[mask], y)<EOL><DEDENT><DEDENT><DEDENT>result, changed = maybe_upcast_putmask(result, ~mask, np.nan)<EOL>result = result.reshape(x.shape)  <EOL>return result<EOL>
If the given arithmetic operation fails, attempt it again on
only the non-null elements of the input array(s).

Parameters
----------
x : np.ndarray
y : np.ndarray, Series, Index
op : binary operator