Skip to content

Commit

Permalink
Fixes for shapely and scipy updates (#174)
Browse files Browse the repository at this point in the history
* Remove duplicate install of testing dependencies

* Require latest version of model_metadata

* Remove obsolete esmpy requirement

* Don't install components for testing

The subsequent call to `mamba install` updates *shapely* to 2.0,
which breaks the <1.9 requirement from #164.

* import UnitSystem from gimli.units

* remove redundant gimli.units unit tests

* checkout gimli.units raises UdunitsError

* Consolidate requirements in one install step

* Fix typos

* Roll back model_metadata for older models

* Remove shapely version cap

* Convert shapely proxy object to geometries

See https://shapely.readthedocs.io/en/stable/migration.html#other-deprecated-functionality

* Remove scipy version cap

* Mark fail when extrapolating with previous and next methods

See scipy/scipy#16997 (comment)

* Check for AssertionError instead of ValueError

* Revert "Don't install components for testing"

This reverts commit bfb47fc.
The shapely version issue is resolved.

* Limit numpy<2

See #173.

* Set numpy print options to legacy=1.21

Without this setting, the value of legacy=1.25 was being inherited
from Landlab, which isn't allowed in the installed version of numpy<2
(currently 1.26.4).

* Add python=3.11 to tests

* Switch from Mambaforge to Miniforge

* Switch from mamba to conda

* Update versions of packaged actions

* install requirements with pip

* turn off fail-fast

* switch back to conda to install requirements

---------

Co-authored-by: mcflugen <mcflugen@gmail.com>
  • Loading branch information
mdpiper and mcflugen authored Oct 11, 2024
1 parent 78cfd16 commit df648b4
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: psf/black@stable
with:
options: "--check --verbose --diff"
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,20 @@ jobs:
shell: bash -l {0}

steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
python-version: 3.8

- name: Show conda installation info
run: |
mamba info
mamba list
conda info
conda list
- name: Install dependencies
run: |
mamba install --file=requirements.txt --file=requirements-docs.txt gimli.units
conda install --file=requirements.txt --file=requirements-docs.txt gimli.units
pip install -e .
- name: Build documentation
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/test-notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,21 @@ jobs:

- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
python-version: ${{ matrix.python-version }}

- name: Show conda installation info
run: |
mamba info
mamba list
conda info
conda list
- name: Install requirements
run: |
mamba install \
conda install \
--file=requirements.txt \
--file=requirements-testing.txt \
--file=requirements-notebooks.txt
mamba list
conda list
- name: Build and install package
run: |
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,38 @@ jobs:
shell: bash -l {0}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10"]
python-version: ["3.10", "3.11"]

steps:
- uses: actions/checkout@v4

- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
python-version: ${{ matrix.python-version }}

- name: Show conda installation info
run: |
mamba info
mamba list
conda info
conda list
- name: Install requirements
run: |
mamba install --file=requirements.txt --file=requirements-testing.txt
mamba list
conda install --file=requirements.txt --file=requirements-testing.txt
conda list
# - name: Install Windows requirements
# if: matrix.os == 'windows-latest'
# run: |
# mamba install pymt_child pymt_hydrotrend pymt_permamodel
- name: Install Windows requirements
if: matrix.os == 'windows-latest'
run: |
conda install pymt_child pymt_hydrotrend pymt_permamodel
# - name: Install Unix requirements
# if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
# run: |
# mamba install pymt_cem pymt_child pymt_hydrotrend pymt_permamodel
- name: Install Unix requirements
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: |
conda install pymt_cem pymt_child pymt_hydrotrend pymt_permamodel
- name: Build and install package
run: |
Expand Down
3 changes: 3 additions & 0 deletions pymt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import numpy as np
from gimli.units import UnitSystem

from ._version import __version__
from .model_collection import ModelCollection

np.set_printoptions(legacy="1.21")

MODELS = ModelCollection()

__all__ = ["__version__", "UnitSystem", "MODELS"]
8 changes: 4 additions & 4 deletions pymt/grids/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"""

from shapely.geometry import Point, asLineString, asPoint, asPolygon
from shapely.geometry import Point, LineString, Polygon

from pymt.grids import (
Rectilinear,
Expand Down Expand Up @@ -84,11 +84,11 @@ def __init__(self, *args, **kwargs):

(x, y) = (point_x.take(cell), point_y.take(cell))
if len(x) > 2:
self._polys.append(asPolygon(zip(x, y)))
self._polys.append(Polygon(zip(x, y)))
elif len(x) == 2:
self._polys.append(asLineString(zip(x, y)))
self._polys.append(LineString(zip(x, y)))
else:
self._polys.append(asPoint(zip(x, y)))
self._polys.append(Point(zip(x, y)))

def get_shared_cells(self, point_id):
"""
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ landlab>=2
matplotlib
model_metadata<0.8
netcdf4
numpy<2 # see #173
pyyaml
scipy<1.9 # see #162
shapely<2 # see #164
scipy
shapely
xarray
# cfunits
# esmpy
4 changes: 3 additions & 1 deletion tests/framework/test_timeinterp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_timeinterp():

def test_timeinterp_with_scalars():
interp = TimeInterpolator(((0.0, 1.0),))
with raises(ValueError):
with raises(AssertionError):
assert interp(0.5) == approx(1.5)
interp.add_data(((1.0, 2.0),))
assert interp(0.5) == approx(1.5)
Expand Down Expand Up @@ -81,6 +81,7 @@ def test_interp_between_points(method):


@pytest.mark.parametrize("method", TimeInterpolator.METHODS)
@pytest.mark.xfail(condition="pytest.param('next')", raises=AssertionError)
def test_interp_outside_range(method):
interp = TimeInterpolator(
((0.0, 1.0), (1.0, 2.0), (2.0, 3.0), (3.0, 4.0)), method=method
Expand All @@ -89,6 +90,7 @@ def test_interp_outside_range(method):


@pytest.mark.parametrize("method", TimeInterpolator.METHODS)
@pytest.mark.xfail(condition="pytest.param('previous')", raises=AssertionError)
def test_interp_below_range(method):
interp = TimeInterpolator(
((0.0, 4.0), (1.0, 3.0), (2.0, 2.0), (3.0, 1.0)), method=method
Expand Down

0 comments on commit df648b4

Please sign in to comment.