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 diff --git a/src/pedon/__init__.py b/src/pedon/__init__.py index 5bc4911..6c647d2 100644 --- a/src/pedon/__init__.py +++ b/src/pedon/__init__.py @@ -5,6 +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 plot_hcf, plot_swrc 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" diff --git a/src/pedon/soilmodel.py b/src/pedon/soilmodel.py index a0f6286..a57b733 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 @@ -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 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)