Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Boolean value of Quantity with offset unit is ambiguous. #1169

Closed
afrazahmad21 opened this issue Sep 7, 2020 · 2 comments
Closed

Comments

@afrazahmad21
Copy link

# Temperature
T = 35 * u.degC

print(type(T))
# Pressure (from operation data)
P = 101.325 * u.kPa  # 1 atp

print(P)
# Duty flow rate
Q = 0.007165 * u.m ** 3 / u.sec  # equivalent to 429.91 L/min

# Fluid property (from operation data)
fluid = Stream('water', T=T, P=P, Q=Q)

Pint version = 0.15

Error StackTrace

Traceback (most recent call last):
File "/home/afraz/Desktop/IPMS-PYTHON/IPMS-API/Modules/CalculationSheet/sanjel/DashboardTable/PumpEfficiency.py", line 204, in
fluid = Stream('water', T=T, P=P, Q=Q)
File "/home/afraz/Desktop/IPMS-PYTHON/IPMS-API/venv/lib/python3.7/site-packages/thermo/stream.py", line 215, in init
T=T, P=P, Vf_TP=V_TP)
File "/home/afraz/Desktop/IPMS-PYTHON/IPMS-API/venv/lib/python3.7/site-packages/thermo/mixture.py", line 451, in init
self.Chemicals = [Chemical(component, P=P, T=T) for component in self.components]
File "/home/afraz/Desktop/IPMS-PYTHON/IPMS-API/venv/lib/python3.7/site-packages/thermo/mixture.py", line 451, in
self.Chemicals = [Chemical(component, P=P, T=T) for component in self.components]
File "/home/afraz/Desktop/IPMS-PYTHON/IPMS-API/venv/lib/python3.7/site-packages/thermo/chemical.py", line 578, in init
self.calculate(T, P)
File "/home/afraz/Desktop/IPMS-PYTHON/IPMS-API/venv/lib/python3.7/site-packages/thermo/chemical.py", line 587, in calculate
if T:
File "/home/afraz/Desktop/IPMS-PYTHON/IPMS-API/venv/lib/python3.7/site-packages/pint/quantity.py", line 1556, in bool
raise ValueError("Boolean value of Quantity with offset unit is ambiguous.")
ValueError: Boolean value of Quantity with offset unit is ambiguous.

@dopplershift
Copy link
Contributor

I'm not sure this is a bug. The problem is, with an offset unit, it's not clear what the right answer is. Let's take the example of 0 degrees Celsius. Being zero, this could reasonably be considered False. If you convert to Kelvin, this is now 273.15 and would be True.

@jthielen
Copy link
Contributor

jthielen commented Sep 23, 2020

This is intentional behavior, and not a bug. See: #866 and #965

@hgrecco hgrecco closed this as completed Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants