blosc2.eye#
- blosc2.eye(N, M=None, k=0, dtype=<class 'numpy.float64'>, **kwargs: ~typing.Any)#
Return a 2-D array with ones on the diagonal and zeros elsewhere.
- Parameters:
N¶ (int) – Number of rows in the output.
M¶ (int, optional) – Number of columns in the output. If None, defaults to N.
k¶ (int, optional) – Index of the diagonal: 0 (the default) refers to the main diagonal, a positive value refers to an upper diagonal, and a negative value to a lower diagonal.
dtype¶ (np.dtype or list str) – The data type of the array elements in NumPy format. Default is np.float64.
- Returns:
out – A NDArray is returned.
- Return type:
Examples
>>> import blosc2 >>> import numpy as np >>> array = blosc2.eye(2, 3, dtype=np.int32) >>> print(array[:]) [[1 0 0] [0 1 0]]