Python Forum
ValueError: The truth value of an array with more than one element is ambiguous.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ValueError: The truth value of an array with more than one element is ambiguous.
#1
I am working on a simple code, for calculating Re number. The problem is that I want to check every number in Re vector, although I do not know how to do it.
The error I am getting is: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

The code:
import numpy as np
from CoolProp.CoolProp import PropsSI
from numpy import*

v = [1,2,3,4,5]
Tz = 42 + 273
v = 4e-2 # [m]
s = 2e-2 # [m]
#------------------------------------------------------------------------------------

npv = np.array(v)

A = v*s
ob = 2*(s + v)
Dh = (4*A)/ ob
roZ = PropsSI('D', 'P', 101325, 'T', Tz, 'Air')
din_vis= PropsSI('V', 'P', 101325, 'T', Tz, 'Air')
kin_vis = din_vis/roZ

Re= (npv *Dh )/ kin_vis
Pr = PropsSI('PRANDTL', 'P', 101325, 'T', Tz, 'Air')
print ('Re:',Re)
print ('Pr:',Pr)

if Re < 2300:
    print('Laminar flow, Re = ', Re)
elif Re > 10000 and Pr >= 0.6 and Pr <= 160:
    print('Turbolent flow, Re = ', Re)
    print('Pr = ', Pr)
else:
    print(' Re = ', Re)
    print('Pr = ', Pr)
Any help is much appreciated.
Reply


Messages In This Thread
ValueError: The truth value of an array with more than one element is ambiguous. - by Eliza5 - Mar-31-2018, 09:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  RandomForest --ValueError: setting an array element with a sequence JaneTan 0 1,779 Sep-08-2021, 02:12 AM
Last Post: JaneTan
  Data cardinality is ambiguous: x sizes: 51 y sizes: 26 sidra 0 2,357 Oct-03-2020, 11:43 AM
Last Post: sidra
  error : value of a DataFrame is ambiguous Sonata 1 2,307 Apr-24-2020, 05:40 PM
Last Post: anbu23
  ValueError: Found array with 0 samples marcellam 1 5,273 Apr-22-2020, 04:12 PM
Last Post: jefsummers
  I am trying to change the value of an element in a record array ingu 1 2,220 Jan-14-2020, 01:30 PM
Last Post: perfringo
  TensorFlow get error - array with more than one element is ambiguous vokoyo 3 5,618 Nov-07-2019, 01:12 PM
Last Post: ThomasL
  ValueError: The truth value of a Series is ambiguous ? firebird 1 4,374 Aug-01-2019, 12:33 AM
Last Post: scidam
  ValueError: could not broadcast input array from shape (75) into shape (25) route2sabya 0 6,526 Mar-14-2019, 01:14 PM
Last Post: route2sabya
  How to add an element such as an average to a multi-dimensional array? xhughesey 6 4,103 Jan-06-2019, 10:47 PM
Last Post: xhughesey
  Convert element of list to integer(Two dimentional array) zorro_phu 3 4,868 Jun-12-2018, 04:49 AM
Last Post: zorro_phu

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020