Skip to content

Commit

Permalink
Merge pull request #4 from martinvonk/dev
Browse files Browse the repository at this point in the history
Update main to v0.0.5
  • Loading branch information
martinvonk authored Dec 1, 2023
2 parents 00b4214 + 82bcd98 commit 4a1aac7
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 6 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
jobs:
test:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/pedon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/pedon/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.4"
__version__ = "0.0.5"
3 changes: 2 additions & 1 deletion src/pedon/soilmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
37 changes: 36 additions & 1 deletion tests/test_soilmodel.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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)

0 comments on commit 4a1aac7

Please sign in to comment.