From 05546747305cc527f98aa5a257f6308ef6a3da93 Mon Sep 17 00:00:00 2001 From: Paul Hobson Date: Thu, 23 May 2024 14:29:25 -0700 Subject: [PATCH 1/3] use uv in CI --- .github/workflows/check-test-coverage.yml | 7 +++++-- .github/workflows/python-runtests-basic.yml | 8 ++++++-- .github/workflows/python-runtests-img-comp.yml | 8 ++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check-test-coverage.yml b/.github/workflows/check-test-coverage.yml index c1eeae8..cd3e0c1 100644 --- a/.github/workflows/check-test-coverage.yml +++ b/.github/workflows/check-test-coverage.yml @@ -17,8 +17,11 @@ jobs: - name: Generate coverage report run: | python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi + python -m pip install uv + uv venv + source .venv/bin/activate + uv pip install pytest flake8 + if [ -f requirements_dev.txt ]; then uv pip install -r requirements_dev.txt; fi coverage run --source wqio check_wqio.py --doctest-modules --cov --cov-report=xml - name: Upload coverage reports to Codecov run: | diff --git a/.github/workflows/python-runtests-basic.yml b/.github/workflows/python-runtests-basic.yml index 178f01c..95965c8 100644 --- a/.github/workflows/python-runtests-basic.yml +++ b/.github/workflows/python-runtests-basic.yml @@ -26,8 +26,12 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install pytest - if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi + python -m pip install uv + uv venv + source .venv/bin/activate + uv pip install pytest + if [ -f requirements_dev.txt ]; then uv pip install -r requirements_dev.txt; fi - name: Test with pytest run: | + source .venv/bin/activate python check_wqio.py --doctest-modules diff --git a/.github/workflows/python-runtests-img-comp.yml b/.github/workflows/python-runtests-img-comp.yml index 253cf4a..3654653 100644 --- a/.github/workflows/python-runtests-img-comp.yml +++ b/.github/workflows/python-runtests-img-comp.yml @@ -22,9 +22,13 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi + python -m pip install uv + uv venv + source .venv/bin/activate + uv pip install pytest + if [ -f requirements_dev.txt ]; then uv pip install -r requirements_dev.txt; fi - name: Test with pytest run: | + source .venv/bin/activate export MPL_IMGCOMP_TOLERANCE=20 python check_wqio.py --strict --verbose From 8b62e801ccbe886330bd4e56b85fd0f3da4cc64a Mon Sep 17 00:00:00 2001 From: Paul Hobson Date: Thu, 23 May 2024 14:39:33 -0700 Subject: [PATCH 2/3] remove warning from wilcoxon tests --- wqio/tests/test_datacollections.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wqio/tests/test_datacollections.py b/wqio/tests/test_datacollections.py index 7fbcdf1..a6255b8 100644 --- a/wqio/tests/test_datacollections.py +++ b/wqio/tests/test_datacollections.py @@ -507,8 +507,7 @@ def test_wilcoxon(dc): F,Outflow,62.0,,28.0,0.492459,,0.656642 F,Reference,22.0,28.0,,0.952765,0.656642, """ - with pytest.warns(UserWarning): - check_stat(known_csv, dc.wilcoxon(), comp=True) + check_stat(known_csv, dc.wilcoxon(), comp=True) @helpers.seed From 2df78ca0adfce8676b7dd6a2e36481d684e637e3 Mon Sep 17 00:00:00 2001 From: Paul Hobson Date: Thu, 23 May 2024 14:45:12 -0700 Subject: [PATCH 3/3] string formatting for ruff --- wqio/hydro.py | 2 +- wqio/tests/helpers.py | 4 ++-- wqio/utils/numutils.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wqio/hydro.py b/wqio/hydro.py index 1410840..ae00d60 100644 --- a/wqio/hydro.py +++ b/wqio/hydro.py @@ -266,7 +266,7 @@ def __init__( }, self.precipcol: { "name": "Precip (mm)", - "ylabel": "%s Precip.\nDepth (mm)" % self.hydrofreq_label, + "ylabel": f"{self.hydrofreq_label} Precip.\nDepth (mm)", "color": "DarkGreen", "linewidth": 1.5, "alpha": 0.4, diff --git a/wqio/tests/helpers.py b/wqio/tests/helpers.py index 8587ffd..5869f1c 100644 --- a/wqio/tests/helpers.py +++ b/wqio/tests/helpers.py @@ -219,8 +219,8 @@ def _show_system_info(): # pragma: no cover import pytest pyversion = sys.version.replace("\n", "") - print("Python version %s" % pyversion) - print("pytest version %d.%d.%d" % pytest.__versioninfo__) + print(f"Python version {pyversion}") + print(f"pytest version {pytest.__versioninfo__}") import numpy diff --git a/wqio/utils/numutils.py b/wqio/utils/numutils.py index f3c39f4..3ff1db8 100644 --- a/wqio/utils/numutils.py +++ b/wqio/utils/numutils.py @@ -153,7 +153,7 @@ def process_p_vals(pval): elif pval > 1 or pval < 0: raise ValueError(f"p-values must be between 0 and 1 (not {pval})") else: - out = "%0.3f" % pval + out = f"{pval:0.3f}" return out @@ -377,7 +377,7 @@ def pH_to_concentration(pH, *args): # check that we recieved a valid input: if pH < 0 or pH > 14: - raise ValueError("pH = %f but must be between 0 and 14" % pH) + raise ValueError(f"pH = {pH} but must be between 0 and 14") # avogadro's number (items/mole) avogadro = 6.0221413e23