Skip to content

Commit f32e469

Browse files
authored
Add Python 3.12 coverage to CI (#663)
* Run tests with py3.12 * Formatting fixes * Install setuptools for Python >=3.12 (required for cffi) * Actions update * Sort imports
1 parent d9a7856 commit f32e469

11 files changed

+23
-21
lines changed

.github/workflows/pythonapp.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ jobs:
2121
strategy:
2222
matrix:
2323
os: [ubuntu-latest]
24-
python-version: ['3.9', '3.10', '3.11']
24+
python-version: ['3.9', '3.10', '3.11', '3.12']
2525
steps:
2626
- name: Checkout FFCx
2727
uses: actions/checkout@v4
2828
- name: Set up Python
29-
uses: actions/setup-python@v4
29+
uses: actions/setup-python@v5
3030
with:
3131
python-version: ${{ matrix.python-version }}
3232
- name: Install dependencies (non-Python, Linux)
@@ -46,7 +46,7 @@ jobs:
4646
run: flake8 --statistics ffcx/ test/
4747
- name: Static check with mypy
4848
run: mypy ffcx/
49-
if: matrix.python-version != '3.11'
49+
if: matrix.python-version != '3.12'
5050
- name: isort checks (non-blocking)
5151
continue-on-error: true
5252
run: isort --check .

demo/Components.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#
1818
# This example demonstrates how to create vectors component-wise
1919
import basix.ufl
20-
from ufl import (Coefficient, FunctionSpace, Mesh, TestFunction, as_vector,
21-
inner, dx)
20+
from ufl import (Coefficient, FunctionSpace, Mesh, TestFunction, as_vector, dx,
21+
inner)
2222

2323
element = basix.ufl.element("Lagrange", "tetrahedron", 1, shape=(3, ))
2424
domain = Mesh(element)

demo/Conditional.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
# Illustration on how to use Conditional to define a source term
1919
import basix.ufl
2020
from ufl import (And, Constant, FunctionSpace, Mesh, Not, Or,
21-
SpatialCoordinate, TestFunction, conditional, dx, ge, gt, inner, le,
22-
lt)
21+
SpatialCoordinate, TestFunction, conditional, dx, ge, gt,
22+
inner, le, lt)
2323

2424
element = basix.ufl.element("Lagrange", "triangle", 2)
2525
domain = Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))

demo/MetaData.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#
1818
# Test form for metadata.
1919
import basix.ufl
20-
from ufl import (Coefficient, Constant, FunctionSpace, Mesh, TestFunction, TrialFunction,
21-
dx, grad, inner)
20+
from ufl import (Coefficient, Constant, FunctionSpace, Mesh, TestFunction,
21+
TrialFunction, dx, grad, inner)
2222

2323
element = basix.ufl.element("Lagrange", "triangle", 1)
2424
vector_element = basix.ufl.element("Lagrange", "triangle", 1, shape=(2, ))

demo/Normals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# Merely project the normal onto a vector section.
2020
import basix.ufl
2121
from ufl import (FacetNormal, FunctionSpace, Mesh, TestFunction, TrialFunction,
22-
inner, ds, triangle)
22+
ds, inner, triangle)
2323

2424
cell = triangle
2525

ffcx/codegeneration/definitions.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
"""FFCx/UFC specific variable definitions."""
77

88
import logging
9+
from typing import List, Union
910

1011
import ffcx.codegeneration.lnodes as L
12+
import ufl
13+
from ffcx.ir.analysis.modified_terminals import ModifiedTerminal
1114
from ffcx.ir.elementtables import UniqueTableReferenceT
1215
from ffcx.ir.representationutils import QuadratureRule
13-
from ffcx.ir.analysis.modified_terminals import ModifiedTerminal
14-
from typing import List, Union
15-
import ufl
16-
1716

1817
logger = logging.getLogger("ffcx")
1918

ffcx/codegeneration/integral_generator.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66

77
import collections
88
import logging
9+
from numbers import Integral
910
from typing import Any, Dict, List, Set, Tuple
1011

1112
import ffcx.codegeneration.lnodes as L
1213
import ufl
1314
from ffcx.codegeneration import geometry
1415
from ffcx.codegeneration.definitions import (create_dof_index,
1516
create_quadrature_index)
17+
from ffcx.codegeneration.optimizer import optimize
1618
from ffcx.ir.elementtables import piecewise_ttypes
1719
from ffcx.ir.integral import BlockDataT
1820
from ffcx.ir.representationutils import QuadratureRule
19-
from ffcx.codegeneration.optimizer import optimize
20-
from numbers import Integral
2121

2222
logger = logging.getLogger("ffcx")
2323

ffcx/codegeneration/lnodes.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
#
55
# SPDX-License-Identifier: LGPL-3.0-or-later
66

7-
from typing import List, Optional, Sequence
87
import numbers
9-
from enum import Enum
108
import typing
9+
from enum import Enum
10+
from typing import List, Optional, Sequence
11+
1112
import numpy as np
1213

1314
import ufl

ffcx/codegeneration/optimizer.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from collections import defaultdict
12
from typing import List, Union
3+
24
import ffcx.codegeneration.lnodes as L
3-
from collections import defaultdict
45
from ffcx.ir.representationutils import QuadratureRule
56

67

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ authors = [
1616
dependencies = [
1717
"numpy>=1.21",
1818
"cffi",
19+
"setuptools; python_version >= '3.12'", # cffi with compilation support requires setuptools
1920
"fenics-basix >= 0.8.0.dev0, <0.9.0",
2021
"fenics-ufl >= 2023.3.0.dev0, <2023.4.0",
2122
]

test/test_lnodes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_gemm(dtype):
1818
A = L.Symbol("A", dtype=L.DataType.SCALAR)
1919
B = L.Symbol("B", dtype=L.DataType.SCALAR)
2020
C = L.Symbol("C", dtype=L.DataType.SCALAR)
21-
code = [L.Comment(f"Matrix multiply A{p,r} = B{p,q} * C{q,r}")]
21+
code = [L.Comment(f"Matrix multiply A{p, r} = B{p, q} * C{q, r}")]
2222

2323
i = L.Symbol("i", dtype=L.DataType.INT)
2424
j = L.Symbol("j", dtype=L.DataType.INT)
@@ -66,7 +66,7 @@ def test_gemv(dtype):
6666
y = L.Symbol("y", dtype=L.DataType.SCALAR)
6767
A = L.Symbol("A", dtype=L.DataType.SCALAR)
6868
x = L.Symbol("x", dtype=L.DataType.SCALAR)
69-
code = [L.Comment(f"Matrix-vector multiply y({p}) = A{p,q} * x({q})")]
69+
code = [L.Comment(f"Matrix-vector multiply y({p}) = A{p, q} * x({q})")]
7070

7171
i = L.Symbol("i", dtype=L.DataType.INT)
7272
j = L.Symbol("j", dtype=L.DataType.INT)

0 commit comments

Comments
 (0)