From 6ab83adf7f02fa5ebea604f08565fc20dba3b287 Mon Sep 17 00:00:00 2001 From: Romain Date: Thu, 23 Jun 2022 13:59:02 +0200 Subject: [PATCH 1/3] use np.expand_dims instead of np.newaxis --- gsw/geostrophy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gsw/geostrophy.py b/gsw/geostrophy.py index 7c7104e..fd1436a 100644 --- a/gsw/geostrophy.py +++ b/gsw/geostrophy.py @@ -184,8 +184,8 @@ def distance(lon, lat, p=0, axis=-1): % (lon.shape, axis)) if lon.ndim == 1: one_d = True - lon = lon[np.newaxis, :] - lat = lat[np.newaxis, :] + lon = np.expand_dims(lon, (0,)) + lat = np.expand_dims(lat, (0,)) axis = -1 else: one_d = False From 37238538df8872a524d08bef27b2d343775fb58a Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Fri, 24 Jun 2022 14:15:14 -0300 Subject: [PATCH 2/3] --no-build-isolation until pip is fixed upstream --- .github/workflows/tests.yml | 9 +++++++-- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5a53d4d..b9ba7de 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,13 +33,18 @@ jobs: run: | micromamba create --name TEST python=${{ matrix.python-version }} python-build numpy=${{ matrix.numpy-version }} --file requirements-dev.txt --channel conda-forge micromamba activate TEST - pip install -e . --no-deps --force-reinstall + python -m pip install -e . --no-deps --no-build-isolation --force-reinstall + + - name: Debug + shell: bash -l {0} + run: | + micromamba activate TEST micromamba info --all micromamba list + python -c "import numpy; print(f'Running numpy {numpy.__version__}')" - name: Tests shell: bash -l {0} run: | micromamba activate TEST - python -c "import numpy; print(f'Running numpy {numpy.__version__}')" pytest -s -rxs -v gsw/tests diff --git a/pyproject.toml b/pyproject.toml index 820e39e..5bc1231 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["pip >9.0.1", "setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4", "oldest-supported-numpy", "build"] +requires = ["pip>9.0.1", "setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4", "oldest-supported-numpy", "build"] build-backend = "setuptools.build_meta" From 61a6834140b94f0daf6035cd2645bab9ddee48e2 Mon Sep 17 00:00:00 2001 From: Romain Date: Sat, 25 Jun 2022 11:21:41 +0200 Subject: [PATCH 3/3] add comment and remove tuple --- gsw/geostrophy.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gsw/geostrophy.py b/gsw/geostrophy.py index fd1436a..42e2328 100644 --- a/gsw/geostrophy.py +++ b/gsw/geostrophy.py @@ -184,8 +184,9 @@ def distance(lon, lat, p=0, axis=-1): % (lon.shape, axis)) if lon.ndim == 1: one_d = True - lon = np.expand_dims(lon, (0,)) - lat = np.expand_dims(lat, (0,)) + # xarray requires expand_dims() rather than [newaxis, :] + lon = np.expand_dims(lon, 0) + lat = np.expand_dims(lat, 0) axis = -1 else: one_d = False