NumPy - Arrays - Special Types of Arrays - Array filled with specific value

i did not under stand.

4 Creating Identity matrix or array**

tup_dim = (1,4)

my_identity_array = np.identity(tup_dim)

print(my_identity_array)

output

TypeError Traceback (most recent call last)
in
1 tup_dim = (1,4)
2
----> 3 my_identity_array = np.identity(tup_dim)
4
5 print(my_identity_array)

/usr/local/anaconda/lib/python3.6/site-packages/numpy/core/numeric.py in identity(n, dtype)
2346 β€œβ€"
2347 from numpy import eye
-> 2348 return eye(n, dtype=dtype)
2349
2350

/usr/local/anaconda/lib/python3.6/site-packages/numpy/lib/twodim_base.py in eye(N, M, k, dtype, order)
199 if M is None:
200 M = N
–> 201 m = zeros((N, M), dtype=dtype, order=order)
202 if k >= M:
203 return m

TypeError: β€˜tuple’ object cannot be interpreted as an integer

​
why this is showing?

i could not understand.

please help.

I am not able to understand your questions. Could you be more clear and specific?

Also, please go thru the NumPy tutorial of CloudxLab.

i did it. It was mistake.

Thank you

2 Likes