Skip to content

Commit

Permalink
Merge branch 'main' into allow_negative_freq
Browse files Browse the repository at this point in the history
  • Loading branch information
mathause committed Feb 1, 2024
2 parents f30f04c + 4de10d4 commit d29ed0a
Show file tree
Hide file tree
Showing 73 changed files with 9,846 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci-additional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ jobs:
#
# If dependencies emit warnings we can't do anything about, add ignores to
# `xarray/tests/__init__.py`.
python -m pytest --doctest-modules xarray --ignore xarray/tests -Werror
# [MHS, 01/25/2024] Skip datatree_ documentation remove after #8572
python -m pytest --doctest-modules xarray --ignore xarray/tests --ignore xarray/datatree_ -Werror
mypy:
name: Mypy
Expand Down
7 changes: 1 addition & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# https://pre-commit.com/
ci:
autoupdate_schedule: monthly
exclude: 'xarray/datatree_.*'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
Expand All @@ -10,12 +11,6 @@ repos:
- id: check-yaml
- id: debug-statements
- id: mixed-line-ending
- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports
name: absolufy-imports
files: ^xarray/
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.1.9'
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prune xarray/datatree_*
2 changes: 1 addition & 1 deletion ci/requirements/all-but-dask.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies:
- pint>=0.22
- pip
- pydap
- pytest==7.4.*
- pytest
- pytest-cov
- pytest-env
- pytest-xdist
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/bare-minimum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies:
- python=3.9
- coveralls
- pip
- pytest==7.4.*
- pytest
- pytest-cov
- pytest-env
- pytest-xdist
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/environment-3.12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies:
- pooch
- pre-commit
- pydap
- pytest==7.4.*
- pytest
- pytest-cov
- pytest-env
- pytest-xdist
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/environment-windows-3.12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies:
- pip
- pre-commit
- pydap
- pytest==7.4.*
- pytest
- pytest-cov
- pytest-env
- pytest-xdist
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/environment-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies:
- pip
- pre-commit
- pydap
- pytest==7.4.*
- pytest
- pytest-cov
- pytest-env
- pytest-xdist
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies:
- pre-commit
- pyarrow # pandas makes a deprecation warning without this, breaking doctests
- pydap
- pytest==7.4.*
- pytest
- pytest-cov
- pytest-env
- pytest-xdist
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/min-all-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dependencies:
- pint=0.22
- pip
- pydap=3.3
- pytest==7.4.*
- pytest
- pytest-cov
- pytest-env
- pytest-xdist
Expand Down
2 changes: 1 addition & 1 deletion doc/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Creating a development environment
----------------------------------

To test out code changes locally, you'll need to build *xarray* from source, which requires you to
`create a local development environment <https://docs.xarray.dev/en/stable/contributing.html#creating-a-development-environment>`_.
`create a local development environment <https://docs.xarray.dev/en/stable/contributing.html#contributing-dev-env>`_.

Update the ``main`` branch
--------------------------
Expand Down
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ Deprecations
Bug fixes
~~~~~~~~~

- Fixed a regression that prevented multi-index level coordinates being
serialized after resetting or dropping the multi-index (:issue:`8628`, :pull:`8672`).
By `Benoit Bovy <https://github.com/benbovy>`_.
- Fix bug with broadcasting when wrapping array API-compliant classes. (:issue:`8665`, :pull:`8669`)
By `Tom Nicholas <https://github.com/TomNicholas>`_.
- Ensure :py:meth:`DataArray.unstack` works when wrapping array API-compliant classes. (:issue:`8666`, :pull:`8668`)
Expand Down
17 changes: 16 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ exclude_lines = ["pragma: no cover", "if TYPE_CHECKING"]

[tool.mypy]
enable_error_code = "redundant-self"
exclude = 'xarray/util/generate_.*\.py'
exclude = [
'xarray/util/generate_.*\.py',
'xarray/datatree_/.*\.py',
]
files = "xarray"
show_error_codes = true
show_error_context = true
Expand Down Expand Up @@ -242,8 +245,15 @@ extend-exclude = [
"doc",
"_typed_ops.pyi",
]
extend-safe-fixes = [
"TID252", # absolute imports
]
target-version = "py39"

[tool.ruff.per-file-ignores]
# don't enforce absolute imports
"asv_bench/**" = ["TID252"]

