From 59a3b941e67bc8ac9f870982972cb0a133cc4c45 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Sat, 22 Jun 2024 23:47:56 +0200 Subject: [PATCH 1/7] run ci on python 3.12 --- .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 499f1a6e..f00d3ac9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12"] os: ["ubuntu-latest", "macos-latest", "windows-latest"] steps: From 38a67b4a71cc06abc2c7a332c3603de3348428e5 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Sat, 22 Jun 2024 23:49:17 +0200 Subject: [PATCH 2/7] temporarily pin to `numpy<3.9` Since `pint` currently does not have a release for 3.9 and `numpy>=2.0`. --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f00d3ac9..893cf445 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,6 +73,10 @@ jobs: - name: install dependencies run: | python -m pip install -r ci/requirements.txt + if [[ "${{matrix.python-version}}" == "3.9" ]]; then + # remove after the release + python -m pip install 'numpy<2.0' + fi - name: install pint-xarray run: python -m pip install --no-deps . From 40de4e74036614f194097d8c8b7cd73591230cc7 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Sat, 22 Jun 2024 23:56:13 +0200 Subject: [PATCH 3/7] configure CI to always use `bash` as the shell --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 893cf445..684a7c4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,9 @@ jobs: name: ${{ matrix.os }} py${{ matrix.python-version }} runs-on: ${{ matrix.os }} needs: detect-skip-ci-trigger + defaults: + run: + shell: bash -l {0} if: | always() From 8e361b2d58cc8c08c4800dfa7e8e877fc951d77e Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Sun, 23 Jun 2024 00:05:06 +0200 Subject: [PATCH 4/7] run the nightly CI on python 3.12 --- .github/workflows/nightly.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1858965f..f595ee36 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -8,6 +8,7 @@ on: branches: [ main ] schedule: - cron: "0 0 * * *" # Daily "At 00:00" UTC + workflow_dispatch: concurrency: @@ -52,7 +53,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.11"] + python-version: ["3.12"] outputs: artifacts_availability: ${{ steps.status.outputs.ARTIFACTS_AVAILABLE }} From 555055e34e832c0196deaf155198d3017257e5ae Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Sun, 23 Jun 2024 00:07:02 +0200 Subject: [PATCH 5/7] run the doctests on python 3.12 --- .github/workflows/ci-additional.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-additional.yml b/.github/workflows/ci-additional.yml index f4ba8973..e6b52c09 100644 --- a/.github/workflows/ci-additional.yml +++ b/.github/workflows/ci-additional.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.11"] + python-version: ["3.12"] steps: - name: checkout From c52510e694f6fc5de0de25f9794d30b556838360 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Sun, 23 Jun 2024 00:20:35 +0200 Subject: [PATCH 6/7] update the doctest output --- pint_xarray/accessors.py | 194 +++++++++++++++++++-------------------- 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/pint_xarray/accessors.py b/pint_xarray/accessors.py index 5cba6c8f..2ce576d0 100644 --- a/pint_xarray/accessors.py +++ b/pint_xarray/accessors.py @@ -300,10 +300,10 @@ def quantify(self, units=_default, unit_registry=None, **unit_kwargs): ... coords={"wavelength": [1e-4, 2e-4, 4e-4, 6e-4, 1e-3, 2e-3]}, ... ) >>> da.pint.quantify(units="Hz") - + Size: 48B Coordinates: - * wavelength (wavelength) float64 0.0001 0.0002 0.0004 0.0006 0.001 0.002 + * wavelength (wavelength) float64 48B 0.0001 0.0002 0.0004 0.0006 0.001 0.002 Don't quantify the data: @@ -313,7 +313,7 @@ def quantify(self, units=_default, unit_registry=None, **unit_kwargs): ... attrs={"units": "Hz"}, ... ) >>> da.pint.quantify(units=None) - + Size: 16B array([0.4, 0.9]) Dimensions without coordinates: wavelength @@ -321,11 +321,11 @@ def quantify(self, units=_default, unit_registry=None, **unit_kwargs): >>> q = da.pint.quantify() >>> q - + Size: 16B Dimensions without coordinates: wavelength >>> q.pint.quantify("Hz") - + Size: 16B Dimensions without coordinates: wavelength """ @@ -423,18 +423,18 @@ def dequantify(self, format=None): >>> da = xr.DataArray([0, 1], dims="x") >>> q = da.pint.quantify("m / s") >>> q - + Size: 16B Dimensions without coordinates: x >>> q.pint.dequantify(format="P") - + Size: 16B array([0, 1]) Dimensions without coordinates: x Attributes: units: meter/second >>> q.pint.dequantify(format="~P") - + Size: 16B array([0, 1]) Dimensions without coordinates: x Attributes: @@ -444,7 +444,7 @@ def dequantify(self, format=None): >>> pint_xarray.unit_registry.default_format = "~L" >>> q.pint.dequantify() - + Size: 16B array([0, 1]) Dimensions without coordinates: x Attributes: @@ -522,67 +522,67 @@ def to(self, units=None, **unit_kwargs): ... name="arr", ... ) >>> da - + Size: 40B Coordinates: - u (x) int64 [s] 0 1 2 3 4 + u (x) int64 40B [s] 0 1 2 3 4 Dimensions without coordinates: x Convert the data >>> da.pint.to("mm") - + Size: 40B Coordinates: - u (x) int64 [s] 0 1 2 3 4 + u (x) int64 40B [s] 0 1 2 3 4 Dimensions without coordinates: x >>> da.pint.to(ureg.mm) - + Size: 40B Coordinates: - u (x) int64 [s] 0 1 2 3 4 + u (x) int64 40B [s] 0 1 2 3 4 Dimensions without coordinates: x >>> da.pint.to({da.name: "mm"}) - + Size: 40B Coordinates: - u (x) int64 [s] 0 1 2 3 4 + u (x) int64 40B [s] 0 1 2 3 4 Dimensions without coordinates: x Convert coordinates >>> da.pint.to({"u": ureg.ms}) - + Size: 40B Coordinates: - u (x) float64 [ms] 0.0 1e+03 2e+03 3e+03 4e+03 + u (x) float64 40B [ms] 0.0 1e+03 2e+03 3e+03 4e+03 Dimensions without coordinates: x >>> da.pint.to(u="ms") - + Size: 40B Coordinates: - u (x) float64 [ms] 0.0 1e+03 2e+03 3e+03 4e+03 + u (x) float64 40B [ms] 0.0 1e+03 2e+03 3e+03 4e+03 Dimensions without coordinates: x Convert both simultaneously >>> da.pint.to("mm", u="ms") - + Size: 40B Coordinates: - u (x) float64 [ms] 0.0 1e+03 2e+03 3e+03 4e+03 + u (x) float64 40B [ms] 0.0 1e+03 2e+03 3e+03 4e+03 Dimensions without coordinates: x >>> da.pint.to({"arr": ureg.mm, "u": ureg.ms}) - + Size: 40B Coordinates: - u (x) float64 [ms] 0.0 1e+03 2e+03 3e+03 4e+03 + u (x) float64 40B [ms] 0.0 1e+03 2e+03 3e+03 4e+03 Dimensions without coordinates: x >>> da.pint.to(arr="mm", u="ms") - + Size: 40B Coordinates: - u (x) float64 [ms] 0.0 1e+03 2e+03 3e+03 4e+03 + u (x) float64 40B [ms] 0.0 1e+03 2e+03 3e+03 4e+03 Dimensions without coordinates: x """ if isinstance(units, (str, pint.Unit)): @@ -1031,57 +1031,57 @@ def quantify(self, units=_default, unit_registry=None, **unit_kwargs): ... ) >>> ds.pint.quantify() - + Size: 96B Dimensions: (x: 3) Coordinates: - * x (x) int64 0 1 2 - u (x) int64 [s] -1 0 1 + * x (x) int64 24B 0 1 2 + u (x) int64 24B [s] -1 0 1 Data variables: - a (x) int64 [m] 0 3 2 - b (x) int64 5 -2 1 + a (x) int64 24B [m] 0 3 2 + b (x) int64 24B 5 -2 1 >>> ds.pint.quantify({"b": "dm"}) - + Size: 96B Dimensions: (x: 3) Coordinates: - * x (x) int64 0 1 2 - u (x) int64 [s] -1 0 1 + * x (x) int64 24B 0 1 2 + u (x) int64 24B [s] -1 0 1 Data variables: - a (x) int64 [m] 0 3 2 - b (x) int64 [dm] 5 -2 1 + a (x) int64 24B [m] 0 3 2 + b (x) int64 24B [dm] 5 -2 1 Don't quantify specific variables: >>> ds.pint.quantify({"a": None}) - + Size: 96B Dimensions: (x: 3) Coordinates: - * x (x) int64 0 1 2 - u (x) int64 [s] -1 0 1 + * x (x) int64 24B 0 1 2 + u (x) int64 24B [s] -1 0 1 Data variables: - a (x) int64 0 3 2 - b (x) int64 5 -2 1 + a (x) int64 24B 0 3 2 + b (x) int64 24B 5 -2 1 Quantify with the same unit: >>> q = ds.pint.quantify() >>> q - + Size: 96B Dimensions: (x: 3) Coordinates: - * x (x) int64 0 1 2 - u (x) int64 [s] -1 0 1 + * x (x) int64 24B 0 1 2 + u (x) int64 24B [s] -1 0 1 Data variables: - a (x) int64 [m] 0 3 2 - b (x) int64 5 -2 1 + a (x) int64 24B [m] 0 3 2 + b (x) int64 24B 5 -2 1 >>> q.pint.quantify({"a": "m"}) - + Size: 96B Dimensions: (x: 3) Coordinates: - * x (x) int64 0 1 2 - u (x) int64 [s] -1 0 1 + * x (x) int64 24B 0 1 2 + u (x) int64 24B [s] -1 0 1 Data variables: - a (x) int64 [m] 0 3 2 - b (x) int64 5 -2 1 + a (x) int64 24B [m] 0 3 2 + b (x) int64 24B 5 -2 1 """ units = either_dict_or_kwargs(units, unit_kwargs, "quantify") registry = get_registry(unit_registry, units, conversion.extract_units(self.ds)) @@ -1167,22 +1167,22 @@ def dequantify(self, format=None): >>> ds = xr.Dataset({"a": ("x", [0, 1]), "b": ("y", [2, 3, 4])}) >>> q = ds.pint.quantify({"a": "m / s", "b": "s"}) >>> q - + Size: 40B Dimensions: (x: 2, y: 3) Dimensions without coordinates: x, y Data variables: - a (x) int64 [m/s] 0 1 - b (y) int64 [s] 2 3 4 + a (x) int64 16B [m/s] 0 1 + b (y) int64 24B [s] 2 3 4 >>> d = q.pint.dequantify(format="P") >>> d.a - + Size: 16B array([0, 1]) Dimensions without coordinates: x Attributes: units: meter/second >>> d.b - + Size: 24B array([2, 3, 4]) Dimensions without coordinates: y Attributes: @@ -1190,13 +1190,13 @@ def dequantify(self, format=None): >>> d = q.pint.dequantify(format="~P") >>> d.a - + Size: 16B array([0, 1]) Dimensions without coordinates: x Attributes: units: m/s >>> d.b - + Size: 24B array([2, 3, 4]) Dimensions without coordinates: y Attributes: @@ -1207,13 +1207,13 @@ def dequantify(self, format=None): >>> pint_xarray.unit_registry.default_format = "~L" >>> d = q.pint.dequantify() >>> d.a - + Size: 16B array([0, 1]) Dimensions without coordinates: x Attributes: units: \frac{\mathrm{m}}{\mathrm{s}} >>> d.b - + Size: 24B array([2, 3, 4]) Dimensions without coordinates: y Attributes: @@ -1260,77 +1260,77 @@ def to(self, units=None, **unit_kwargs): ... coords={"u": ("x", np.arange(5) * ureg.s)}, ... ) >>> ds - + Size: 120B Dimensions: (x: 5) Coordinates: - u (x) int64 [s] 0 1 2 3 4 + u (x) int64 40B [s] 0 1 2 3 4 Dimensions without coordinates: x Data variables: - a (x) float64 [m] 0.0 0.25 0.5 0.75 1.0 - b (x) float64 [kg] -1.0 -0.75 -0.5 -0.25 0.0 + a (x) float64 40B [m] 0.0 0.25 0.5 0.75 1.0 + b (x) float64 40B [kg] -1.0 -0.75 -0.5 -0.25 0.0 Convert the data >>> ds.pint.to({"a": "mm", "b": ureg.g}) - + Size: 120B Dimensions: (x: 5) Coordinates: - u (x) int64 [s] 0 1 2 3 4 + u (x) int64 40B [s] 0 1 2 3 4 Dimensions without coordinates: x Data variables: - a (x) float64 [mm] 0.0 250.0 500.0 750.0 1e+03 - b (x) float64 [g] -1e+03 -750.0 -500.0 -250.0 0.0 + a (x) float64 40B [mm] 0.0 250.0 500.0 750.0 1e+03 + b (x) float64 40B [g] -1e+03 -750.0 -500.0 -250.0 0.0 >>> ds.pint.to(a=ureg.mm, b="g") - + Size: 120B Dimensions: (x: 5) Coordinates: - u (x) int64 [s] 0 1 2 3 4 + u (x) int64 40B [s] 0 1 2 3 4 Dimensions without coordinates: x Data variables: - a (x) float64 [mm] 0.0 250.0 500.0 750.0 1e+03 - b (x) float64 [g] -1e+03 -750.0 -500.0 -250.0 0.0 + a (x) float64 40B [mm] 0.0 250.0 500.0 750.0 1e+03 + b (x) float64 40B [g] -1e+03 -750.0 -500.0 -250.0 0.0 Convert coordinates >>> ds.pint.to({"u": ureg.ms}) - + Size: 120B Dimensions: (x: 5) Coordinates: - u (x) float64 [ms] 0.0 1e+03 2e+03 3e+03 4e+03 + u (x) float64 40B [ms] 0.0 1e+03 2e+03 3e+03 4e+03 Dimensions without coordinates: x Data variables: - a (x) float64 [m] 0.0 0.25 0.5 0.75 1.0 - b (x) float64 [kg] -1.0 -0.75 -0.5 -0.25 0.0 + a (x) float64 40B [m] 0.0 0.25 0.5 0.75 1.0 + b (x) float64 40B [kg] -1.0 -0.75 -0.5 -0.25 0.0 >>> ds.pint.to(u="ms") - + Size: 120B Dimensions: (x: 5) Coordinates: - u (x) float64 [ms] 0.0 1e+03 2e+03 3e+03 4e+03 + u (x) float64 40B [ms] 0.0 1e+03 2e+03 3e+03 4e+03 Dimensions without coordinates: x Data variables: - a (x) float64 [m] 0.0 0.25 0.5 0.75 1.0 - b (x) float64 [kg] -1.0 -0.75 -0.5 -0.25 0.0 + a (x) float64 40B [m] 0.0 0.25 0.5 0.75 1.0 + b (x) float64 40B [kg] -1.0 -0.75 -0.5 -0.25 0.0 Convert both simultaneously >>> ds.pint.to(a=ureg.mm, b=ureg.g, u="ms") - + Size: 120B Dimensions: (x: 5) Coordinates: - u (x) float64 [ms] 0.0 1e+03 2e+03 3e+03 4e+03 + u (x) float64 40B [ms] 0.0 1e+03 2e+03 3e+03 4e+03 Dimensions without coordinates: x Data variables: - a (x) float64 [mm] 0.0 250.0 500.0 750.0 1e+03 - b (x) float64 [g] -1e+03 -750.0 -500.0 -250.0 0.0 + a (x) float64 40B [mm] 0.0 250.0 500.0 750.0 1e+03 + b (x) float64 40B [g] -1e+03 -750.0 -500.0 -250.0 0.0 >>> ds.pint.to({"a": "mm", "b": "g", "u": ureg.ms}) - + Size: 120B Dimensions: (x: 5) Coordinates: - u (x) float64 [ms] 0.0 1e+03 2e+03 3e+03 4e+03 + u (x) float64 40B [ms] 0.0 1e+03 2e+03 3e+03 4e+03 Dimensions without coordinates: x Data variables: - a (x) float64 [mm] 0.0 250.0 500.0 750.0 1e+03 - b (x) float64 [g] -1e+03 -750.0 -500.0 -250.0 0.0 + a (x) float64 40B [mm] 0.0 250.0 500.0 750.0 1e+03 + b (x) float64 40B [g] -1e+03 -750.0 -500.0 -250.0 0.0 Convert homogeneous data @@ -1342,23 +1342,23 @@ def to(self, units=None, **unit_kwargs): ... coords={"u": ("x", np.arange(5) * ureg.s)}, ... ) >>> ds - + Size: 120B Dimensions: (x: 5) Coordinates: - u (x) int64 [s] 0 1 2 3 4 + u (x) int64 40B [s] 0 1 2 3 4 Dimensions without coordinates: x Data variables: - a (x) float64 [kg] 0.0 0.25 0.5 0.75 1.0 - b (x) float64 [mg] -1.0 -0.75 -0.5 -0.25 0.0 + a (x) float64 40B [kg] 0.0 0.25 0.5 0.75 1.0 + b (x) float64 40B [mg] -1.0 -0.75 -0.5 -0.25 0.0 >>> ds.pint.to("g") - + Size: 120B Dimensions: (x: 5) Coordinates: - u (x) int64 [s] 0 1 2 3 4 + u (x) int64 40B [s] 0 1 2 3 4 Dimensions without coordinates: x Data variables: - a (x) float64 [g] 0.0 250.0 500.0 750.0 1e+03 - b (x) float64 [g] -0.001 -0.00075 -0.0005 -0.00025 0.0 + a (x) float64 40B [g] 0.0 250.0 500.0 750.0 1e+03 + b (x) float64 40B [g] -0.001 -0.00075 -0.0005 -0.00025 0.0 """ if isinstance(units, (str, pint.Unit)): unit_kwargs.update( From 82d7807040ac1e4e88e61fa2142b27a32f82763b Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Sun, 23 Jun 2024 14:59:41 +0200 Subject: [PATCH 7/7] temporarily pin `numpy` and `pint` --- ci/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/requirements.txt b/ci/requirements.txt index e703d88b..6a35ad10 100644 --- a/ci/requirements.txt +++ b/ci/requirements.txt @@ -1,5 +1,5 @@ -pint -numpy +pint!=0.24.0 +numpy<2 scipy dask[array] bottleneck