Skip to content

Commit b83e662

Browse files
Drop Aesara support and fix PyTensor compatibility (#44)
* Drop Aesara support This simplifies testing & upcoming fixes related to changes in shape handling in PyTensor. * Use static shape information about inputs * Don't run CI jobs twice * Require numpy >=1.17 In an attempt to fix the CI environment creation. * Require numpy >=1.19 * Drop Python 3.8, add Python 3.11 * Try pinning compatible numpy * Use mambabuild * Increase minimum numba to 0.57 * Relax lower numpy pin to 1.17 * Remove explicit numpy pin --------- Co-authored-by: Ben Mares <[email protected]>
1 parent 5050779 commit b83e662

File tree

5 files changed

+20
-27
lines changed

5 files changed

+20
-27
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Python package
22

3-
on: [pull_request, push]
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
48

59
jobs:
610
test-on-linux:
@@ -14,7 +18,7 @@ jobs:
1418
fail-fast: false
1519
matrix:
1620
os: ["ubuntu-latest", "windows-latest"]
17-
python-version: ["3.8", "3.9", "3.10"]
21+
python-version: ["3.9", "3.10", "3.11"]
1822
steps:
1923
- uses: actions/checkout@v3
2024
with:
@@ -28,10 +32,10 @@ jobs:
2832
python-version: ${{ matrix.python-version }}
2933
- name: Install Dependences
3034
run: |
31-
conda install --yes conda-build conda-verify pytest pytest-cov hypothesis statsmodels pytensor c-compiler
35+
conda install --yes conda-build boa conda-verify pytest pytest-cov hypothesis statsmodels pytensor c-compiler
3236
- name: Build package
3337
run: |
34-
conda build --variants "{python: [${{ matrix.python-version }}]}" ./sunode/conda
38+
conda mambabuild --variants "{python: [${{ matrix.python-version }}]}" ./sunode/conda
3539
- name: Install package
3640
run: |
3741
conda install --yes -c file:///${CONDA_PREFIX}/conda-bld/ sunode

conda/meta.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,16 @@ requirements:
2020
host:
2121
- python
2222
- pip
23-
- numpy >=1.14
2423
- liblapack
2524
- cffi
2625
- sundials >=5.3,<6.0
2726
run:
2827
- python
29-
- numpy >=1.14
3028
- cffi
3129
- xarray
3230
- scipy
3331
- sundials >=5.3,<6.0
34-
- numba >=0.49
32+
- numba >=0.57
3533
- typing_extensions
3634
- sympy >=1.8
3735

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get_version():
2020
author='Adrian Seyboldt',
2121
author_email='[email protected]',
2222
description='Python wrapper of sundials for solving ordinary differential equations',
23-
url='https://github.com/aseyboldt/sunode',
23+
url='https://github.com/pymc-devs/sunode',
2424
setup_requires=["cffi>=1.0.0"],
2525
cffi_modules=[
2626
"sunode/build_cvodes.py:ffibuilder",

sunode/wrappers/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
from . import as_pytensor
2-
from . import as_pytensor as as_aesara
32

4-
__all__ = ['as_aesara', 'as_pytensor']
3+
__all__ = ("as_pytensor",)

sunode/wrappers/as_pytensor.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
try:
2-
import pytensor.tensor as pt
3-
from pytensor.graph.basic import Constant, Variable
4-
from pytensor.graph.fg import MissingInputError
5-
from pytensor.graph.op import Op
6-
from pytensor.gradient import grad_not_implemented
7-
except ModuleNotFoundError:
8-
import aesara.tensor as pt
9-
from aesara.graph.basic import Constant, Variable
10-
from aesara.graph.fg import MissingInputError
11-
from aesara.graph.op import Op
12-
from aesara.gradient import grad_not_implemented
1+
import pytensor.tensor as pt
2+
from pytensor.graph.basic import Constant, Variable
3+
from pytensor.graph.fg import MissingInputError
4+
from pytensor.graph.op import Op
5+
from pytensor.gradient import grad_not_implemented
136
import copy
147
from typing import Dict, Optional, Any, Callable
158

@@ -52,12 +45,11 @@ def read_dict(vals, name=None):
5245
if isinstance(vals, tuple):
5346
tensor, dim_names = vals
5447
else:
55-
try:
56-
tensor, dim_names = vals, pt.as_tensor_variable(vals, dtype="float64").shape.eval()
57-
except MissingInputError as e:
48+
tensor, dim_names = vals, pt.as_tensor_variable(vals, dtype="float64").type.shape
49+
if any(d is None for d in dim_names):
5850
raise ValueError(
59-
'Shapes of tensors need to be statically '
60-
'known or given explicitly.') from e
51+
'Shapes of tensors need to be statically known or given explicitly.'
52+
)
6153
if isinstance(dim_names, (str, int)):
6254
dim_names = (dim_names,)
6355
tensor = pt.as_tensor_variable(tensor, dtype="float64")

0 commit comments

Comments
 (0)