Could someone explain why I get this warning
<>:18: SyntaxWarning: list indices must be integers or slices, not tuple; perhaps you missed a comma?
and this error message
TypeError Traceback (most recent call last)
Cell In[62], line 18
12 weights.extend([w / d] * d)
14 return maut_method(D, weights, ['min'] * 54 + ['max'] * 10 + ['min'] * 1 + ['max'] * 1 + ['min'] * 1, ['exp'] * 67, graph=True) #poistin tästä 0.01 joka on varmaan step funktion koko
17 dataset = np.array([
---> 18 [1, 1, 1, 1, 1, 2, 2, 2, 3, 59.4, 4.13, 4, 4, 2, 3, 4, 4, 1, 1, 1, 1, 1, 1, 1550, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.43, 187, 1.87e-05, 0.0698, 0.149, 1, 0.0398, 1, 1, 1, 1, 1, 1, 315, 6030, 1, 2910, 0.00134, 1, 183, 27.2, 30.6, 3, 48, 3, 23, 14, 3.3, 1, 3.65, 0.025, 2, 0.0] #SnPb
19 [1, 1, 1, 1, 1, 2, 2, 2, 3, 57.5, 5.04, 3, 3, 1, 3, 3, 3, 1, 1, 1, 1, 1, 1, 198, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 357, 4.13e-05, 0.551, 1.47, 1, 0.12, 1, 1, 1, 1, 1, 1, 768, 8760, 1, 5770, 0.0214, 1, 218, 28, 32, 3.4, 22.1, 3, 27, 17, 13, 5, 8.936, 0.304, 2, 0.0] #SAC water
20 [1, 1, 1, 1, 1, 2, 2, 2, 3, 57.5, 5.04, 3, 3, 1, 3, 3, 3, 1, 1, 1, 1, 1, 1, 198, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 357, 4.13e-05, 0.551, 1.47, 1, 0.12, 1, 1, 1, 1, 1, 1, 768, 8760, 1, 5770, 0.0214, 1, 218, 20, 30, 6.2, 26.1, 3, 27, 17, 13, 5, 8.936, 0.304, 2, 0.0] #SAC air
21 [1, 1, 1, 1, 1, 2, 2, 2, 3, 54.9, 2.58, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 8.7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.53, 216, 1.78e-05, 0.0706, 0.199, 1, 0.0364, 1, 1, 1, 1, 1, 1, 312, 5830, 1, 3400, 0.00133, 1, 227, 15, 19, 5.4, 20.8, 2, 21.5, 18.5, 8.6, 2.1, 1.125, 0.41, 2, 0.0] #SnCu water
22 [1, 1, 1, 1, 1, 2, 2, 2, 3, 54.9, 2.58, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 8.7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.53, 216, 1.78e-05, 0.0706, 0.199, 1, 0.0364, 1, 1, 1, 1, 1, 1, 312, 5830, 1, 3400, 0.00133, 1, 227, 16, 22, 9.1, 41.2, 2, 21.5, 18.5, 8.6, 2.1, 1.125, 0.41, 2, 0.0] #SnCu air
23 ])
27 print(get_ranks(dataset))
TypeError: list indices must be integers or slices, not tuple
I think my data is a proper numpy array containing integers and decimal numbers. So what is the problem?
Here is my code
import pyDecision
import numpy as np
from pyDecision.algorithm import maut_method
def get_ranks(D):
Ws, Ds = [13.75, 20.83, 18.75, 18.33, 14.58, 13.75], [5, 18, 10, 20, 11, 3]
weights = []
for w, d in zip(Ws, Ds):
weights.extend([w / d] * d)
return maut_method(D, weights, ['min'] * 54 + ['max'] * 10 + ['min'] * 1 + ['max'] * 1 + ['min'] * 1, ['exp'] * 67, graph=True)
dataset = np.array([
[1, 1, 1, 1, 1, 2, 2, 2, 3, 59.4, 4.13, 4, 4, 2, 3, 4, 4, 1, 1, 1, 1, 1, 1, 1550, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.43, 187, 1.87e-05, 0.0698, 0.149, 1, 0.0398, 1, 1, 1, 1, 1, 1, 315, 6030, 1, 2910, 0.00134, 1, 183, 27.2, 30.6, 3, 48, 3, 23, 14, 3.3, 1, 3.65, 0.025, 2, 0.0] #a1
[1, 1, 1, 1, 1, 2, 2, 2, 3, 57.5, 5.04, 3, 3, 1, 3, 3, 3, 1, 1, 1, 1, 1, 1, 198, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 357, 4.13e-05, 0.551, 1.47, 1, 0.12, 1, 1, 1, 1, 1, 1, 768, 8760, 1, 5770, 0.0214, 1, 218, 28, 32, 3.4, 22.1, 3, 27, 17, 13, 5, 8.936, 0.304, 2, 0.0] #a2
[1, 1, 1, 1, 1, 2, 2, 2, 3, 57.5, 5.04, 3, 3, 1, 3, 3, 3, 1, 1, 1, 1, 1, 1, 198, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 357, 4.13e-05, 0.551, 1.47, 1, 0.12, 1, 1, 1, 1, 1, 1, 768, 8760, 1, 5770, 0.0214, 1, 218, 20, 30, 6.2, 26.1, 3, 27, 17, 13, 5, 8.936, 0.304, 2, 0.0] #a3
[1, 1, 1, 1, 1, 2, 2, 2, 3, 54.9, 2.58, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 8.7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.53, 216, 1.78e-05, 0.0706, 0.199, 1, 0.0364, 1, 1, 1, 1, 1, 1, 312, 5830, 1, 3400, 0.00133, 1, 227, 15, 19, 5.4, 20.8, 2, 21.5, 18.5, 8.6, 2.1, 1.125, 0.41, 2, 0.0] #a4
[1, 1, 1, 1, 1, 2, 2, 2, 3, 54.9, 2.58, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 8.7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.53, 216, 1.78e-05, 0.0706, 0.199, 1, 0.0364, 1, 1, 1, 1, 1, 1, 312, 5830, 1, 3400, 0.00133, 1, 227, 16, 22, 9.1, 41.2, 2, 21.5, 18.5, 8.6, 2.1, 1.125, 0.41, 2, 0.0] #a5
])
print(get_ranks(dataset))
,
at the end of each sub_List eg should be...2, 0.0], #a1
and so on[1,2,3,...][1,4,5]
is parsed as a list indexed with a tuple, not as fwo separate lists.perhaps you missed a comma