Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Adios Automated Script committed Nov 30, 2021
2 parents b388fbb + 51cd37a commit f995eaf
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion oil_library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from .models import DBSession

__version__ = '2.0.0'
__version__ = '2.0.1'


#
Expand Down
6 changes: 6 additions & 0 deletions oil_library/oil_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ def __eq__(self, other):
except Exception:
return False

def __hash__(self):
"""
so that we can use lru_cache on the methods of the object
"""
return id(self)

def __ne__(self, other):
return not self == other

Expand Down
40 changes: 40 additions & 0 deletions oil_library/tests/test_oil_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,43 @@ def test_deepcopy(self):
assert getattr(op, item) is getattr(dcop, item)
else:
assert getattr(op, item) is not getattr(dcop, item)


def test_hash():
"""
make sure OilProps is hashable
"""
op = get_oil_props('ALASKA NORTH SLOPE (MIDDLE PIPELINE, 1997)')

print(dir(op))
print(op.__hash__)
print(f"Hash is: {op.__hash__()}")

# this may change, but fpr now
assert hash(op) == id(op)


def test_vapor_pressure():

# making sure the lru_cache works
op = get_oil_props('ALASKA NORTH SLOPE (MIDDLE PIPELINE, 1997)')

vp = op.vapor_pressure(303)

print(f"{vp=}")

# I have no idea if these values are correct
assert np.allclose(vp, np.array([4.25112967e+04, 4.25112967e+04,
4.33030879e+03, 4.33030879e+03,
3.44544154e+02, 3.44544154e+02,
2.11131481e+01, 2.11131481e+01,
1.03347266e+00, 1.03347266e+00,
4.67207773e-02, 4.67207773e-02,
2.25663515e-03, 2.25663515e-03,
1.34558585e-04, 1.34558585e-04,
2.73632461e-05, 2.73632461e-05,
1.91947361e-05, 1.91947361e-05,
4.83593789e-19, 4.83593789e-19]))



4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ def run(self):
# build_py is an old-style class, so we can't use super()
build_py.run(self)

DESCRIPTION = ('{}: The NOAA library of oils and their properties.\n'
'Branch: {}\n'
DESCRIPTION = ('{}: The NOAA library of oils and their properties.'
'Branch: {}'
'LastUpdate: {}'
.format(pkg_name, *get_repo_data())
)
Expand Down

0 comments on commit f995eaf

Please sign in to comment.