def nulp_diff(x, y, dtype=None):
import numpy as np<EOL>if dtype:<EOL><INDENT>x = np.array(x, dtype=dtype)<EOL>y = np.array(y, dtype=dtype)<EOL><DEDENT>else:<EOL><INDENT>x = np.array(x)<EOL>y = np.array(y)<EOL><DEDENT>t = np.common_type(x, y)<EOL>if np.iscomplexobj(x) or np.iscomplexobj(y):<EOL><INDENT>raise NotImplementedError("<STR_LIT>")<EOL><DEDENT>x = np.array(x, dtype=t)<EOL>y = np.array(y, dtype=t)<EOL>if not x.shape == y.shape:<EOL><INDENT>raise ValueError("<STR_LIT>" %(x.shape, y.shape))<EOL><DEDENT>def _diff(rx, ry, vdt):<EOL><INDENT>diff = np.array(rx-ry, dtype=vdt)<EOL>return np.abs(diff)<EOL><DEDENT>rx = integer_repr(x)<EOL>ry = integer_repr(y)<EOL>return _diff(rx, ry, t)<EOL>
For each item in x and y, return the number of representable floating
    points between them.

    Parameters
    ----------
    x : array_like
        first input array
    y : array_like
        second input array

    Returns
    -------
    nulp : array_like
        number of representable floating point numbers between each item in x
        and y.

    Examples
    --------
    # By definition, epsilon is the smallest number such as 1 + eps != 1, so
    # there should be exactly one ULP between 1 and 1 + eps
    >>> nulp_diff(1, 1 + np.finfo(x.dtype).eps)
    1.0