Skip to content

Commit a8242f0

Browse files
committed
Match min required version to min CI version
1 parent ee250af commit a8242f0

16 files changed

+130
-141
lines changed

ffcx/analysis.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,18 @@ class UFLData(typing.NamedTuple):
2626
"""UFL data."""
2727

2828
# Tuple of ufl form data
29-
form_data: typing.Tuple[ufl.algorithms.formdata.FormData, ...]
29+
form_data: tuple[ufl.algorithms.formdata.FormData, ...]
3030
# List of unique elements
31-
unique_elements: typing.List[basix.ufl._ElementBase]
31+
unique_elements: list[basix.ufl._ElementBase]
3232
# Lookup table from each unique element to its index in `unique_elements`
33-
element_numbers: typing.Dict[basix.ufl._ElementBase, int]
33+
element_numbers: dict[basix.ufl._ElementBase, int]
3434
# List of unique coordinate elements
35-
unique_coordinate_elements: typing.List[basix.ufl._ElementBase]
35+
unique_coordinate_elements: list[basix.ufl._ElementBase]
3636
# List of ufl Expressions as tuples (expression, points, original_expression)
37-
expressions: typing.List[
38-
typing.Tuple[ufl.core.expr.Expr, npt.NDArray[np.float64], ufl.core.expr.Expr]
39-
]
37+
expressions: list[tuple[ufl.core.expr.Expr, npt.NDArray[np.float64], ufl.core.expr.Expr]]
4038

4139

42-
def analyze_ufl_objects(ufl_objects: typing.List, options: typing.Dict) -> UFLData:
40+
def analyze_ufl_objects(ufl_objects: list, options: dict) -> UFLData:
4341
"""Analyze ufl object(s).
4442
4543
Args:
@@ -112,7 +110,7 @@ def analyze_ufl_objects(ufl_objects: typing.List, options: typing.Dict) -> UFLDa
112110
)
113111

114112

115-
def _analyze_expression(expression: ufl.core.expr.Expr, options: typing.Dict):
113+
def _analyze_expression(expression: ufl.core.expr.Expr, options: dict):
116114
"""Analyzes and preprocesses expressions."""
117115
preserve_geometry_types = (ufl.classes.Jacobian,)
118116
expression = ufl.algorithms.apply_algebra_lowering.apply_algebra_lowering(expression)
@@ -134,7 +132,7 @@ def _analyze_expression(expression: ufl.core.expr.Expr, options: typing.Dict):
134132
return expression
135133

136134

137-
def _analyze_form(form: ufl.form.Form, options: typing.Dict) -> ufl.algorithms.formdata.FormData:
135+
def _analyze_form(form: ufl.form.Form, options: dict) -> ufl.algorithms.formdata.FormData:
138136
"""Analyzes UFL form and attaches metadata.
139137
140138
Args:

ffcx/codegeneration/codegeneration.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class CodeBlocks(typing.NamedTuple):
3030
and start and end of file output
3131
"""
3232

33-
file_pre: typing.List[typing.Tuple[str, str]]
34-
elements: typing.List[typing.Tuple[str, str]]
35-
dofmaps: typing.List[typing.Tuple[str, str]]
36-
integrals: typing.List[typing.Tuple[str, str]]
37-
forms: typing.List[typing.Tuple[str, str]]
38-
expressions: typing.List[typing.Tuple[str, str]]
39-
file_post: typing.List[typing.Tuple[str, str]]
33+
file_pre: list[tuple[str, str]]
34+
elements: list[tuple[str, str]]
35+
dofmaps: list[tuple[str, str]]
36+
integrals: list[tuple[str, str]]
37+
forms: list[tuple[str, str]]
38+
expressions: list[tuple[str, str]]
39+
file_post: list[tuple[str, str]]
4040

4141

4242
def generate_code(ir, options) -> CodeBlocks:

ffcx/codegeneration/definitions.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""FFCx/UFC specific variable definitions."""
77

88
import logging
9-
from typing import List, Union
9+
from typing import Union
1010

1111
import ufl
1212

