Skip to content

Drop Aesara support and fix PyTensor compatibility #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Python package

on: [pull_request, push]
on:
pull_request:
push:
branches:
- master

jobs:
test-on-linux:
Expand All @@ -14,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:
Expand All @@ -28,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
Expand Down
4 changes: 1 addition & 3 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,16 @@ requirements:
host:
- python
- pip
- numpy >=1.14
- liblapack
- cffi
- sundials >=5.3,<6.0
run:
- python
- numpy >=1.14
- cffi
- xarray
- scipy
- sundials >=5.3,<6.0
- numba >=0.49
- numba >=0.57
- typing_extensions
- sympy >=1.8

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_version():
author='Adrian Seyboldt',
author_email='[email protected]',
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",
Expand Down
3 changes: 1 addition & 2 deletions sunode/wrappers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from . import as_pytensor
from . import as_pytensor as as_aesara

__all__ = ['as_aesara', 'as_pytensor']
__all__ = ("as_pytensor",)
26 changes: 9 additions & 17 deletions sunode/wrappers/as_pytensor.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -52,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")
Expand Down