numpy - ValueError in simple Python calculation -


This is my work and the variable track is a list and each element of the list is nx 3 array: For the category (j + 1, n) in the range for j (n-1) category:

  temp = np.array (np.zeros ((n, n))) : For brain = np.zeros (LAN (tracks [j])) in range (lane (jane)): brain en [i] = np.linalg.norm (min (np.fabs (np. Array) (Tracks [w]) - tracks [j] [ii])) temporary [j] [w] = np sum (brain) / lane (tracks [j]]  

I am trying to calculate the minimum distance between the array of inventory which represents 3D lines in the space, but I am getting the error:

Value error: With more than one true value of an array, an element is unclear. Use either A.any () or a.all ().

The error is probably related to the call min () but I can not solve it. Traceback error is:

Traceback (most recent call final): File "

because the error occurs It can not determine whether a complete array is true or incorrect . What will be the boolean state of an array, where all elements are true but one?

Minimum takes one charge for each argument, and each element in the second, each comparison result in a boolean value. The individual elements are generated by altering the 1-D MMP array - min works for 1-D oval array.

  & gt; & Gt; & Gt; An array ([- 4, -3, -2, -1, 0, 1, 2, 3, 4])> gt; & Gt; & Gt; For one thing: print item, -4 -3 -2 -1 0 1 2 3 4 & gt; & Gt; & Gt; Min (A) -4 & gt; & Gt; & Gt;  

Repeats the 2-D numpy array.

  & gt; & Gt; & Gt; B array ([[-4, -3, -2], [-1, 0, 1], [2, 3, 4]]) gt; & Gt; & Gt; For talk in B: Print talk [-4 -3 -2] [-1 0] [2 3 4]> gt; & Gt;  

min will not work for 2-D arrays because it compares arrays and - the value of an array with more than one Element is unclear .

  & gt; & Gt; & Gt; C array ([0, 1, 2, 3]) & gt; & Gt; & Gt; C & lt; 2 array ([tru, tru, false, false], dtype = bool)> gt; & Gt; & Gt; Bull (c & lt; 2) traceback (most recent call final): File "& lt; pyshell # 74" gt; Line 1, & lt; Module & gt; Bool (c & lt; 2) Value error: The truth value of an array with more than one element is ambiguous. Use A.any () or a.all () & gt; & Gt; & Gt; & Gt; & Gt; & Gt; Bull (Np. Array (Truback (True, True) Traceback (most recent call final): File "& lt; pyshell # 75"; Line 1, & lt; Module & gt; Bool (np.array (True, True)) ValueError: The truth value of an array with more than one element is vague. Use A.any () or a.all () >> >> gt; & gt; & gt; Bull (Np. Array (True, False) Traceback (Most Recent Call End): File "& lt; pyshell # 76"; Line 1, & lt; Module & gt; Bool Np.array (True, False) ValueError: The truth value of an array with more than one element Use .aany () or a.all () >>> >>  

If you have elements Need to find, then numpy.amin or ndarray.min method.

  & gt; & gt; & gt; Gt; & gt; & gt; NP. Amin (B) -4>>  Bmn (-4)>>  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -