Skip to content

Commit

Permalink
Merge pull request #200 from ArtesiaWater/dev
Browse files Browse the repository at this point in the history
Minor version update 0.11.1
  • Loading branch information
OnnoEbbens authored Mar 25, 2024
2 parents b60fb6c + 05414d5 commit 4a06b01
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 64 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ jobs:
fail-fast: true
matrix:
include:
- name: Test suite with py312-ubuntu
python: "3.12"
os: ubuntu-latest
toxenv: py312
- name: Test suite with py311-ubuntu
python: "3.11"
os: ubuntu-latest
Expand Down Expand Up @@ -47,10 +51,10 @@ jobs:
# Pytest
PYTEST_ADDOPTS: "--color=yes"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
check-latest: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Install dependencies
Expand Down
10 changes: 7 additions & 3 deletions hydropandas/io/pastas.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,17 @@ def create_pastastore(
meta = dict()

if col is None:
col = o._get_first_numeric_col_name()
use_col = o._get_first_numeric_col_name()
else:
use_col = col

if kind == "oseries":
pstore.conn.add_oseries(o[col], o.name, metadata=meta, overwrite=overwrite)
pstore.conn.add_oseries(
o[use_col], o.name, metadata=meta, overwrite=overwrite
)
else:
pstore.conn.add_stress(
o[col], o.name, kind, metadata=meta, overwrite=overwrite
o[use_col], o.name, kind, metadata=meta, overwrite=overwrite
)

return pstore
Expand Down
2 changes: 1 addition & 1 deletion hydropandas/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.11.0"
__version__ = "0.11.1"
16 changes: 4 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,18 @@ maintainers = [
{ name = "D.A. Brakenhoff", email = "d.brakenhoff@artesia-water.nl" },
{ name = "M.A. Vonk", email = "m.vonk@artesia-water.nl" },
]
requires-python = ">=3.7"
dependencies = [
"scipy",
"pandas",
"matplotlib",
"tqdm",
"requests",
"colorama",
]
requires-python = ">=3.9"
dependencies = ["scipy", "pandas", "matplotlib", "tqdm", "requests", "colorama"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"Intended Audience :: Other Audience",
"License :: OSI Approved :: MIT License",
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
"Operating System :: OS Independent",
'Topic :: Scientific/Engineering :: Hydrology',
]
Expand Down Expand Up @@ -107,7 +99,7 @@ markers = ["slow: mark test as slow."]
legacy_tox_ini = """
[tox]
requires = tox>=4
env_list = format, lint, notebooks, py{37, 38, 39, 310, 311}
env_list = format, lint, notebooks, py{39, 310, 311, 312}
[testenv]
description = run unit tests
Expand Down
56 changes: 35 additions & 21 deletions tests/test_001_to_from.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ def test_bro_gld():
# single observation
bro_id = "GLD000000012893"
hpd.GroundwaterObs.from_bro(bro_id)
return


def test_bro_gmn():
# single observation
bro_id = "GMN000000000163"
hpd.read_bro(bro_id=bro_id, only_metadata=True)
return


def test_bro_extent():
Expand All @@ -30,7 +28,6 @@ def test_bro_extent():
extent = (102395, 103121, 434331, 434750) # 4 observations within extent

hpd.read_bro(extent=extent, only_metadata=True)
return


def test_bro_extent_too_big():
Expand All @@ -49,21 +46,23 @@ def test_observation_gwq():
# single observation
path = "./tests/data/2019-Dino-test/Grondwatersamenstellingen_Put/B52C0057.txt"
hpd.WaterQualityObs.from_dino(path)
return


def test_observation_wl():
path = "./tests/data/2019-Dino-test/Peilschaal/P58A0001.csv"
hpd.WaterlvlObs.from_dino(path)
return


def test_observation_gw():
def observation_gw():
path = "./tests/data/2019-Dino-test/Grondwaterstanden_Put/B33F0080001_1.csv"
o = hpd.GroundwaterObs.from_dino(path=path)
return o


def test_observation_gw():
observation_gw()


def test_obscollection_from_list():
dino_gw = hpd.read_dino(
dirname=dinozip,
Expand All @@ -74,7 +73,6 @@ def test_obscollection_from_list():
)
obs_list = [o for o in dino_gw.obs.values]
hpd.ObsCollection(obs_list)
return


def test_obscollection_from_df():
Expand All @@ -90,7 +88,7 @@ def test_obscollection_empty():
# read dino directories


def test_obscollection_dinozip_gw():
def obscollection_dinozip_gw():
# groundwater quantity
oc = hpd.read_dino(
dirname=dinozip,
Expand All @@ -102,7 +100,7 @@ def test_obscollection_dinozip_gw():
return oc


def test_obscollection_dinozip_gw_keep_all_obs():
def obscollection_dinozip_gw_keep_all_obs():
# do not delete empty dataframes
oc = hpd.read_dino(
dirname=dinozip,
Expand All @@ -114,7 +112,7 @@ def test_obscollection_dinozip_gw_keep_all_obs():
return oc


def test_obscollection_dinozip_wl():
def obscollection_dinozip_wl():
# surface water
oc = hpd.read_dino(
dirname=dinozip, ObsClass=hpd.WaterlvlObs, subdir="Peilschaal", suffix=".csv"
Expand All @@ -123,6 +121,19 @@ def test_obscollection_dinozip_wl():
return oc


def test_obscollection_dinozip_gw():
# groundwater quantity
obscollection_dinozip_gw()


def test_obscollection_dinozip_gw_keep_all_obs():
obscollection_dinozip_gw_keep_all_obs()


def test_obscollection_dinozip_wl():
obscollection_dinozip_wl()


def test_obscollection_dinozip_gwq():
# groundwater quality
hpd.read_dino(
Expand All @@ -131,35 +142,38 @@ def test_obscollection_dinozip_gwq():
subdir="Grondwatersamenstellingen_Put",
suffix=".txt",
)
return


# %% FEWS


def obscollection_fews_lowmemory():
oc = hpd.read_fews(
"./tests/data/2019-FEWS-test/WaalenBurg_201810-20190215_prod.zip",
locations=None,
low_memory=True,
)
return oc


def test_obscollection_fews_highmemory():
hpd.read_fews(
"./tests/data/2019-FEWS-test/WaalenBurg_201810-20190215_prod.zip",
to_mnap=False,
remove_nan=False,
low_memory=False,
)
return


def test_obscollection_fews_lowmemory():
oc = hpd.read_fews(
"./tests/data/2019-FEWS-test/WaalenBurg_201810-20190215_prod.zip",
locations=None,
low_memory=True,
)
return oc
obscollection_fews_lowmemory()


def test_obscollection_fews_selection():
hpd.read_fews(
"./tests/data/2019-FEWS-test/WaalenBurg_201810-20190215_prod.zip",
locations=("MPN-N-2",),
)
return


# %% WISKI
Expand Down Expand Up @@ -193,7 +207,7 @@ def test_obscollection_wiskizip_gw():

# %% PASTASTORE
def test_to_pastastore():
dino_gw = test_obscollection_dinozip_gw()
dino_gw = obscollection_dinozip_gw()
# drop duplicate
dino_gw.drop("B22D0155-001", inplace=True)
pstore = dino_gw.to_pastastore()
Expand Down Expand Up @@ -304,7 +318,7 @@ def test_knmi_obs_from_xy():
# " https://github.com/ArtesiaWater/hydropandas/issues/103"
# )
def test_knmi_collection_from_locations():
obsc = test_obscollection_dinozip_gw()
obsc = obscollection_dinozip_gw()
try:
hpd.read_knmi(
locations=obsc, meteo_vars=["EV24", "RD"], starts="2010", ends="2015"
Expand Down
24 changes: 12 additions & 12 deletions tests/test_003_calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def test_within_extent():
dino_gw = ttf.test_obscollection_dinozip_gw()
dino_gw = ttf.obscollection_dinozip_gw()
extent = [210350, 213300, 473300, 474000]
dino_gw.geo.within_extent(extent, inplace=True)
assert dino_gw.shape[0] == 4
Expand All @@ -12,32 +12,32 @@ def test_within_extent():


def test_obscollection_consecutive_obs_years():
gw = ttf.test_obscollection_dinozip_gw_keep_all_obs()
gw = ttf.obscollection_dinozip_gw_keep_all_obs()
gw.stats.consecutive_obs_years()


def test_obscollection_get_number_of_obs():
gw = ttf.test_obscollection_dinozip_gw_keep_all_obs()
gw = ttf.obscollection_dinozip_gw_keep_all_obs()
gw.stats.get_no_of_observations()


def test_obscollection_get_first_last_obs_date():
gw = ttf.test_obscollection_dinozip_gw_keep_all_obs()
gw = ttf.obscollection_dinozip_gw_keep_all_obs()
gw.stats.get_first_last_obs_date()


def test_obscollection_get_seasonal_stats():
gw = ttf.test_obscollection_dinozip_gw_keep_all_obs()
gw = ttf.obscollection_dinozip_gw_keep_all_obs()
gw.stats.get_seasonal_stat(stat="mean")


def test_obscollection_get_min():
gw = ttf.test_obscollection_dinozip_gw_keep_all_obs()
gw = ttf.obscollection_dinozip_gw_keep_all_obs()
gw.stats.get_min()


def test_obscollection_get_max():
gw = ttf.test_obscollection_dinozip_gw_keep_all_obs()
gw = ttf.obscollection_dinozip_gw_keep_all_obs()
gw.stats.get_max()


Expand All @@ -47,8 +47,8 @@ def test_obscollection_get_max():
def test_get_nearest_point():
# check two of the same observation collections
# every point must find itself as the nearest point
dino_gw = ttf.test_obscollection_dinozip_gw()
fl = ttf.test_obscollection_dinozip_wl()
dino_gw = ttf.obscollection_dinozip_gw()
fl = ttf.obscollection_dinozip_wl()
dino_gw[["nearest point", "distance nearest point"]] = (
dino_gw.geo.get_nearest_point(fl)
)
Expand All @@ -60,7 +60,7 @@ def test_get_nearest_polygon():

# check two of the same observation collections
# every point must find itself as the nearest point
dino_gw = ttf.test_obscollection_dinozip_gw()
dino_gw = ttf.obscollection_dinozip_gw()
extent = dino_gw.geo.get_extent()
polygon1 = Polygon(
(
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_get_ground_level_oc():
try:
from art_tools import hpd_extension # noqa: F401

gw = ttf.test_obscollection_fews_lowmemory()
gw = ttf.obscollection_fews_lowmemory()
gw.art.geo_get_ground_level()
return
except ModuleNotFoundError as e:
Expand All @@ -104,7 +104,7 @@ def test_get_ground_level_gwobs():
try:
from art_tools import hpd_extension # noqa: F401

gw = ttf.test_observation_gw()
gw = ttf.observation_gw()
gw.art.geo_get_ground_level()
return
except ModuleNotFoundError as e:
Expand Down
10 changes: 5 additions & 5 deletions tests/test_004_gwobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@


def test_set_tube_nr():
dino_gw = ttf.test_obscollection_dinozip_gw()
dino_gw = ttf.obscollection_dinozip_gw()
dino_gw.gwobs.set_tube_nr(if_exists="replace")


def test_set_tube_nr_monitoring_well():
fews_gw_prod = ttf.test_obscollection_fews_lowmemory()
fews_gw_prod = ttf.obscollection_fews_lowmemory()
fews_gw_prod.gwobs.set_tube_nr_monitoring_well(
"monitoring_well", if_exists="replace"
)
Expand Down Expand Up @@ -44,7 +44,7 @@ def test_get_modellayers_mf2005():
yul=700000,
)

dino_gw = ttf.test_obscollection_dinozip_gw()
dino_gw = ttf.obscollection_dinozip_gw()
dino_gw.gwobs.get_modellayers(ml)


Expand Down Expand Up @@ -79,10 +79,10 @@ def test_get_modellayers_mf6_structured():
top=ztop,
botm=botm[1:],
)
dino_gw = ttf.test_obscollection_dinozip_gw()
dino_gw = ttf.obscollection_dinozip_gw()
dino_gw.gwobs.get_modellayers(gwf)


def test_get_regis_layer():
dino_gw = ttf.test_obscollection_dinozip_gw()
dino_gw = ttf.obscollection_dinozip_gw()
dino_gw.gwobs.get_regis_layers()
Loading

0 comments on commit 4a06b01

Please sign in to comment.