python - ValueError: setting an array element with a sequence symbolic -


I'm starting with Python I have the following code:

  import disorder imports numpy NP import sympy as import SP def champs_de_contraintes as Qtheta (epaisseurs, angle, L, eT, GLT, Nult): E0 = np.mat ( '[0; 0; 0]') #inizialising E0 K = np.mat ( '[0; 0; 0]') E0K the #inizialising = np.mat ( '[0; 0; 0; 0; 0; 0]') #inizialising K E0K = Deformation.defos (epaisseurs, Angle, L, et, GLT, Nult) #function that return a 6x1 matrix type; Class 'numpy.matrixlib.defmatrix.matrix' & gt; E0 = E0K [: 3] #Slicing 2 vectors E0K E0 and KK = E0K [3:] nb_composantes = 3 #sigma X, sigma y, Taux xy Sigmaxy = np.zeros ((nb_composantes, Lane (epaisseurs))) # Sigma X, Sigma Y, TOU XI, Array # =============== This block calculates the height of a ply ============== =========== = Z = [] E = [] z.append (for (np.sum (epaisseurs)) / 2) (range (lane (epaisseurs)): # To add height to [ar]: [i] = e [i- 1] + epaisseurs [i] #sum easel [lane (z):] = [z [0] + e [i]] # ultratitude # ================== ========= This block calculates a vector for =================== I (range (len (epaisseurs))): newcolumn = Qtheta.Qtheta (angle [i ], L, eT, GLT, Nult) * E0 + z [i] * Qtheta.Qtheta (angle [i], L, eT, GLT, Nult) * K #Z (height meter range # 3x1 = 3x3 * 3x1 + 1x1 * 3x3 * 3x1's (LAN (new column)): Sigmaksi [i, m] = new column [m] returns Sigmiksi  

this

Actually, what I want gives me an error

  sigmaxy [i, m] = newcolumn [m] value error: the installation of an array element with a sequence  Code> < / Pre> 

In a new column in the sigmax matrix, vector is intended to save "new column". I think I get this error because "new column" is symbolic. In fact, E2 and K2 depend on the variable.

Can anyone help me with it?

Thanks in advance!

If you want to set the elements of your array in this way, then you need to make sure It is necessary to match the shapes.

If you try to do something like this:

  my_1d_array = np.array ([1,2,3]) my_1d_array [0 ] = [4, 5, 6]  

By stating the error, you are trying to set an element in the sequence of elements, which is not possible. Debug your code, and ensure that the size of the Sigmaxy [i, m] and newcolumn [m] match ( .shape )

In the beginning, start your array with the right size with the space for all the elements. If you do not know the exact size, you can add columns to create larger arrays, see other questions for it.


Comments