[tool.ruff.lint]
# E402: module level import not at top of file
# E501: line too long - let black worry about that
Expand All @@ -257,13 +267,18 @@ select = [
"F", # Pyflakes
"E", # Pycodestyle
"W",
"TID", # flake8-tidy-imports (absolute imports)
"I", # isort
"UP", # Pyupgrade
]

[tool.ruff.lint.isort]
known-first-party = ["xarray"]

[tool.ruff.lint.flake8-tidy-imports]
# Disallow all relative imports.
ban-relative-imports = "all"

[tool.pytest.ini_options]
addopts = ["--strict-config", "--strict-markers"]
filterwarnings = [
Expand Down
18 changes: 11 additions & 7 deletions xarray/conventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
)
from xarray.core.pycompat import is_duck_dask_array
from xarray.core.utils import emit_user_level_warning
from xarray.core.variable import Variable
from xarray.core.variable import IndexVariable, Variable

CF_RELATED_DATA = (
"bounds",
Expand Down Expand Up @@ -84,13 +84,17 @@ def _infer_dtype(array, name=None):


def ensure_not_multiindex(var: Variable, name: T_Name = None) -> None:
# only the pandas multi-index dimension coordinate cannot be serialized (tuple values)
if isinstance(var._data, indexing.PandasMultiIndexingAdapter):
raise NotImplementedError(
f"variable {name!r} is a MultiIndex, which cannot yet be "
"serialized. Instead, either use reset_index() "
"to convert MultiIndex levels into coordinate variables instead "
"or use https://cf-xarray.readthedocs.io/en/latest/coding.html."
)
if name is None and isinstance(var, IndexVariable):
name = var.name
if var.dims == (name,):
raise NotImplementedError(
f"variable {name!r} is a MultiIndex, which cannot yet be "
"serialized. Instead, either use reset_index() "
"to convert MultiIndex levels into coordinate variables instead "
"or use https://cf-xarray.readthedocs.io/en/latest/coding.html."
)


def _copy_with_dtype(data, dtype: np.typing.DTypeLike):
Expand Down
15 changes: 15 additions & 0 deletions xarray/datatree_/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[flake8]
ignore =
# whitespace before ':' - doesn't work well with black
E203
# module level import not at top of file
E402
# line too long - let black worry about that
E501
# do not assign a lambda expression, use a def
E731
# line break before binary operator
W503
exclude=
.eggs
doc
4 changes: 4 additions & 0 deletions xarray/datatree_/.git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true)$
ref-names: $Format:%D$
11 changes: 11 additions & 0 deletions xarray/datatree_/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "daily"
7 changes: 7 additions & 0 deletions xarray/datatree_/.github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- Feel free to remove check-list items aren't relevant to your change -->

- [ ] Closes #xxxx
- [ ] Tests added
- [ ] Passes `pre-commit run --all-files`
- [ ] New functions/methods are listed in `api.rst`
- [ ] Changes are summarized in `docs/source/whats-new.rst`
97 changes: 97 additions & 0 deletions xarray/datatree_/.github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 0 * * *"

jobs:

test:
name: ${{ matrix.python-version }}-build
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4

- name: Create conda environment
uses: mamba-org/provision-with-micromamba@main
with:
cache-downloads: true
micromamba-version: 'latest'
environment-file: ci/environment.yml
extra-specs: |
python=${{ matrix.python-version }}
- name: Conda info
run: conda info

- name: Install datatree
run: |
python -m pip install -e . --no-deps --force-reinstall
- name: Conda list
run: conda list

- name: Running Tests
run: |
python -m pytest --cov=./ --cov-report=xml --verbose
- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v3.1.4
with:
file: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false


test-upstream:
name: ${{ matrix.python-version }}-dev-build
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4

- name: Create conda environment
uses: mamba-org/provision-with-micromamba@main
with:
cache-downloads: true
micromamba-version: 'latest'
environment-file: ci/environment.yml
extra-specs: |
python=${{ matrix.python-version }}
- name: Conda info
run: conda info

- name: Install dev reqs
run: |
python -m pip install --no-deps --upgrade \
git+https://github.com/pydata/xarray \
git+https://github.com/Unidata/netcdf4-python
python -m pip install -e . --no-deps --force-reinstall
- name: Conda list
run: conda list

- name: Running Tests
run: |
python -m pytest --verbose
Loading

0 comments on commit d29ed0a

Please sign in to comment.