I want to do matrix calculations in multiple arrays, so I'm going through trial and error, but I get a title error.
I'm a beginner at Python, so please be gentle.
The error is in the "user_list [user_index] = np.dot(o,w)" part.
edge0user_group=[ ]
edge1 user_group = [ ]
edge2user_group = [ ]
a=np.array([1,2],[3,4]))
b=np.array([1,2],[5,6]))
c=np.array([1,2],[7,8]))
d=np.array([1,2],[9,10]))
e=np.array([3,4],[5,6]))
f=np.array([3,4],[7,8]))
g=np.array([3,4],[9,10]))
h=np.array([5,6],[7,8]))
i=np.array([5,6],[8,9]))
j=np.array([7,8],[9,10]))
user_list = [ ]
user_num=30
for user_index, oin enumerate (range(user_num)) :
o = random.choice((a,b,c,d,e,f,g,h,i,j))
w = random.choice((a,b,c,d,e,f,g,h,i,j))
data=user_list.append('userindex:', (user_index), (o), 'x', (w)))
print('user_list=',user_list)
for user_index, data in enumerate(user_list):
if user_index==0 or user_index==4 or user_index==9:
edge0 user_group.append(data))
elif user_index==1 or user_index==2 or user_index==6 or user_index==10 or user_index==17 or user_index==18:
edge1 user_group.append(data))
elif user_index==3 or user_index==8:
edge2user_group.append(data))
else:
pass
for user_index, data in enumerate(user_list):
For o in data:
For win data:
if user_index==0 or user_index==4 or user_index==9:
user_list [user_index] = np.dot(o,w)
elif user_index==1 or user_index==2 or user_index==6 or user_index==10 or user_index==17 or user_index==18:
user_list [user_index] = np.dot(o,w)
elif user_index==3 or user_index==8:
user_list [user_index] = np.dot(o,w)
else:
pass
print('edge0user_group:',edge0user_group)
print('edge1user_group:',edge1user_group)
print('edge2user_group:',edge2user_group)
print(user_list)
data
was the following tuple.
('userindex:',0,array([5,6],
[8,9]), 'x', array([1,2],
[7, 8]]))
Therefore, o
is "userindex" and w
is also "userindex".There is an error because the strings are passed as arguments to np.dot()
.
Just to guess, didn't you perform the following calculations?
for user_index, data in enumerate(user_list):
for o in data [2]:
for win data [4]:
if user_index==0 or user_index==4 or user_index==9:
user_list [user_index] = np.dot(o,w)
elif user_index==1 or user_index==2 or user_index==6 or user_index==10 or user_index==17 or user_index==18:
user_list [user_index] = np.dot(o,w)
elif user_index==3 or user_index==8:
user_list [user_index] = np.dot(o,w)
else:
pass
© 2024 OneMinuteCode. All rights reserved.