def H(P):
    """
    P is an array of dimension 1 or 2.

    If P is a matrix, entropy is computed row-wise. (P is assumed to
    be left stochastic)
    """
    P = P.astype(np.float)

    if 2 < P.ndim:
        P = P.reshape((1,P.size))

    # Allow negative infinity without complaint
    old_settings = np.seterr(divide='ignore')
    logP = np.log2(P)
    np.seterr(**old_settings)

    logP[(P == 0)] = 0.
    out = -1 * (P * logP).sum(1)

    out = np.squeeze(out)
    if out.ndim == 0:
        return out[()]
    return out
dataset/ETHPy150Open inpho/vsm/vsm/spatial.py/H/swapped operands of `<`