@@ -86,7 +86,7 @@ def get(
8686
tabledata: UniqueTableReferenceT,
8787
quadrature_rule: QuadratureRule,
8888
access: L.Symbol,
89-
) -> Union[L.Section, List]:
89+
) -> Union[L.Section, list]:
9090
"""Return definition code for a terminal."""
9191
# Call appropriate handler, depending on the type of terminal
9292
terminal = mt.terminal
@@ -111,7 +111,7 @@ def coefficient(
111111
tabledata: UniqueTableReferenceT,
112112
quadrature_rule: QuadratureRule,
113113
access: L.Symbol,
114-
) -> Union[L.Section, List]:
114+
) -> Union[L.Section, list]:
115115
"""Return definition code for coefficients."""
116116
# For applying tensor product to coefficients, we need to know if the coefficient
117117
# has a tensor factorisation and if the quadrature rule has a tensor factorisation.
@@ -146,7 +146,7 @@ def coefficient(
146146
mt.terminal, (ic.global_index) * bs + begin
147147
)
148148

149-
declaration: List[L.Declaration] = [L.VariableDecl(access, 0.0)]
149+
declaration: list[L.Declaration] = [L.VariableDecl(access, 0.0)]
150150
body = [L.AssignAdd(access, dof_access * FE)]
151151
code = [L.create_nested_for_loops([ic], body)]
152152

