From 73ca3e14fa53dfe5aff23e55a0aa8bdc3cae29b1 Mon Sep 17 00:00:00 2001 From: Katelyn FitzGerald <7872563+kafitzgerald@users.noreply.github.com> Date: Fri, 19 Apr 2024 10:25:21 -0600 Subject: [PATCH 1/6] Update environment.yml --- build_envs/environment.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build_envs/environment.yml b/build_envs/environment.yml index b78dfcc..f06c8eb 100644 --- a/build_envs/environment.yml +++ b/build_envs/environment.yml @@ -7,13 +7,13 @@ dependencies: - make - matplotlib - sphinx - - pip - cmaps - numpy - xarray - metpy - pint + - pytest + - pytest-mpl - geocat-datafiles - - pip: - - pre-commit - - scikit-learn + - pre-commit + - scikit-learn From 77e7ab91225dc546e72e20edaadb6b1dbb8653e8 Mon Sep 17 00:00:00 2001 From: Katelyn FitzGerald <7872563+kafitzgerald@users.noreply.github.com> Date: Fri, 19 Apr 2024 10:44:24 -0600 Subject: [PATCH 2/6] add some basic test infra --- .github/workflows/ci.yml | 4 ++++ test/__init__.py | 0 test/test_util.py | 3 +++ 3 files changed, 7 insertions(+) create mode 100644 test/__init__.py create mode 100644 test/test_util.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8ed96d..4f9fca8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,10 @@ jobs: run: | conda list + - name: tests + run: | + python -m pytest test + link-check: runs-on: ubuntu-latest defaults: diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/test_util.py b/test/test_util.py new file mode 100644 index 0000000..1210010 --- /dev/null +++ b/test/test_util.py @@ -0,0 +1,3 @@ +import pytest + + From a5934af13ded4f2286af1a5a2384baab5b9ce401 Mon Sep 17 00:00:00 2001 From: Katelyn FitzGerald <7872563+kafitzgerald@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:00:15 -0600 Subject: [PATCH 3/6] a bit more testing setup --- .github/workflows/ci.yml | 2 +- setup.cfg | 5 ++++- {test => tests}/__init__.py | 0 {test => tests}/test_util.py | 0 4 files changed, 5 insertions(+), 2 deletions(-) rename {test => tests}/__init__.py (100%) rename {test => tests}/test_util.py (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f9fca8..831ee41 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: - name: tests run: | - python -m pytest test + python -m pytest link-check: runs-on: ubuntu-latest diff --git a/setup.cfg b/setup.cfg index 5c5e6a1..9711735 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,6 +43,9 @@ install_requires = setuptools scikit-learn metpy +tests_require = + pytest + pytest-mpl [options.packages.find] where = src @@ -64,7 +67,7 @@ docs = [tool:pytest] python_files = test_*.py -testpaths = test +testpaths = tests [aliases] test = pytest diff --git a/test/__init__.py b/tests/__init__.py similarity index 100% rename from test/__init__.py rename to tests/__init__.py diff --git a/test/test_util.py b/tests/test_util.py similarity index 100% rename from test/test_util.py rename to tests/test_util.py From c153445756c63dc4f0bffdd0adaba827f070862b Mon Sep 17 00:00:00 2001 From: Katelyn FitzGerald <7872563+kafitzgerald@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:06:23 -0600 Subject: [PATCH 4/6] add to release notes --- docs/release-notes.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release-notes.rst b/docs/release-notes.rst index c24b640..a57ce02 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -12,6 +12,10 @@ Internal Changes ^^^^^^^^^^^^^^^^ * Remove M1 workaround for CI and tokens that are no longer needed by `Katelyn FitzGerald`_ in (:pr:`232`) +Testing +^^^^^^^ +* Add basic testing infrastructure by `Katelyn FitzGerald`_ and `Julia Kent`_ in (:pr:`233`) + v2024.03.0 (March 26, 2024) --------------------------- From f75859dd953142c35d25d4041e25fa3773864268 Mon Sep 17 00:00:00 2001 From: Katelyn FitzGerald <7872563+kafitzgerald@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:13:36 -0600 Subject: [PATCH 5/6] formatting --- tests/test_util.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_util.py b/tests/test_util.py index 1210010..5871ed8 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,3 +1 @@ import pytest - - From 02e09e2daaf98afadc9c27b4e1e31ec94c195e6e Mon Sep 17 00:00:00 2001 From: Katelyn FitzGerald <7872563+kafitzgerald@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:45:05 -0600 Subject: [PATCH 6/6] add a quick test --- tests/test_util.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_util.py b/tests/test_util.py index 5871ed8..8084bec 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1 +1,13 @@ import pytest +import matplotlib as mpl + +from geocat.viz.util import truncate_colormap + + +def test_truncate_colormap(): + cmap = mpl.colormaps['terrain'] + truncated_cmap = truncate_colormap(cmap, 0.1, 0.9) + + assert isinstance(truncated_cmap, mpl.colors.LinearSegmentedColormap) + assert truncated_cmap(0.0) == cmap(0.1) + assert truncated_cmap(1.0) == cmap(0.9)