def offdiag_view(A, offset=0):
    from numpy.lib.stride_tricks import as_strided
    assert A.ndim == 2, "only implemented for 2 dimensions"
    Af = as_strided(A, shape=(A.size,), strides=(A.itemsize,))
    return as_strided(Af[(1+offset):], shape=(A.shape[0]-1, A.shape[1]), strides=(A.strides[0] + A.itemsize, A.strides[1]))
dataset/ETHPy150Open SheffieldML/GPy/GPy/util/diag.py/offdiag_view/original