From bd74597e5c833d4af89ac324295b91e3c83b56e8 Mon Sep 17 00:00:00 2001 From: OnnoEbbens Date: Mon, 11 Mar 2024 14:47:53 +0100 Subject: [PATCH 1/6] version bump --- hydropandas/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hydropandas/version.py b/hydropandas/version.py index ae6db5f1..f0ef5726 100644 --- a/hydropandas/version.py +++ b/hydropandas/version.py @@ -1 +1 @@ -__version__ = "0.11.0" +__version__ = "0.11.1b" From 947811026fe779325c868bf47f207e7916f5d581 Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Tue, 12 Mar 2024 11:31:40 +0100 Subject: [PATCH 2/6] drop python 3.7, 3.8 and test 3.12 --- .github/workflows/ci.yml | 8 ++++++-- pyproject.toml | 16 ++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 60796883..27f8fad9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/pyproject.toml b/pyproject.toml index cbd5ebb3..53aed96e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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', ] @@ -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 From 22cbe9f92cf273037f5dbebda1f529cc6395eb7a Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Tue, 12 Mar 2024 11:31:55 +0100 Subject: [PATCH 3/6] update actions checkout and setup-python --- .github/workflows/python-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 15242e38..e9e03f37 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -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 From a236c532f9b0d4b6fba5e137ea9fb23bb8b400fa Mon Sep 17 00:00:00 2001 From: OnnoEbbens Date: Tue, 12 Mar 2024 16:25:04 +0100 Subject: [PATCH 4/6] fix for #102 (#194) * fix for #102 * fix errors --- tests/test_001_to_from.py | 56 ++++++++++++++++++++------------- tests/test_003_calculations.py | 24 +++++++------- tests/test_004_gwobs.py | 10 +++--- tests/test_008_visualisation.py | 12 +++---- 4 files changed, 58 insertions(+), 44 deletions(-) diff --git a/tests/test_001_to_from.py b/tests/test_001_to_from.py index 811f65ea..9df3ab4b 100644 --- a/tests/test_001_to_from.py +++ b/tests/test_001_to_from.py @@ -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(): @@ -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(): @@ -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, @@ -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(): @@ -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, @@ -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, @@ -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" @@ -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( @@ -131,10 +142,20 @@ 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", @@ -142,16 +163,10 @@ def test_obscollection_fews_highmemory(): 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(): @@ -159,7 +174,6 @@ def test_obscollection_fews_selection(): "./tests/data/2019-FEWS-test/WaalenBurg_201810-20190215_prod.zip", locations=("MPN-N-2",), ) - return # %% WISKI @@ -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() @@ -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" diff --git a/tests/test_003_calculations.py b/tests/test_003_calculations.py index 5f57e203..9919ebb4 100644 --- a/tests/test_003_calculations.py +++ b/tests/test_003_calculations.py @@ -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 @@ -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() @@ -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) ) @@ -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( ( @@ -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: @@ -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: diff --git a/tests/test_004_gwobs.py b/tests/test_004_gwobs.py index a9e73a76..12d51117 100644 --- a/tests/test_004_gwobs.py +++ b/tests/test_004_gwobs.py @@ -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" ) @@ -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) @@ -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() diff --git a/tests/test_008_visualisation.py b/tests/test_008_visualisation.py index 4b1b809a..71d61d00 100644 --- a/tests/test_008_visualisation.py +++ b/tests/test_008_visualisation.py @@ -4,7 +4,7 @@ def test_interactive_plot(): - gw = ttf.test_observation_gw() + gw = ttf.observation_gw() gw.plots.interactive_plot( savedir=plot_dir, cols=("stand_m_tov_nap",), @@ -14,7 +14,7 @@ def test_interactive_plot(): def test_obscollection_dino_to_imap(): - dino_gw = ttf.test_obscollection_dinozip_gw() + dino_gw = ttf.obscollection_dinozip_gw() dino_gw.geo.set_lat_lon() dino_gw.plots.interactive_map( plot_dir, @@ -31,7 +31,7 @@ def test_obscollection_dino_to_mapgraph(): try: from art_tools import hpd_extension # noqa: F401 - gw = ttf.test_obscollection_dinozip_gw() + gw = ttf.obscollection_dinozip_gw() gw.art.plot_mapgraphs(plot_ylim="min_dy") return except ModuleNotFoundError as e: @@ -39,7 +39,7 @@ def test_obscollection_dino_to_mapgraph(): def test_obscollection_dino_to_section_plot(): - dino_gw = ttf.test_obscollection_dinozip_gw() + dino_gw = ttf.obscollection_dinozip_gw() dino_gw.plots.section_plot() @@ -47,7 +47,7 @@ def test_obscollection_to_map(): try: from art_tools import hpd_extension # noqa: F401 - fews_gw_prod = ttf.test_obscollection_fews_lowmemory() + fews_gw_prod = ttf.obscollection_fews_lowmemory() fews_gw_prod.art.plot_mapfig() return except ModuleNotFoundError as e: @@ -56,7 +56,7 @@ def test_obscollection_to_map(): def test_obscollection_to_imap(): fname = "texel_fews.html" - fews_gw_prod = ttf.test_obscollection_fews_lowmemory() + fews_gw_prod = ttf.obscollection_fews_lowmemory() # add metadata to obscollection DF fews_gw_prod.add_meta_to_df("lat") fews_gw_prod.add_meta_to_df("lon") From 73500ed7c95186dc6ddd6f4e45caa2280f8798e7 Mon Sep 17 00:00:00 2001 From: OnnoEbbens Date: Wed, 13 Mar 2024 11:31:03 +0100 Subject: [PATCH 5/6] do not overwrite column when its None --- hydropandas/io/pastas.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hydropandas/io/pastas.py b/hydropandas/io/pastas.py index 80e83012..0ecba10a 100644 --- a/hydropandas/io/pastas.py +++ b/hydropandas/io/pastas.py @@ -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 From 05414d563c3889fe594147c7bf3b3a8b8313f460 Mon Sep 17 00:00:00 2001 From: OnnoEbbens Date: Mon, 25 Mar 2024 16:14:32 +0100 Subject: [PATCH 6/6] version bump --- hydropandas/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hydropandas/version.py b/hydropandas/version.py index f0ef5726..fee46bd8 100644 --- a/hydropandas/version.py +++ b/hydropandas/version.py @@ -1 +1 @@ -__version__ = "0.11.1b" +__version__ = "0.11.1"