Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package health #407

Merged
merged 25 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9b1ed6e
Update __init__.py
aaronspring Oct 29, 2023
20a1a9c
Update readthedocs.yml
aaronspring Oct 29, 2023
398157c
Update setup.cfg
aaronspring Oct 29, 2023
c571f84
Update setup.py
aaronspring Oct 29, 2023
1a705e8
Update dev.yml
aaronspring Oct 29, 2023
be2b43c
Update doc.yml
aaronspring Oct 29, 2023
54fad8e
Update xskillscore_installs.yml
aaronspring Oct 29, 2023
755d6ba
Update xskillscore_testing.yml
aaronspring Oct 29, 2023
34bebdd
Update xskillscore_testing.yml
aaronspring Oct 29, 2023
8ce0ed6
Update upstream-dev-ci.yml
aaronspring Oct 29, 2023
3c37e61
Update __init__.py
aaronspring Oct 29, 2023
162b5e6
Update test_probabilistic.py normalize=False drop
aaronspring Oct 29, 2023
841a391
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2023
547921a
Update test_resampling.py
aaronspring Oct 29, 2023
e04f559
Update xskillscore_testing.yml
aaronspring Oct 29, 2023
36c366a
Update upstream-dev-ci.yml [test-upstream]
aaronspring Oct 29, 2023
3b873a1
rework .pre-commit-config.yaml
aaronspring Oct 29, 2023
3a47e1c
Update .pre-commit-config.yaml
aaronspring Oct 29, 2023
af3948c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2023
95a08b7
Update contingency.py
aaronspring Oct 29, 2023
c4b4246
merge (#408)
aaronspring Oct 29, 2023
701e93b
Update probabilistic.py
aaronspring Oct 29, 2023
fdd5dcc
Update .pre-commit-config.yaml
aaronspring Oct 29, 2023
497bc71
Merge branch 'main' into package_health
aaronspring Oct 29, 2023
33ca971
Update CHANGELOG.rst [test-upstream]
aaronspring Oct 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/upstream-dev-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
python-version: ["3.11"]
outputs:
artifacts_availability: ${{ steps.status.outputs.ARTIFACTS_AVAILABLE }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/xskillscore_installs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/xskillscore_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v2
- name: Set up conda
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
channels: conda-forge
mamba-version: "*"
activate-environment: xskillscore-minimum-tests
python-version: 3.8
python-version: 3.9
- name: Set up conda environment
run: |
mamba env update -f ci/minimum-tests.yml
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
channels: conda-forge
mamba-version: "*"
activate-environment: xskillscore-docs-notebooks
python-version: 3.8
python-version: 3.9
- name: Set up conda environment
run: |
mamba env update -f ci/docs_notebooks.yml
Expand Down
96 changes: 67 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,85 @@
default_language_version:
python: python3

ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: quarterly
skip: []
submodules: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: no-commit-to-branch
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-docstring-first
- id: end-of-file-fixer
- id: check-json
exclude: 'asv.conf.json'
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
args: [ '--allow-multiple-documents' ]
- id: debug-statements
- id: end-of-file-fixer
- id: no-commit-to-branch
- id: pretty-format-json
args: [ '--autofix', '--no-ensure-ascii', '--no-sort-keys' ]
exclude: '.ipynb|asv.conf.json'
- id: trailing-whitespace

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.10.1
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8

- repo: https://github.com/PyCQA/doc8
rev: v1.0.0
hooks:
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
hooks:
- id: blackdoc
additional_dependencies: [ 'black==23.10.1' ]

- repo: https://github.com/PyCQA/doc8
rev: v1.0.0
hooks:
- id: doc8
args: ["--max-line-length", "100",
"--allow-long-titles",
"--ignore-path", "docs/source/api/"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
hooks:
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
hooks:
- id: mypy
exclude: "asv_bench"
args:
- --ignore-missing-imports
- --follow-imports=silent
- --install-types
- --non-interactive
exclude: 'asv_bench'
additional_dependencies: [
# Type stubs
types-python-dateutil,
types-pkg_resources,
types-PyYAML,
types-pytz,
typing-extensions==3.10.0.0,
# Dependencies that are typed
numpy,
]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.0
hooks:
- id: check-github-workflows
- id: check-readthedocs
1 change: 0 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Changelog History
=================


xskillscore v0.0.25 (2021-xx-xx)
--------------------------------

Expand Down
1 change: 0 additions & 1 deletion asv_bench/benchmarks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class Generate:
repeat = (2, 5, 20)

def make_ds(self, nmember, nx, ny, chunks=None):

# ds
self.ds = xr.Dataset()
self.nmember = nmember
Expand Down
2 changes: 1 addition & 1 deletion ci/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: xskillscore-docs
channels:
- conda-forge
dependencies:
- python=3.8
- python >=3.9
- bottleneck
- doc8
- ipykernel
Expand Down
9 changes: 7 additions & 2 deletions readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: 2

build:
os: "ubuntu-20.04"
os: "ubuntu-22.04"
tools:
python: "mambaforge-4.10"
python: "mambaforge-22.9"

conda:
environment: ci/doc.yml
Expand All @@ -12,3 +12,8 @@ sphinx:
fail_on_warning: false

formats: []

python:
install:
- method: pip
path: .
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[tool:pytest]
python_files = test_*.py
testpaths = xskillscore/tests
addopts =
--color=yes
--verbose
markers =
slow: marks tests as slow (deselect with '-m "not slow"')

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
URL = "https://github.com/xarray-contrib/xskillscore"
with open("requirements.txt") as f:
INSTALL_REQUIRES = f.read().strip().split("\n")
PYTHON_REQUIRE = ">=3.8"
PYTHON_REQUIRE = ">=3.9"

EXTRAS_REQUIRE = {
"accel": ["numba>=0.52", "bottleneck"],
Expand All @@ -24,7 +24,7 @@
"matplotlib",
"pytest-cov",
"pytest-xdist",
"pytest-lazyfixures",
"pytest-lazy-fixures",
"pre-commit",
]
EXTRAS_REQUIRE["docs"] = EXTRAS_REQUIRE["complete"] + [
Expand Down
6 changes: 3 additions & 3 deletions xskillscore/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# flake8: noqa
from pkg_resources import DistributionNotFound, get_distribution # type: ignore
from importlib.metadata import PackageNotFoundError, version as _get_version

from .core import resampling
from .core.accessor import XSkillScoreAccessor
Expand Down Expand Up @@ -40,7 +40,7 @@
from .versioning.print_versions import show_versions

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
__version__ = _get_version("xskillscore")
except PackageNotFoundError: # pragma: no cover
# package is not installed
pass
27 changes: 11 additions & 16 deletions xskillscore/core/comparative.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,17 @@ def sign_test(

Examples
--------
>>> f1 = xr.DataArray(np.random.normal(size=(30)),
... coords=[('time', np.arange(30))])
>>> f1 = xr.DataArray(np.random.normal(size=(30)), coords=[("time", np.arange(30))])
>>> f2 = f1 + 2
>>> o = xr.DataArray(np.random.normal(size=(30)),
... coords=[('time', np.arange(30))])
>>> o = xr.DataArray(np.random.normal(size=(30)), coords=[("time", np.arange(30))])
>>> significantly_different, walk, confidence = xs.sign_test(
... f1, f2, o, time_dim='time', metric='mae', orientation='negative'
... f1, f2, o, time_dim="time", metric="mae", orientation="negative"
... )
>>> walk.plot() # doctest: +ELLIPSIS
>>> walk.plot() # doctest: +ELLIPSIS
[<matplotlib.lines.Line2D object at 0x...>]
>>> confidence.plot(color='gray') # doctest: +ELLIPSIS
>>> confidence.plot(color="gray") # doctest: +ELLIPSIS
[<matplotlib.lines.Line2D object at 0x...>]
>>> (-1 * confidence).plot(color='gray') # doctest: +ELLIPSIS
>>> (-1 * confidence).plot(color="gray") # doctest: +ELLIPSIS
[<matplotlib.lines.Line2D object at 0x...>]
>>> walk
<xarray.DataArray (time: 30)>
Expand Down Expand Up @@ -268,14 +266,11 @@ def halfwidth_ci_test(

Examples
--------
>>> f1 = xr.DataArray(np.random.normal(size=(30)),
... coords=[('time', np.arange(30))])
>>> f2 = xr.DataArray(np.random.normal(size=(30)),
... coords=[('time', np.arange(30))])
>>> o = xr.DataArray(np.random.normal(size=(30)),
... coords=[('time', np.arange(30))])
>>> f1 = xr.DataArray(np.random.normal(size=(30)), coords=[("time", np.arange(30))])
>>> f2 = xr.DataArray(np.random.normal(size=(30)), coords=[("time", np.arange(30))])
>>> o = xr.DataArray(np.random.normal(size=(30)), coords=[("time", np.arange(30))])
>>> significantly_different, diff, hwci = xs.halfwidth_ci_test(
... f1, f2, o, "mae", time_dim='time', dim=[], alpha=0.05
... f1, f2, o, "mae", time_dim="time", dim=[], alpha=0.05
... )
>>> significantly_different
<xarray.DataArray ()>
Expand All @@ -290,7 +285,7 @@ def halfwidth_ci_test(
>>> # confidence interval, therefore not significant at level alpha=0.05
>>> # now comparing against an offset f2, the difference in MAE is significant
>>> significantly_different, diff, hwci = xs.halfwidth_ci_test(
... f1, f2 + 2., o, "mae", time_dim='time', dim=[], alpha=0.05
... f1, f2 + 2.0, o, "mae", time_dim="time", dim=[], alpha=0.05
... )
>>> significantly_different
<xarray.DataArray ()>
Expand Down
14 changes: 8 additions & 6 deletions xskillscore/core/contingency.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,17 @@ class Contingency:

Examples
--------
>>> da = xr.DataArray(np.random.normal(size=(3, 3)),
... coords=[("x", np.arange(3)), ("y", np.arange(3))])
>>> da = xr.DataArray(
... np.random.normal(size=(3, 3)),
... coords=[("x", np.arange(3)), ("y", np.arange(3))],
... )
>>> o = xr.Dataset({"var1": da, "var2": da})
>>> f = o * 1.1
>>> o_category_edges = np.linspace(-2, 2, 5)
>>> f_category_edges = np.linspace(-3, 3, 5)
>>> xs.Contingency(o, f,
... o_category_edges, f_category_edges,
... dim=['x', 'y']) # doctest: +SKIP
>>> xs.Contingency(
... o, f, o_category_edges, f_category_edges, dim=["x", "y"]
... ) # doctest: +SKIP
<xskillscore.Contingency>
Dimensions: (forecasts_category: 4, observations_category: 4)
Coordinates:
Expand Down Expand Up @@ -774,7 +776,7 @@ def _gerrity_s(table):
a = (1.0 - p_sum) / p_sum
k = a.shape[-1]
s = np.zeros(table.shape, dtype=float)
for (i, j) in np.ndindex(*s.shape[-2:]):
for i, j in np.ndindex(*s.shape[-2:]):
if i == j:
s[..., i, j] = (
1.0
Expand Down
Loading
Loading