From b51cf558434986e436e3682fb74d32706c6b6177 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Jun 2025 22:09:47 +0200 Subject: [PATCH 1/9] Bump codecov/codecov-action from 5.4.2 to 5.4.3 (#299) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.2 to 5.4.3. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v5.4.2...v5.4.3) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-version: 5.4.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c81209e3..f3f718ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,7 +97,7 @@ jobs: python -m pytest --cov=pint_xarray --cov-report=xml - name: Upload code coverage to Codecov - uses: codecov/codecov-action@v5.4.2 + uses: codecov/codecov-action@v5.4.3 with: file: ./coverage.xml flags: unittests From 5720dd607ed83b75d71c1676ff89cd312e784f25 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Jun 2025 22:09:59 +0200 Subject: [PATCH 2/9] [pre-commit.ci] pre-commit autoupdate (#300) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.9 → v0.11.13](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.9...v0.11.13) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 98429224..7265ef09 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,7 @@ repos: additional_dependencies: ["black==25.1.0"] - id: blackdoc-autoupdate-black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.9 + rev: v0.11.13 hooks: - id: ruff args: [--fix] From 59e5d348e19c28fa84844048ea1028844faef28b Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Mon, 9 Jun 2025 23:36:17 +0200 Subject: [PATCH 3/9] release 0.5 (#301) * release 0.5 * [skip-ci] --- docs/whats-new.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/whats-new.rst b/docs/whats-new.rst index 4eca815f..bb0c87be 100644 --- a/docs/whats-new.rst +++ b/docs/whats-new.rst @@ -2,7 +2,7 @@ What's new ========== -0.5 (*unreleased*) +0.5 (09 Jun 2025) ------------------ - drop support for python 3.9 (:pull:`266`) By `Justus Magin `_. From b44dfeb083690fa1d7f7b34a63cf39e00b6a1a15 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Mon, 9 Jun 2025 23:39:08 +0200 Subject: [PATCH 4/9] new release section (#302) --- docs/whats-new.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/whats-new.rst b/docs/whats-new.rst index bb0c87be..fd3257aa 100644 --- a/docs/whats-new.rst +++ b/docs/whats-new.rst @@ -2,6 +2,10 @@ What's new ========== +0.5.1 (*unreleased*) +-------------------- + + 0.5 (09 Jun 2025) ------------------ - drop support for python 3.9 (:pull:`266`) From 9c25bddfa8fdbfe22203d7f9984a4d49fcbc1128 Mon Sep 17 00:00:00 2001 From: Bhavin Patel <15210802+bpatel2107@users.noreply.github.com> Date: Sat, 14 Jun 2025 11:03:58 +0100 Subject: [PATCH 5/9] Pass kwargs to sel (#304) * Pass kwargs to sel * Add test for sel with method=nearest * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * changelog * stylistical changes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Justus Magin --- docs/whats-new.rst | 3 ++- pint_xarray/index.py | 4 ++-- pint_xarray/tests/test_index.py | 36 +++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/docs/whats-new.rst b/docs/whats-new.rst index fd3257aa..83571b46 100644 --- a/docs/whats-new.rst +++ b/docs/whats-new.rst @@ -4,7 +4,8 @@ What's new ========== 0.5.1 (*unreleased*) -------------------- - +- Pass ``sel`` options to the wrapped array (:pull:`304`, :issue:`303`) + By `Bhavin Patel `_. 0.5 (09 Jun 2025) ------------------ diff --git a/pint_xarray/index.py b/pint_xarray/index.py index be158794..858b6f01 100644 --- a/pint_xarray/index.py +++ b/pint_xarray/index.py @@ -52,11 +52,11 @@ def stack(cls, variables, dim): def unstack(self): raise NotImplementedError() - def sel(self, labels): + def sel(self, labels, **options): converted_labels = conversion.convert_indexer_units(labels, self.units) stripped_labels = conversion.strip_indexer_units(converted_labels) - return self.index.sel(stripped_labels) + return self.index.sel(stripped_labels, **options) def isel(self, indexers): subset = self.index.isel(indexers) diff --git a/pint_xarray/tests/test_index.py b/pint_xarray/tests/test_index.py index 13f49064..48ec29f1 100644 --- a/pint_xarray/tests/test_index.py +++ b/pint_xarray/tests/test_index.py @@ -104,6 +104,42 @@ def test_sel(labels, expected): ) +@pytest.mark.parametrize( + ["labels", "expected"], + ( + ( + {"x": ureg.Quantity(1.1, "m")}, + IndexSelResult(dim_indexers={"x": np.array(0)}), + ), + ( + {"x": ureg.Quantity(3100, "mm")}, + IndexSelResult(dim_indexers={"x": np.array(2)}), + ), + ( + {"x": ureg.Quantity(0.0021, "km")}, + IndexSelResult(dim_indexers={"x": np.array(1)}), + ), + ( + {"x": ureg.Quantity([0.0021, 0.0041], "km")}, + IndexSelResult(dim_indexers={"x": np.array([1, 3])}), + ), + ), +) +def test_sel_nearest(labels, expected): + index = PintIndex( + index=PandasIndex(pd.Index([1, 2, 3, 4]), dim="x"), units={"x": ureg.Unit("m")} + ) + + actual = index.sel(labels, method="nearest") + + assert isinstance(actual, IndexSelResult) + assert actual.dim_indexers.keys() == expected.dim_indexers.keys() + assert all( + indexer_equal(actual.dim_indexers[k], expected.dim_indexers[k]) + for k in expected.dim_indexers.keys() + ) + + @pytest.mark.parametrize( "indexers", ({"y": 0}, {"y": [1, 2]}, {"y": slice(0, None, 2)}, {"y": xr.Variable("y", [1])}), From dd2a35ded041cab968eda031d43e87ec1b65f5e3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 21:18:25 +0200 Subject: [PATCH 6/9] [pre-commit.ci] pre-commit autoupdate (#305) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/keewis/blackdoc: v0.3.9 → v0.4.0](https://github.com/keewis/blackdoc/compare/v0.3.9...v0.4.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7265ef09..101b91ec 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,7 +31,7 @@ repos: hooks: - id: black-jupyter - repo: https://github.com/keewis/blackdoc - rev: v0.3.9 + rev: v0.4.0 hooks: - id: blackdoc additional_dependencies: ["black==25.1.0"] From 9bbae6c936f9891c4580a617c6f0f82409794cb3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 26 Jun 2025 14:57:51 +0200 Subject: [PATCH 7/9] [pre-commit.ci] pre-commit autoupdate (#306) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/rbubley/mirrors-prettier: v3.5.3 → v3.6.0](https://github.com/rbubley/mirrors-prettier/compare/v3.5.3...v3.6.0) - [github.com/astral-sh/ruff-pre-commit: v0.11.13 → v0.12.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.13...v0.12.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 101b91ec..60a73a24 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: end-of-file-fixer - id: check-docstring-first - repo: https://github.com/rbubley/mirrors-prettier - rev: v3.5.3 + rev: v3.6.0 hooks: - id: prettier args: ["--cache-location=.prettier_cache/cache"] @@ -37,7 +37,7 @@ repos: additional_dependencies: ["black==25.1.0"] - id: blackdoc-autoupdate-black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.13 + rev: v0.12.0 hooks: - id: ruff args: [--fix] From 5fac59956f6cef28452c39b049e7aca61c085a91 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 4 Jul 2025 09:09:16 +0200 Subject: [PATCH 8/9] [pre-commit.ci] pre-commit autoupdate (#307) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/rbubley/mirrors-prettier: v3.6.0 → v3.6.2](https://github.com/rbubley/mirrors-prettier/compare/v3.6.0...v3.6.2) - [github.com/keewis/blackdoc: v0.4.0 → v0.4.1](https://github.com/keewis/blackdoc/compare/v0.4.0...v0.4.1) - [github.com/astral-sh/ruff-pre-commit: v0.12.0 → v0.12.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.0...v0.12.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 60a73a24..3ab19056 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: end-of-file-fixer - id: check-docstring-first - repo: https://github.com/rbubley/mirrors-prettier - rev: v3.6.0 + rev: v3.6.2 hooks: - id: prettier args: ["--cache-location=.prettier_cache/cache"] @@ -31,13 +31,13 @@ repos: hooks: - id: black-jupyter - repo: https://github.com/keewis/blackdoc - rev: v0.4.0 + rev: v0.4.1 hooks: - id: blackdoc additional_dependencies: ["black==25.1.0"] - id: blackdoc-autoupdate-black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.12.0 + rev: v0.12.1 hooks: - id: ruff args: [--fix] From 22aaf7f1a59642a252ffe878d2a286c270021584 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 14 Jul 2025 18:51:46 +0000 Subject: [PATCH 9/9] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.12.1 → v0.12.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.12.1...v0.12.3) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3ab19056..3d8f4987 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,7 @@ repos: additional_dependencies: ["black==25.1.0"] - id: blackdoc-autoupdate-black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.12.1 + rev: v0.12.3 hooks: - id: ruff args: [--fix]