From 114ed35e7633b75baefb936dc7cd2bb0f78b3235 Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Wed, 4 Oct 2023 10:32:21 +0200 Subject: [PATCH 1/7] add python 3.12 test suite --- .github/workflows/tests.yaml | 11 +++++++++++ pyproject.toml | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 0114a5f..f935833 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -7,6 +7,7 @@ on: jobs: test: runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} strategy: fail-fast: false matrix: @@ -15,22 +16,32 @@ jobs: python: "3.10" os: ubuntu-latest toxenv: py310 + experimental: false - name: Test suite with py311-ubuntu python: "3.11" os: ubuntu-latest toxenv: py311 + experimental: false + - name: Test suite with py312-ubuntu + python: "3.12-dev" + os: ubuntu-latest + toxenv: py312 + experimental: true - name: Type check with mypy python: "3.10" os: ubuntu-latest toxenv: type + experimental: false - name: Formatting with black + isort python: "3.10" os: ubuntu-latest toxenv: format + experimental: false - name: Linting with flake8 + ruff python: "3.10" os: ubuntu-latest toxenv: lint + experimental: false name: ${{ matrix.name }} env: diff --git a/pyproject.toml b/pyproject.toml index c16a3b9..16fa028 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,7 @@ pythonpath = ["src"] legacy_tox_ini = """ [tox] requires = tox>=4 - env_list = format, type, lint, py{310,311} + env_list = format, type, lint, py{310,311,312} [testenv] description = run unit tests @@ -82,8 +82,8 @@ legacy_tox_ini = """ basepython = python3.10 extras = formatting commands = - black src - isort src + black src --check --verbose + isort src --check [testenv:type] description = run type checks From 4efeb0e8a1eccf8b646e8ffe46af20278d5d08fd Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Wed, 4 Oct 2023 10:35:04 +0200 Subject: [PATCH 2/7] isort --- src/pedon/soilmodel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pedon/soilmodel.py b/src/pedon/soilmodel.py index a0f6286..60e4d38 100644 --- a/src/pedon/soilmodel.py +++ b/src/pedon/soilmodel.py @@ -3,7 +3,7 @@ import matplotlib.pyplot as plt from numpy import abs as npabs -from numpy import exp, full, linspace, log, logspace, log10 +from numpy import exp, full, linspace, log, log10, logspace from ._typing import FloatArray From bbe8b4cf2b8fc9dc46a8dfb79d5456fa84fdaccd Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Wed, 4 Oct 2023 16:45:44 +0200 Subject: [PATCH 3/7] add tests for h and gardner --- tests/test_soilmodel.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/test_soilmodel.py b/tests/test_soilmodel.py index 2b97abc..60a6579 100644 --- a/tests/test_soilmodel.py +++ b/tests/test_soilmodel.py @@ -1,11 +1,13 @@ import pytest -from numpy import logspace +from numpy import array, logspace import pedon as pe from pedon._typing import FloatArray h = -logspace(-2, 6, num=50) +theta = array([0.1, 0.2, 0.3, 0.4]) + @pytest.fixture def gen() -> pe.soilmodel.SoilModel: @@ -22,6 +24,11 @@ def sor() -> pe.soilmodel.SoilModel: return pe.Panday(k_s=10, theta_r=0.01, theta_s=0.43, alpha=0.02, beta=1.1, brook=3) +@pytest.fixture +def gar() -> pe.soilmodel.SoilModel: + return pe.Gardner(k_s=10, theta_r=0.01, theta_s=0.43, a=0.02, b=1.0, m=1.1) + + def test_theta_genuchten(gen: pe.soilmodel.SoilModel, h: FloatArray = h) -> None: gen.theta(h=h) @@ -34,6 +41,10 @@ def test_k_genuchten(gen: pe.soilmodel.SoilModel, h: FloatArray = h) -> None: gen.k(h=h) +def test_h_genuchten(gen: pe.soilmodel.SoilModel, theta: FloatArray = theta) -> None: + gen.h(theta=theta) + + def test_theta_brooks(bro: pe.soilmodel.SoilModel, h: FloatArray = h) -> None: bro.theta(h=h) @@ -46,6 +57,10 @@ def test_k_brooks(bro: pe.soilmodel.SoilModel, h: FloatArray = h) -> None: bro.k(h=h) +def test_h_brooks(bro: pe.soilmodel.SoilModel, theta: FloatArray = theta) -> None: + bro.h(theta=theta) + + def test_theta_panday(sor: pe.soilmodel.SoilModel, h: FloatArray = h) -> None: sor.theta(h=h) @@ -56,3 +71,23 @@ def test_s_panday(sor: pe.soilmodel.SoilModel, h: FloatArray = h) -> None: def test_k_panday(sor: pe.soilmodel.SoilModel, h: FloatArray = h) -> None: sor.k(h=h) + + +def test_h_panday(sor: pe.soilmodel.SoilModel, theta: FloatArray = theta) -> None: + sor.h(theta=theta) + + +def test_theta_gardner(gar: pe.soilmodel.SoilModel, h: FloatArray = h) -> None: + gar.theta(h=h) + + +def test_s_gardner(gar: pe.soilmodel.SoilModel, h: FloatArray = h) -> None: + gar.s(h=h) + + +def test_k_gardner(gar: pe.soilmodel.SoilModel, h: FloatArray = h) -> None: + gar.k(h=h) + + +def test_h_gardner(gar: pe.soilmodel.SoilModel, theta: FloatArray = theta) -> None: + gar.h(theta=theta) From c2f87d788339455df0e0cd5fbcaad12b7b092338 Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Fri, 1 Dec 2023 13:36:59 +0100 Subject: [PATCH 4/7] add specific storage to panday soil type --- src/pedon/soilmodel.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pedon/soilmodel.py b/src/pedon/soilmodel.py index 60e4d38..a57b733 100644 --- a/src/pedon/soilmodel.py +++ b/src/pedon/soilmodel.py @@ -201,6 +201,7 @@ class Panday: sr: float = field(init=False, repr=True) gamma: float = field(init=False, repr=False) # 1 - 1 / beta sy: float = field(init=False, repr=False) + ss: float = field(default=1e-6, repr=False) def __post_init__(self): self.sr = self.theta_r / self.theta_s # theta_r / theta_s From 5e6f466b9dd0498ccd041c0a52eaa35357a92c45 Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Fri, 1 Dec 2023 13:40:52 +0100 Subject: [PATCH 5/7] add gardner to init --- src/pedon/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pedon/__init__.py b/src/pedon/__init__.py index 5bc4911..c981e63 100644 --- a/src/pedon/__init__.py +++ b/src/pedon/__init__.py @@ -7,4 +7,5 @@ from .soilmodel import Brooks as Brooks from .soilmodel import Genuchten as Genuchten from .soilmodel import Panday as Panday +from .soilmodel import Gardner as Gardner from .soilmodel import plot_hcf, plot_swrc From c1bda613e4feb629b67c97b4edd3fee958677b56 Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Fri, 1 Dec 2023 14:01:46 +0100 Subject: [PATCH 6/7] Update _version.py --- src/pedon/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pedon/_version.py b/src/pedon/_version.py index 81f0fde..b1a19e3 100644 --- a/src/pedon/_version.py +++ b/src/pedon/_version.py @@ -1 +1 @@ -__version__ = "0.0.4" +__version__ = "0.0.5" From 82bcd98574d6f45cec82ca040892c997e975c2e9 Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Fri, 1 Dec 2023 14:04:25 +0100 Subject: [PATCH 7/7] Update __init__.py --- src/pedon/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pedon/__init__.py b/src/pedon/__init__.py index c981e63..6c647d2 100644 --- a/src/pedon/__init__.py +++ b/src/pedon/__init__.py @@ -5,7 +5,7 @@ from .soil import Soil as Soil from .soil import SoilSample as SoilSample from .soilmodel import Brooks as Brooks +from .soilmodel import Gardner as Gardner from .soilmodel import Genuchten as Genuchten from .soilmodel import Panday as Panday -from .soilmodel import Gardner as Gardner from .soilmodel import plot_hcf, plot_swrc