Numpy and python list bizarre behavior
I did the following code in python: " I created a list of numpy arrays and I tried to initialize the first row of of each array in that list with a matrix that has the same rows length as the each in that python list and has the same column length as the list length " import numpy as np N=10 dim=3 r=[np.zeros((N,dim))]*4 rt=[0.92,0.39,-0.00003] rv=[0.68,0.23,-0.036] rmer=[0.29,-0.28,-0.05] rmar=[-0.087,1.57,0.035] X=np.array([rt,rv,rmar,rmer]) for i in range(len(r)): r[i][0]=X[i] print(r) then after a several hours trying to understand why I kept getting the same first row for all the arrays w
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.