From 041c4002af8f34d438af982a4209ca97d5e60f8d Mon Sep 17 00:00:00 2001 From: Martin Vonk <66305055+martinvonk@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:52:25 +0100 Subject: [PATCH 1/5] Update tests.yml add ruff --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0742e29..95b0c5d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -35,7 +35,7 @@ jobs: python: "3.9" os: ubuntu-latest toxenv: format - - name: Linting with flake8 + - name: Linting with flake8 + ruff python: "3.9" os: ubuntu-latest toxenv: lint From 8ca3d378ec94eb48c5ce41d8accaed15809a0729 Mon Sep 17 00:00:00 2001 From: Martin Vonk <66305055+martinvonk@users.noreply.github.com> Date: Wed, 15 Mar 2023 10:24:09 +0100 Subject: [PATCH 2/5] Update pyproject.toml add "Typing :: Typed", --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index cdf611c..6ba0519 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ classifiers = [ 'Intended Audience :: Science/Research', "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", + "Typing :: Typed", ] [project.urls] From 42301041e677e98e5120f44e5c73e5d0fa1555c1 Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Wed, 29 Mar 2023 10:05:23 +0200 Subject: [PATCH 3/5] move fixtures to conftest.py --- doc/_static/make_logo.py | 2 +- tests/{fixtures.py => conftest.py} | 0 tests/test_dist_utils.py | 6 +++--- tests/test_plots.py | 2 -- tests/test_si.py | 2 -- tests/test_validate.py | 3 ++- 6 files changed, 6 insertions(+), 9 deletions(-) rename tests/{fixtures.py => conftest.py} (100%) diff --git a/doc/_static/make_logo.py b/doc/_static/make_logo.py index 79212a8..da20ac1 100644 --- a/doc/_static/make_logo.py +++ b/doc/_static/make_logo.py @@ -1,5 +1,5 @@ import matplotlib.pyplot as plt -from numpy import meshgrid, linspace +from numpy import linspace, meshgrid fig, ax = plt.subplots(figsize=(27, 9)) x, y = meshgrid((0, 100), linspace(0, 0.1, 1000)) diff --git a/tests/fixtures.py b/tests/conftest.py similarity index 100% rename from tests/fixtures.py rename to tests/conftest.py diff --git a/tests/test_dist_utils.py b/tests/test_dist_utils.py index 2e98317..b318086 100644 --- a/tests/test_dist_utils.py +++ b/tests/test_dist_utils.py @@ -1,7 +1,7 @@ -from spei.utils import dists_test +from pandas import Series -from .fixtures import head +from spei.utils import dists_test -def test_dists_test(head) -> None: +def test_dists_test(head: Series) -> None: _ = dists_test(head) diff --git a/tests/test_plots.py b/tests/test_plots.py index a817e10..bbe24f9 100644 --- a/tests/test_plots.py +++ b/tests/test_plots.py @@ -5,8 +5,6 @@ from spei.plot import dist, monthly_density from spei.plot import si as plot_si -from .fixtures import prec, si - mpl.use("Agg") # prevent _tkinter.TclError: Can't find a usable tk.tcl error diff --git a/tests/test_si.py b/tests/test_si.py index b9d9333..e4a20f9 100644 --- a/tests/test_si.py +++ b/tests/test_si.py @@ -2,8 +2,6 @@ from spei import sgi, spei, spi, ssfi -from .fixtures import evap, head, prec - def test_spi(prec: Series) -> None: spi(prec.rolling("30D", min_periods=30).sum().dropna(), prob_zero=True) diff --git a/tests/test_validate.py b/tests/test_validate.py index 1c7432e..537466d 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -1,5 +1,6 @@ -import pytest import logging + +import pytest from pandas import DataFrame, Series, to_datetime from spei.utils import validate_index, validate_series From e77f422cca98651444e8baeff0505e2bd2d4bc4a Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Wed, 3 May 2023 10:27:17 +0200 Subject: [PATCH 4/5] add show_version method and some tests --- src/spei/__init__.py | 2 +- src/spei/_version.py | 15 +++++++++++++++ tests/test_version.py | 10 ++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/test_version.py diff --git a/src/spei/__init__.py b/src/spei/__init__.py index 2c59221..1b4672e 100644 --- a/src/spei/__init__.py +++ b/src/spei/__init__.py @@ -1,4 +1,4 @@ # flake8: noqa from . import plot, si, utils -from ._version import __version__ +from ._version import __version__, show_versions from .si import sgi, spei, spi, ssfi diff --git a/src/spei/_version.py b/src/spei/_version.py index e19434e..477ad73 100644 --- a/src/spei/_version.py +++ b/src/spei/_version.py @@ -1 +1,16 @@ +from importlib import metadata +from platform import python_version + __version__ = "0.3.3" + + +def show_versions() -> None: + msg = f"Versions\npython: {python_version()}\nspei: {__version__}\n" + + requirements = metadata.requires("spei") + if requirements: + deps = [x for x in requirements if "extra" not in x] + for dep in deps: + msg += f"{dep}: {metadata.version(dep)}\n" + + print(msg) diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 0000000..0520036 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,10 @@ +import spei as si + + +def test_version() -> None: + assert isinstance(si.__version__, str) + assert si.__version__.count(".") == 2 + + +def test_show_versions(): + si.show_versions() From 0f3d8d715b5893e7906d14988169eebfe72d5a85 Mon Sep 17 00:00:00 2001 From: Martin Vonk Date: Wed, 3 May 2023 10:30:00 +0200 Subject: [PATCH 5/5] bump version to 0.3.4 --- src/spei/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spei/_version.py b/src/spei/_version.py index 477ad73..058111b 100644 --- a/src/spei/_version.py +++ b/src/spei/_version.py @@ -1,7 +1,7 @@ from importlib import metadata from platform import python_version -__version__ = "0.3.3" +__version__ = "0.3.4" def show_versions() -> None: