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

link to old version of pint #271

Closed monroews closed 3 years ago

monroews commented 4 years ago

The install requirements currently link to an old version of pint. Is there a reason not to use the current version of Pint and thus speed up the install on Colab? In Colab it has to uninstall Pint 0.12 to revert to the old version of Pint.

Found existing installation: Pint 0.12 Uninstalling Pint-0.12: Successfully uninstalled Pint-0.12 Successfully installed aguaclara-0.2.1 pint-0.8.1

HannahSi commented 4 years ago

The required Pint version was set to 0.8.1 to solve issue #155. When I briefly tried testing the package with version 0.12, I didn't find the same errors as before, but a few other tests did fail. We'll look into what it takes to make this upgrade.

HannahSi commented 3 years ago

The failing tests turned to be caused by round off errors. I believe I've fixed all of them on branch hs649/upgrade-pint.

Note to self: remember to update pint versions in Pipfile.lock.

HannahSi commented 3 years ago

The Pint version has been upgraded to the latest version (0.16.1) on my branch. A few precision-related errors remain in the doctests of the aguaclara.design modules. For example, this doctest at the beginning of sed_tank.py:

""" ...
Example:
    >>> from aguaclara.design.sed_tank import *
    >>> sed_tank = SedimentationTank(q = 60 * u.L / u.s)
    >>> sed_tank.diffuser_hl
    <Quantity(0.009259259259259259, 'centimeter')>
"""

results in the following error (see outputs in Travis build) while running make doctest:

Failed example:
    sed_tank.diffuser_hl
Expected:
    <Quantity(0.009259259259259259, 'centimeter')>
Got:
    <Quantity(0.00925925926, 'centimeter')>

@oliver-leung and @ryan26192, what are your thoughts on modifying the example code to prevent round-off errors, e.g. round(sed_tank.diffuser_hl, 6)? Alternatively, since precision might vary again with future versions of Pint and between computers in general, and the aguaclara.design modules are already pytest-ed in test files, would it be worth turning these doctests into static RST code blocks?

ryan26192 commented 3 years ago

I think modifying the code to prevent round off errrors with the round function makes a lot of sense, if we keep a normal amount of sig figs (3,4, or 5) it would probably be free from errors surrounding pint

HannahSi commented 3 years ago

Sounds good, thanks for your input! I'll use the round function in the doctests.