@@ -167,7 +167,7 @@ def _define_coordinate_dofs_lincomb(
167167
tabledata: UniqueTableReferenceT,
168168
quadrature_rule: QuadratureRule,
169169
access: L.Symbol,
170-
) -> Union[L.Section, List]:
170+
) -> Union[L.Section, list]:
171171
"""Define x or J as a linear combination of coordinate dofs with given table data."""
172172
# Get properties of domain
173173
domain = ufl.domain.extract_unique_domain(mt.terminal)
@@ -222,7 +222,7 @@ def spatial_coordinate(
222222
tabledata: UniqueTableReferenceT,
223223
quadrature_rule: QuadratureRule,
224224
access: L.Symbol,
225-
) -> Union[L.Section, List]:
225+
) -> Union[L.Section, list]:
226226
"""Return definition code for the physical spatial coordinates.
227227
228228
If physical coordinates are given:
@@ -248,7 +248,7 @@ def jacobian(
248248
tabledata: UniqueTableReferenceT,
249249
quadrature_rule: QuadratureRule,
250250
access: L.Symbol,
251-
) -> Union[L.Section, List]:
251+
) -> Union[L.Section, list]:
252252
"""Return definition code for the Jacobian of x(X)."""
253253
return self._define_coordinate_dofs_lincomb(mt, tabledata, quadrature_rule, access)
254254

@@ -258,6 +258,6 @@ def pass_through(
258258
tabledata: UniqueTableReferenceT,
259259
quadrature_rule: QuadratureRule,
260260
access: L.Symbol,
261-
) -> Union[L.Section, List]:
261+
) -> Union[L.Section, list]:
262262
"""Return definition code for pass through terminals."""
263263
return []

ffcx/codegeneration/expression_generator.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import collections
99
import logging
1010
from itertools import product
11-
from typing import Any, DefaultDict, Dict, Set
11+
from typing import Any
1212

1313
import ufl
1414

@@ -31,10 +31,10 @@ def __init__(self, ir: ExpressionIR, backend: FFCXBackend):
3131

3232
self.ir = ir
3333
self.backend = backend
34-
self.scope: Dict[Any, LNode] = {}
35-
self._ufl_names: Set[Any] = set()
36-
self.symbol_counters: DefaultDict[Any, int] = collections.defaultdict(int)
37-
self.shared_symbols: Dict[Any, Any] = {}
34+
self.scope: dict[Any, LNode] = {}
35+
self._ufl_names: set[Any] = set()
36+
self.symbol_counters: collections.defaultdict[Any, int] = collections.defaultdict(int)
37+
self.shared_symbols: dict[Any, Any] = {}
3838
self.quadrature_rule = list(self.ir.integrand.keys())[0]
3939

4040
def generate(self):
@@ -65,7 +65,7 @@ def generate_geometry_tables(self):
6565
ufl_geometry = {
6666
ufl.geometry.ReferenceCellVolume: "reference_cell_volume",
6767
}
68-
cells: Dict[Any, Set[Any]] = {t: set() for t in ufl_geometry.keys()} # type: ignore
68+
cells: dict[Any, set[Any]] = {t: set() for t in ufl_geometry.keys()} # type: ignore
6969

7070
for integrand in self.ir.integrand.values():
7171
for attr in integrand["factorization"].nodes.values():

ffcx/codegeneration/integral_generator.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import collections
99
import logging
1010
from numbers import Integral
11-
from typing import Any, Dict, List, Set, Tuple
11+
from typing import Any
1212

1313
import ufl
1414

@@ -23,7 +23,7 @@
2323
logger = logging.getLogger("ffcx")
2424

2525

26-
def extract_dtype(v, vops: List[Any]):
26+
def extract_dtype(v, vops: list[Any]):
2727
"""Extract dtype from ufl expression v and its operands."""
2828
dtypes = []
2929
for op in vops:
@@ -201,7 +201,7 @@ def generate_geometry_tables(self):
201201
ufl.geometry.ReferenceNormal: "reference_facet_normals",
202202
ufl.geometry.FacetOrientation: "facet_orientation",
203203
}
204-
cells: Dict[Any, Set[Any]] = {t: set() for t in ufl_geometry.keys()} # type: ignore
204+
cells: dict[Any, set[Any]] = {t: set() for t in ufl_geometry.keys()} # type: ignore
205205

206206
for integrand in self.ir.integrand.values():
207207
for attr in integrand["factorization"].nodes.values():
@@ -418,7 +418,7 @@ def get_arg_factors(self, blockdata, block_rank, quadrature_rule, iq, indices):
418418
return arg_factors, tables
419419

420420
def generate_block_parts(
421-
self, quadrature_rule: QuadratureRule, blockmap: Tuple, blocklist: List[BlockDataT]
421+
self, quadrature_rule: QuadratureRule, blockmap: tuple, blocklist: list[BlockDataT]
422422
):
423423
"""Generate and return code parts for a given block.
424424
@@ -429,8 +429,8 @@ def generate_block_parts(
429429
quadloop-independent blocks.
430430
"""
431431
# The parts to return
432-
quadparts: List[L.LNode] = []
433-
intermediates: List[L.LNode] = []
432+
quadparts: list[L.LNode] = []
433+
intermediates: list[L.LNode] = []
434434
tables = []
435435
vars = []
436436

@@ -526,7 +526,7 @@ def generate_block_parts(
526526
for indices in rhs_expressions:
527527
keep[indices] = rhs_expressions[indices]
528528

529-
body: List[L.LNode] = []
529+
body: list[L.LNode] = []
530530

531531
A = self.backend.symbols.element_tensor
532532
A_shape = self.ir.tensor_shape

ffcx/codegeneration/lnodes.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
"""
2525

2626
import numbers
27-
import typing
27+
from collections.abc import Sequence
2828
from enum import Enum
29-
from typing import List, Optional, Sequence
29+
from typing import Optional
3030

3131
import numpy as np
3232
import ufl
@@ -114,7 +114,7 @@ class DataType(Enum):
114114
NONE = 4
115115

116116

117-
def merge_dtypes(dtypes: typing.List[DataType]):
117+
def merge_dtypes(dtypes: list[DataType]):
118118
"""Promote dtype to SCALAR or REAL if either argument matches."""
119119
if DataType.NONE in dtypes:
120120
raise ValueError(f"Invalid DataType in LNodes {dtypes}")
@@ -865,11 +865,11 @@ class Section(LNode):
865865
def __init__(
866866
self,
867867
name: str,
868-
statements: List[LNode],
868+
statements: list[LNode],
869869
declarations: Sequence[Declaration],
870-
input: Optional[List[Symbol]] = None,
871-
output: Optional[List[Symbol]] = None,
872-
annotations: Optional[List[Annotation]] = None,
870+
input: Optional[list[Symbol]] = None,
871+
output: Optional[list[Symbol]] = None,
872+
annotations: Optional[list[Annotation]] = None,
873873
):
874874
"""Initialise."""
875875
self.name = name
@@ -1127,7 +1127,7 @@ def ufl_to_lnodes(operator, *args):
11271127
raise RuntimeError(f"Missing lookup for expr type {optype}.")
11281128

11291129

1130-
def create_nested_for_loops(indices: List[MultiIndex], body):
1130+
def create_nested_for_loops(indices: list[MultiIndex], body):
11311131
"""Create nested for loops over list of indices.
11321132
11331133
The depth of the nested for loops is equal to the sub-indices for all

ffcx/codegeneration/optimizer.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""Optimizer."""
22
from collections import defaultdict
3-
from typing import List, Union
3+
from typing import Union
44

55
import ffcx.codegeneration.lnodes as L
66
from ffcx.ir.representationutils import QuadratureRule
77

88

9-
def optimize(code: List[L.LNode], quadrature_rule: QuadratureRule) -> List[L.LNode]:
9+
def optimize(code: list[L.LNode], quadrature_rule: QuadratureRule) -> list[L.LNode]:
1010
"""Optimize code.
1111
1212
Args:
@@ -30,7 +30,7 @@ def optimize(code: List[L.LNode], quadrature_rule: QuadratureRule) -> List[L.LNo
3030
return code
3131

3232

33-
def fuse_sections(code: List[L.LNode], name) -> List[L.LNode]:
33+
def fuse_sections(code: list[L.LNode], name) -> list[L.LNode]:
3434
"""Fuse sections with the same name.
3535
3636
Args:
@@ -40,12 +40,12 @@ def fuse_sections(code: List[L.LNode], name) -> List[L.LNode]:
4040
Returns:
4141
Fused list of LNodes.
4242
"""
43-
statements: List[L.LNode] = []
44-
indices: List[int] = []
45-
input: List[L.Symbol] = []
46-
output: List[L.Symbol] = []
47-
declarations: List[L.Declaration] = []
48-
annotations: List[L.Annotation] = []
43+
statements: list[L.LNode] = []
44+
indices: list[int] = []
45+
input: list[L.Symbol] = []
46+
output: list[L.Symbol] = []
47+
declarations: list[L.Declaration] = []
48+
annotations: list[L.Annotation] = []
4949

5050
for i, section in enumerate(code):
5151
if isinstance(section, L.Section):
@@ -98,7 +98,7 @@ def fuse_loops(code: L.Section) -> L.Section:
9898
return L.Section(code.name, output_code, code.declarations, code.input, code.output)
9999

100100

101-
def get_statements(statement: Union[L.Statement, L.StatementList]) -> List[L.LNode]:
101+
def get_statements(statement: Union[L.Statement, L.StatementList]) -> list[L.LNode]:
102102
"""Get statements from a statement list.
103103
104104
Args:
@@ -177,7 +177,7 @@ def licm(section: L.Section, quadrature_rule: QuadratureRule) -> L.Section:
177177
assert isinstance(lhs, L.ArrayAccess) # Expecting ArrayAccess
178178
expressions[lhs].append(rhs)
179179

180-
pre_loop: List[L.LNode] = []
180+
pre_loop: list[L.LNode] = []
181181
for lhs, rhs in expressions.items():
182182
for r in rhs:
183183
hoist_candidates = []

ffcx/compiler.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ def _print_timing(stage: int, timing: float):
8080

8181

8282
def compile_ufl_objects(
83-
ufl_objects: typing.List[typing.Any],
84-
object_names: typing.Dict = {},
83+
ufl_objects: list[typing.Any],
84+
object_names: dict = {},
8585
prefix: typing.Optional[str] = None,
86-
options: typing.Dict = {},
86+
options: dict = {},
8787
visualise: bool = False,
8888
):
8989
"""Generate UFC code for a given UFL objects.

ffcx/element_interface.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,20 @@
55
# SPDX-License-Identifier: LGPL-3.0-or-later
66
"""Finite element interface."""
77

8-
import typing
9-
108
import basix
119
import basix.ufl
1210
import numpy as np
1311
import numpy.typing as npt
1412

1513

16-
def basix_index(indices: typing.Tuple[int]) -> int:
14+
def basix_index(indices: tuple[int]) -> int:
1715
"""Get the Basix index of a derivative."""
1816
return basix.index(*indices)
1917

2018

2119
def create_quadrature(
22-
cellname: str, degree: int, rule: str, elements: typing.List[basix.ufl._ElementBase]
23-
) -> typing.Tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]]:
20+
cellname: str, degree: int, rule: str, elements: list[basix.ufl._ElementBase]
21+
) -> tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]]:
2422
"""Create a quadrature rule."""
2523
if cellname == "vertex":
2624
return (np.ones((1, 0), dtype=np.float64), np.ones(1, dtype=np.float64))

ffcx/ir/analysis/modified_terminals.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def __init__(
3737
reference_value: bool,
3838
base_shape,
3939
base_symmetry,
40-
component: typing.Tuple[int, ...],
40+
component: tuple[int, ...],
4141
flat_component: int,
42-
global_derivatives: typing.Tuple[int, ...],
43-
local_derivatives: typing.Tuple[int, ...],
42+
global_derivatives: tuple[int, ...],
43+
local_derivatives: tuple[int, ...],
4444
averaged: typing.Union[None, str],
4545
restriction: typing.Union[None, str],
4646
):

0 commit comments

Comments
 (0)