Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [main]
pull_request:
branches: ['*']
branches: ["*"]

defaults:
run:
Expand All @@ -20,7 +20,6 @@ jobs:
- name: Setup Conda Environment
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
environment-file: ci/requirements-docs.yml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [main]
pull_request:
branches: ['*']
branches: ["*"]

jobs:
checks:
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [main]
pull_request:
branches: ['*']
branches: ["*"]
workflow_dispatch: # allows you to trigger manually

# When this workflow is queued, automatically cancel any previous running
Expand All @@ -19,41 +19,42 @@ defaults:

jobs:
build:
name: ${{ matrix.os }} ${{ matrix.python-version }} ${{ matrix.requirements }}
name:
${{ matrix.os }} ${{ matrix.python-version }} ${{ matrix.requirements }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
requirements: [latest]
include:
# Test on macos and windows (first and last version of python only)
- os: macos
python-version: '3.8'
python-version: "3.8"
requirements: latest
- os: macos
python-version: '3.12'
python-version: "3.12"
requirements: latest
- os: windows
python-version: '3.8'
python-version: "3.8"
requirements: latest
- os: windows
python-version: '3.12'
python-version: "3.12"
requirements: latest
# Test on minimal requirements
- os: ubuntu
python-version: '3.8'
python-version: "3.8"
requirements: minimal
- os: macos
python-version: '3.8'
python-version: "3.8"
requirements: minimal
- os: windows
python-version: '3.8'
python-version: "3.8"
requirements: minimal
# Test on nightly builds of requirements
- os: ubuntu
python-version: '3.12'
python-version: "3.12"
requirements: upstream

steps:
Expand All @@ -65,7 +66,6 @@ jobs:
- name: Setup Conda Environment
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
python-version: ${{ matrix.python-version }}
Expand All @@ -85,7 +85,7 @@ jobs:
run: |
# Pick up https://github.com/mamba-org/mamba/pull/2903
mamba install -n base 'mamba>=1.5.2'

mamba uninstall --force numpy pandas scipy pyarrow
python -m pip install --no-deps --pre --prefer-binary \
--extra-index-url https://pypi.fury.io/arrow-nightlies/ \
Expand Down
61 changes: 52 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,66 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: name-tests-test
args: ["--pytest-test-first"]
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.4.2
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
args: [--prose-wrap=always]

- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports
name: absolufy-imports
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
language_version: python3
args:
- --target-version=py38

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
rev: v0.8.4
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
- tomli

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.10.0.1"
hooks:
- id: shellcheck

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.23
hooks:
- id: validate-pyproject
additional_dependencies: ["validate-pyproject-schema-store[all]"]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.30.0"
hooks:
- id: check-dependabot
- id: check-github-workflows

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.14.0
hooks:
- id: mypy
additional_dependencies:
Expand Down
6 changes: 3 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ conda:
environment: ci/requirements-docs.yml

python:
install:
- method: pip
path: .
install:
- method: pip
path: .

sphinx:
builder: html
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
xarray_extras
=============
# xarray_extras

[![doc-badge](https://github.com/crusaderky/xarray_extras/actions/workflows/docs.yml/badge.svg)](https://github.com/crusaderky/xarray_extras/actions)
[![pre-commit-badge](https://github.com/crusaderky/xarray_extras/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/crusaderky/xarray_extras/actions)
[![pytest-badge](https://github.com/crusaderky/xarray_extras/actions/workflows/pytest.yml/badge.svg)](https://github.com/crusaderky/xarray_extras/actions)
Expand Down
8 changes: 4 additions & 4 deletions doc/_static/style.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
@import url("theme.css");

.wy-side-nav-search>a img.logo,
.wy-side-nav-search .wy-dropdown>a img.logo {
width: 12rem
.wy-side-nav-search > a img.logo,
.wy-side-nav-search .wy-dropdown > a img.logo {
width: 12rem;
}

.wy-side-nav-search {
background-color: #eee;
}

.wy-side-nav-search>div.version {
.wy-side-nav-search > div.version {
display: none;
}

Expand Down
4 changes: 2 additions & 2 deletions doc/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{% extends "!layout.html" %}
{% set css_files = css_files + ["_static/style.css"] %}
{% extends "!layout.html" %} {% set css_files = css_files +
["_static/style.css"] %}
4 changes: 2 additions & 2 deletions doc/api/sort.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sort

An example that uses all of the above functions is *source attribution*.
Given a generic function :math:`y = f(x_{0}, x_{1}, ..., x_{i})`, which is
embarassingly parallel along a given dimension, one wants to find:
embarrassingly parallel along a given dimension, one wants to find:

- the top k elements of y along the dimension
- the elements of all x's that generated the top k elements of y
Expand All @@ -20,7 +20,7 @@ embarassingly parallel along a given dimension, one wants to find:
>>> from xarray_extras.sort import *
>>> x = DataArray([[5, 3, 2, 8, 1],
>>> [0, 7, 1, 3, 2]], dims=['x', 's'])
>>> y = x.sum('x') # y = f(x), embarassingly parallel among dimension 's'
>>> y = x.sum('x') # y = f(x), embarrassingly parallel among dimension 's'
>>> y
<xarray.DataArray (s: 5)>
array([ 5, 10, 3, 11, 3])
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

# General information about the project.
project = "xarray_extras"
copyright = "2018-%s, xarray_extras Developers" % datetime.datetime.now().year
copyright = f"2018-{datetime.datetime.now().year}, xarray_extras Developers"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ License

xarray-extras is available under the open source `Apache License`__.

__ http://www.apache.org/licenses/LICENSE-2.0.html
__ http://www.apache.org/licenses/LICENSE-2.0.html
55 changes: 42 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/crusaderky/xarray_extras"
"Bug Tracker" = "https://github.com/crusaderky/xarray_extras/issues"
Changelog = "https://xarray-extras.readthedocs.io/en/latest/whats-new.html"

[project.readme]
text = "Advanced / experimental algorithms for xarray"
content-type = "text/x-rst"

[tool.setuptools]
packages = ["xarray_extras"]
zip-safe = false # https://mypy.readthedocs.io/en/latest/installed_packages.html
zip-safe = false # https://mypy.readthedocs.io/en/latest/installed_packages.html
include-package-data = true

[tool.setuptools_scm]
Expand Down Expand Up @@ -72,6 +74,8 @@ filterwarnings = [
# FIXME these need to be looked at
'ignore:.*will no longer be implicitly promoted:FutureWarning',
'ignore:.*updating coordinate .* with a PandasMultiIndex would leave the multi-index level coordinates .* in an inconsistent state:FutureWarning',
# xarray vs. pandas upstream
'ignore:Converting non-nanosecond precision datetime:UserWarning',
]

[tool.coverage.report]
Expand All @@ -88,27 +92,52 @@ exclude_lines = [
'@(numba\.)?guvectorize',
]

[tool.codespell]
ignore-words-list = ["ND"]

[tool.ruff]
builtins = ["ellipsis"]
exclude = [".eggs"]
target-version = "py38"

[tool.ruff.lint]
ignore = [
"E402", # module level import not at top of file
"SIM108", # use ternary operator instead of if-else block
"EM101", # Exception must not use a string literal, assign to variable first
"EM102", # Exception must not use an f-string literal, assign to variable first
"N802", # Function name should be lowercase
"N803", # Argument name should be lowercase
"N806", # Variable should be lowercase
"N816", # Variable in global scope should not be mixedCase
"PD901", # Avoid using the generic variable name `df` for DataFrames
"PT006", # Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple`
"PLC0414", # Import alias does not rename original package
"PLR0912", # Too many branches
"PLR0913", # Too many arguments in function definition
"PLR2004", # Magic value used in comparison, consider replacing `123` with a constant variable
"PLW2901", # for loop variable overwritten by assignment target
"SIM108", # Use ternary operator instead of if-else block
]
select = [
"F", # Pyflakes
"YTT", # flake8-2020
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"ISC", # flake8-implicit-str-concat
"EM", # flake8-errmsg
"EXE", # flake8-executable
"ICN", # flake8-import-conventions
"G", # flake8-logging-format
"PIE", # flake8-pie
"PT", # flake8-pytest-style
"RET", # flake8-return
"SIM", # flake8-simplify
"E", # Pycodestyle
"W", # Pycodestyle
"ARG", # flake8-unused-arguments
"I", # isort
"NPY", # NumPy specific rules
"N", # pep8-naming
"UP", # Pyupgrade
"E", # Pycodestyle
"W", # Pycodestyle
"PGH", # pygrep-hooks
"F", # Pyflakes
"PL", # pylint
"UP", # pyupgrade
"RUF", # unused-noqa
"EXE001", # Shebang is present but file is not executable
]
Expand All @@ -117,9 +146,9 @@ select = [
known-first-party = ["xarray_extras"]

[tool.mypy]
allow_incomplete_defs = false
allow_untyped_decorators = false
allow_untyped_defs = false
disallow_incomplete_defs = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
ignore_missing_imports = true
no_implicit_optional = true
show_error_codes = true
Expand All @@ -129,4 +158,4 @@ warn_unreachable = true

[[tool.mypy.overrides]]
module = ["*.tests.*"]
allow_untyped_defs = true
disallow_untyped_defs = false
Loading
Loading