AguaClara / aguaclara

An open-source Python package for designing and performing research on AguaClara water treatment plants.
https://aguaclara.github.io/aguaclara/
MIT License
24 stars 13 forks source link

list index out of range #155

Closed WalterGuardado closed 5 years ago

WalterGuardado commented 5 years ago

@oliver-leung Is it possible that the list handler needs to be modified or removed?

FlowRate = 10 u.L / u.s HeadLoss = 1500 u.m - 1440 u.m Length = 2.5 u.km Temp = 30 u.degC Nu = pc.viscosity_kinematic(Temp) PipeRough = 0.1 u.mm KMinor = 0.5 + 1

pc.diam_pipe(FlowRate, HeadLoss, Length, Nu, PipeRough, KMinor)

IndexError Traceback (most recent call last)

in ----> 1 pc.diam_pipe(FlowRate, HeadLoss, Length, Nu, PipeRough, KMinor) ~\AppData\Local\Continuum\anaconda3.1\lib\site-packages\pint\registry_helpers.py in wrapper(*values, **kw) 190 # In principle, the values are used as is 191 # When then extract the magnitudes when needed. --> 192 new_values, values_by_name = converter(ureg, values, strict) 193 194 result = func(*new_values, **kw) ~\AppData\Local\Continuum\anaconda3.1\lib\site-packages\pint\registry_helpers.py in _converter(ureg, values, strict) 117 for ndx in unit_args_ndx: 118 --> 119 if isinstance(values[ndx], ureg.Quantity): 120 new_values[ndx] = ureg._convert(values[ndx]._magnitude, 121 values[ndx]._units, IndexError: list index out of range
jacqueline-wong commented 5 years ago

Me too!!!!!!

JC-Conneely commented 5 years ago

I'm also getting this error!

jacqueline-wong commented 5 years ago

After using teletype, we realised that Ananya could run Justin and I's code but neither of us could run hers... Perhaps this is an issue with Macs and specifically Macs updated to Mojave? And within that, perhaps an issue with "PipeRough" because only functions with that variable have issues...

monroews commented 5 years ago

I checked this on my computer. I am using the code below and it works fine. So now I'm wondering if we are dealing with different versions of python?

Type "python --version" in the anaconda Prompt or command line window. I am using python version 3.6.6

SDR = 26
Q = 10 * u.L/u.s
delta_elevation = 1500 * u.m - 1440 * u.m
L_pipe = 2.5 * u.km
K_minor = 1.5
# The maximum viscosity will occur at the lowest temperature.
T_crit = 10* u.degC
nu = pc.viscosity_kinematic(T_crit)
e = 0.1 * u.mm
pipeline_ID_min = pc.diam_pipe(Q,delta_elevation,L_pipe,nu,e,K_minor)
JC-Conneely commented 5 years ago

Ananya's is working, and she's also on version 3.6 as well. The code isn't working for Jacqueline and I, and we're both on version 3.7.

Is the best solution to uninstall python completely and reinstall version 3.6?

monroews commented 5 years ago

I'd suggest switching to version 3.6.6 and seeing if that fixes the problem.

Here is a link to a way that I found. I've not tested it!

Let us know if this works!

jacqueline-wong commented 5 years ago

I just downgraded my Python to 3.6.6 but it still has the same error unfortunately. @JustinConneely had the same issue as well

monroews commented 5 years ago

I think the problem is the list handler that enables our functions to handle arrays. I'm asking @oliver-leung and @fletchapin to see if they can release a version of AguaClara with the list handler removed. In the meantime you can assume an answer where the code breaks and then move ahead in the assignment. Hopefully we will have a new code release soon.

WalterGuardado commented 5 years ago

I installed aguaclara version 0.0.16 which didn´t have the list handle installed. Now I get this error. This suggests that the problem isn´t the list handler.

IndexError Traceback (most recent call last)

in ----> 1 pc.diam_pipe(FlowRate, HeadLoss, Length, Nu, PipeRough, KMinor) ~\AppData\Local\Continuum\anaconda3.1\lib\site-packages\pint\registry_helpers.py in wrapper(*values, **kw) 190 # In principle, the values are used as is 191 # When then extract the magnitudes when needed. --> 192 new_values, values_by_name = converter(ureg, values, strict) 193 194 result = func(*new_values, **kw) ~\AppData\Local\Continuum\anaconda3.1\lib\site-packages\pint\registry_helpers.py in _converter(ureg, values, strict) 117 for ndx in unit_args_ndx: 118 --> 119 if isinstance(values[ndx], ureg.Quantity): 120 new_values[ndx] = ureg._convert(values[ndx]._magnitude, 121 values[ndx]._units, IndexError: list index out of range
monroews commented 5 years ago

I get an error running the pc.diam_pipe function when I am using pint version 0.9. I can fix the error by installing pint version 0.8.1. you can try this by typing this in Anaconda prompt pip install pint==0.8.1

jacqueline-wong commented 5 years ago

It works for me now! Thank you so much!

JC-Conneely commented 5 years ago

This worked for me as well. Thank you!

monroews commented 5 years ago

@oliver-leung I restarted Atom with your local fix of the aguaclara code and the density function now returns a value that can be displayed without causing an error. I'd suggest pushing that fix and releasing a new version of aguaclara code right away. Thanks!

fletchapin commented 5 years ago

@oliver-leung @monroews if we're releasing a fix for this I'd suggest also adding in the adjustment to round_sf() which allows for units to be input/returned

oliver-leung commented 5 years ago

Got it - let's continue discussion of the water density function in #152.

Task: specify pint==0.8.1 in setup.py.

oliver-leung commented 5 years ago

Completed