From f22edc04578b995e297ff7829ad6ee5b76c1671c Mon Sep 17 00:00:00 2001 From: Michael Osthege Date: Thu, 17 Aug 2023 13:36:57 +0200 Subject: [PATCH 01/11] Drop Aesara support This simplifies testing & upcoming fixes related to changes in shape handling in PyTensor. --- setup.py | 2 +- sunode/wrappers/__init__.py | 3 +-- sunode/wrappers/as_pytensor.py | 17 +++++------------ 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index b85d287..d6a07ea 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ def get_version(): author='Adrian Seyboldt', author_email='adrian.seyboldt@gmail.com', description='Python wrapper of sundials for solving ordinary differential equations', - url='https://github.com/aseyboldt/sunode', + url='https://github.com/pymc-devs/sunode', setup_requires=["cffi>=1.0.0"], cffi_modules=[ "sunode/build_cvodes.py:ffibuilder", diff --git a/sunode/wrappers/__init__.py b/sunode/wrappers/__init__.py index 9fb2e5e..d0945c9 100644 --- a/sunode/wrappers/__init__.py +++ b/sunode/wrappers/__init__.py @@ -1,4 +1,3 @@ from . import as_pytensor -from . import as_pytensor as as_aesara -__all__ = ['as_aesara', 'as_pytensor'] \ No newline at end of file +__all__ = ("as_pytensor",) diff --git a/sunode/wrappers/as_pytensor.py b/sunode/wrappers/as_pytensor.py index 69c11eb..a9d1017 100644 --- a/sunode/wrappers/as_pytensor.py +++ b/sunode/wrappers/as_pytensor.py @@ -1,15 +1,8 @@ -try: - import pytensor.tensor as pt - from pytensor.graph.basic import Constant, Variable - from pytensor.graph.fg import MissingInputError - from pytensor.graph.op import Op - from pytensor.gradient import grad_not_implemented -except ModuleNotFoundError: - import aesara.tensor as pt - from aesara.graph.basic import Constant, Variable - from aesara.graph.fg import MissingInputError - from aesara.graph.op import Op - from aesara.gradient import grad_not_implemented +import pytensor.tensor as pt +from pytensor.graph.basic import Constant, Variable +from pytensor.graph.fg import MissingInputError +from pytensor.graph.op import Op +from pytensor.gradient import grad_not_implemented import copy from typing import Dict, Optional, Any, Callable From 5316cfcfd9e229d49a965e16f0f8030a5bebda41 Mon Sep 17 00:00:00 2001 From: Michael Osthege Date: Fri, 18 Aug 2023 13:42:19 +0200 Subject: [PATCH 02/11] Use static shape information about inputs --- sunode/wrappers/as_pytensor.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sunode/wrappers/as_pytensor.py b/sunode/wrappers/as_pytensor.py index a9d1017..137ad74 100644 --- a/sunode/wrappers/as_pytensor.py +++ b/sunode/wrappers/as_pytensor.py @@ -45,12 +45,11 @@ def read_dict(vals, name=None): if isinstance(vals, tuple): tensor, dim_names = vals else: - try: - tensor, dim_names = vals, pt.as_tensor_variable(vals, dtype="float64").shape.eval() - except MissingInputError as e: + tensor, dim_names = vals, pt.as_tensor_variable(vals, dtype="float64").type.shape + if any(d is None for d in dim_names): raise ValueError( - 'Shapes of tensors need to be statically ' - 'known or given explicitly.') from e + 'Shapes of tensors need to be statically known or given explicitly.' + ) if isinstance(dim_names, (str, int)): dim_names = (dim_names,) tensor = pt.as_tensor_variable(tensor, dtype="float64") From 5711c50241047d06186aff896f3b26e6200a6bfb Mon Sep 17 00:00:00 2001 From: Michael Osthege Date: Fri, 18 Aug 2023 17:30:16 +0200 Subject: [PATCH 03/11] Don't run CI jobs twice --- .github/workflows/main.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6dc3583..328d9fe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,10 @@ name: Python package -on: [pull_request, push] +on: + pull_request: + push: + branches: + - master jobs: test-on-linux: From 74aaf1fe267de28de2eb707f316b22c45890655e Mon Sep 17 00:00:00 2001 From: Michael Osthege Date: Fri, 18 Aug 2023 17:40:17 +0200 Subject: [PATCH 04/11] Require numpy >=1.17 In an attempt to fix the CI environment creation. --- conda/meta.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conda/meta.yaml b/conda/meta.yaml index 16fcfa3..efeabe8 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -20,13 +20,13 @@ requirements: host: - python - pip - - numpy >=1.14 + - numpy >=1.17 - liblapack - cffi - sundials >=5.3,<6.0 run: - python - - numpy >=1.14 + - numpy >=1.17 - cffi - xarray - scipy From 0f0ad191716e26d198066c3b234737066fb678ec Mon Sep 17 00:00:00 2001 From: Michael Osthege Date: Fri, 18 Aug 2023 18:21:53 +0200 Subject: [PATCH 05/11] Require numpy >=1.19 --- conda/meta.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conda/meta.yaml b/conda/meta.yaml index efeabe8..0fbe05d 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -20,13 +20,13 @@ requirements: host: - python - pip - - numpy >=1.17 + - numpy >=1.19 - liblapack - cffi - sundials >=5.3,<6.0 run: - python - - numpy >=1.17 + - numpy >=1.19 - cffi - xarray - scipy From aa7b8a3b027ac490da3cccd175dcfd96fe9a48b5 Mon Sep 17 00:00:00 2001 From: Michael Osthege Date: Fri, 18 Aug 2023 19:41:20 +0200 Subject: [PATCH 06/11] Drop Python 3.8, add Python 3.11 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 328d9fe..dcd3c20 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: ["ubuntu-latest", "windows-latest"] - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 with: From 87908ddec355264055c088c7a521a79d5ae1701f Mon Sep 17 00:00:00 2001 From: Michael Osthege Date: Sun, 20 Aug 2023 18:58:44 +0200 Subject: [PATCH 07/11] Try pinning compatible numpy --- conda/meta.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/conda/meta.yaml b/conda/meta.yaml index 0fbe05d..1ab3331 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -34,6 +34,7 @@ requirements: - numba >=0.49 - typing_extensions - sympy >=1.8 + - {{ pin_compatible("numpy") }} test: imports: From 44ca4e90a6d7f832f0d521c08ecbe3810990065e Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sun, 20 Aug 2023 19:58:54 +0200 Subject: [PATCH 08/11] Use mambabuild --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dcd3c20..c2a5d27 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,10 +32,10 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install Dependences run: | - conda install --yes conda-build conda-verify pytest pytest-cov hypothesis statsmodels pytensor c-compiler + conda install --yes conda-build boa conda-verify pytest pytest-cov hypothesis statsmodels pytensor c-compiler - name: Build package run: | - conda build --variants "{python: [${{ matrix.python-version }}]}" ./sunode/conda + conda mambabuild --variants "{python: [${{ matrix.python-version }}]}" ./sunode/conda - name: Install package run: | conda install --yes -c file:///${CONDA_PREFIX}/conda-bld/ sunode From e22497f5ea691dd12e024c010fe0522415152dda Mon Sep 17 00:00:00 2001 From: Michael Osthege Date: Sun, 20 Aug 2023 20:24:34 +0200 Subject: [PATCH 09/11] Increase minimum numba to 0.57 --- conda/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda/meta.yaml b/conda/meta.yaml index 1ab3331..c7a1a61 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -31,7 +31,7 @@ requirements: - xarray - scipy - sundials >=5.3,<6.0 - - numba >=0.49 + - numba >=0.57 - typing_extensions - sympy >=1.8 - {{ pin_compatible("numpy") }} From 8f2a623cdf39244baa76ae873f93e64f9bd7ebe8 Mon Sep 17 00:00:00 2001 From: Michael Osthege Date: Sun, 20 Aug 2023 21:03:43 +0200 Subject: [PATCH 10/11] Relax lower numpy pin to 1.17 --- conda/meta.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conda/meta.yaml b/conda/meta.yaml index c7a1a61..95e074a 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -20,13 +20,13 @@ requirements: host: - python - pip - - numpy >=1.19 + - numpy >=1.17 - liblapack - cffi - sundials >=5.3,<6.0 run: - python - - numpy >=1.19 + - numpy >=1.17 - cffi - xarray - scipy From fb2dd4adf9d1cbe15f5b61d17a15835323ed796c Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sun, 20 Aug 2023 23:21:58 +0200 Subject: [PATCH 11/11] Remove explicit numpy pin --- conda/meta.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/conda/meta.yaml b/conda/meta.yaml index 95e074a..7542a86 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -20,13 +20,11 @@ requirements: host: - python - pip - - numpy >=1.17 - liblapack - cffi - sundials >=5.3,<6.0 run: - python - - numpy >=1.17 - cffi - xarray - scipy @@ -34,7 +32,6 @@ requirements: - numba >=0.57 - typing_extensions - sympy >=1.8 - - {{ pin_compatible("numpy") }} test: imports: