What are the advantages of using numpy.identity over numpy.eye?

identity just calls eye so there is no difference in how the arrays are constructed. Here’s the code for identity:

def identity(n, dtype=None):
    from numpy import eye
    return eye(n, dtype=dtype)

As you say, the main difference is that with eye the diagonal can may be offset, whereas identity only fills the main diagonal.

Since the identity matrix is such a common construct in mathematics, it seems the main advantage of using identity is for its name alone.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)