简体   繁体   English

Python 中的“数组索引过多”错误

[英]"Too many indices for array" Error in Python

All of the below values are integers/floats.以下所有值都是整数/浮点数。

# atomic density of Pu
MPu = 239.0
NPu = np.array(((p*avo)/(MPu))*cm2tobarns)

# atomic density of U
MU = 238.07
NU = np.array(((p*avo)/(MU))*cm2tobarns)

Here are the matrices/arrays being called这是被调用的矩阵/数组

Ugroup = np.array([[1.28, 0.78, 0.2, 0.03, 0.003, 0, 0],
       [0, 1.05, 0.42, 0.01, 0.01, 0, 0],
       [0, 0, 0.33, 0.04, 0.005, 0.0009, 0],
       [0, 0, 0, 0.29, 0.003, 0.0005, 0],
       [0, 0, 0, 0, 0.18, 0.02, 0],
       [0, 0, 0, 0, 0, 0, 0.09, 0],
       [0, 0, 0, 0, 0, 0, 0.01]])

Pugroup = np.array([[0.66, 0.6, 0.19, 0.04, 0.005, 0, 0],
       [0, 0.64, 0.15, 0.03, 0.006, 0, 0],
       [0, 0, 0.31, 0.05, 0.01, 0.0009, 0],
       [0, 0, 0, 0.18, 0.01, 0.0005, 0],
       [0, 0, 0, 0, 0.13, 0.02, 0],
       [0, 0, 0, 0, 0, 0.09, 0],
       [0, 0, 0, 0, 0, 0, 0.01]])

Here is a portion of what I am trying to do.I keep getting an error message for the first line.这是我正在尝试做的一部分。我不断收到第一行的错误消息。


Sig12 = (Pugroup[0,0]*NPu) + (Ugroup[0,0]*NU)
Sig13 = (Pugroup[0,1]*NPu) + (Ugroup[0,1]*NU)
Sig14 = (Pugroup[0,2]*NPu) + (Ugroup[0,2]*NU)
Sig15 = (Pugroup[0,3]*NPu) + (Ugroup[0,3]*NU)
Sig16 = (Pugroup[0,4]*NPu) + (Ugroup[0,4]*NU)
Sig17 = (Pugroup[0,5]*NPu) + (Ugroup[0,5]*NU)
Sig18 = (Pugroup[0,6]*NPu) + (Ugroup[0,6]*NU)

Above is my code, I am trying to multiply specific values by a constant and then add them together for further calculations.以上是我的代码,我试图将特定值乘以一个常数,然后将它们加在一起以进行进一步计算。 However, I keep getting this error.但是,我不断收到此错误。 I have tried making the constants an array, but that doesn't work.我曾尝试将常量设为数组,但这不起作用。 I am not sure what does.我不确定是什么。

you need not to index with commas but with [0][0] et cetera你不需要用逗号索引,而是用[0][0]等等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM