Skip to content
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

Add support for both ufl and ufl-legacy #24

Merged
merged 10 commits into from
Apr 26, 2024
33 changes: 33 additions & 0 deletions .github/workflows/conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Test package in conda environment

on: [workflow_dispatch]

jobs:
test-conda:
name: Test with conda environment
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.11"]
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Conda install fenics
shell: bash -el {0}
run: conda install -c conda-forge fenics

- name: Upgrade pip
shell: bash -l {0}
run: python3 -m pip install --upgrade pip

- name: Install package
shell: bash -l {0}
run: python3 -m pip install -e .[test]

- name: Run tests
shell: bash -l {0}
run: python3 -m pytest --cov=beat --cov-report=html --cov-report=term-missing -v
6 changes: 5 additions & 1 deletion demos/endocardial_stimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
import matplotlib.pyplot as plt

import dolfin
import ufl_legacy as ufl

try:
import ufl_legacy as ufl
except ImportError:
import ufl

try:
from tqdm import tqdm
Expand Down
6 changes: 5 additions & 1 deletion demos/endocardial_stimulation_odefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
import matplotlib.pyplot as plt

import dolfin
import ufl_legacy as ufl

try:
import ufl_legacy as ufl
except ImportError:
import ufl

try:
from tqdm import tqdm
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ requires-python = ">=3.8"
keywords = ["cardiac", "electrophysiology"]
dependencies = [
"numpy",
"scipy",
]

[project.urls]
Expand Down
9 changes: 7 additions & 2 deletions src/beat/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
from enum import Enum, auto

import dolfin
import ufl_legacy as ufl
from ufl_legacy.core.expr import Expr

try:
import ufl_legacy as ufl
from ufl_legacy.core.expr import Expr
except ImportError:
import ufl
from ufl.core.expr import Expr


logger = logging.getLogger(__name__)
Expand Down
9 changes: 7 additions & 2 deletions src/beat/bidomain_model.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from __future__ import annotations
import logging
import ufl_legacy as ufl
from ufl_legacy.core.expr import Expr
import dolfin

try:
import ufl_legacy as ufl
from ufl_legacy.core.expr import Expr
except ImportError:
import ufl
from ufl.core.expr import Expr

from .base_model import BaseModel, Stimulus


Expand Down
7 changes: 6 additions & 1 deletion src/beat/ecg.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from __future__ import annotations
import dolfin
from typing import NamedTuple
import ufl_legacy as ufl
import numpy as np

try:
import ufl_legacy as ufl
except ImportError:
import ufl


def ecg_recovery(
*,
Expand Down
9 changes: 7 additions & 2 deletions src/beat/monodomain_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
import logging

import dolfin
import ufl_legacy as ufl
from ufl_legacy.core.expr import Expr

try:
import ufl_legacy as ufl
from ufl_legacy.core.expr import Expr
except ImportError:
import ufl
from ufl.core.expr import Expr

from .base_model import BaseModel, Stimulus

Expand Down
8 changes: 6 additions & 2 deletions src/beat/utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
from __future__ import annotations
from typing import Any
import logging
from contextlib import contextmanager
import dolfin
import numpy.typing as npt
import numpy as np
import ufl_legacy as ufl
from contextlib import contextmanager
from mpi4py import MPI as pyMPI

try:
import ufl_legacy as ufl
except ImportError:
import ufl


logger = logging.getLogger(__name__)

Expand Down
Loading