2020from ufl .algorithms .domain_analysis import IntegralData , reconstruct_form_from_integral_data
2121from ufl .algorithms .replace import replace
2222from ufl .classes import Argument , Coefficient , FunctionSpace , GeometricFacetQuantity
23- from ufl .coefficient import BaseCoefficient
2423from ufl .corealg .traversal import traverse_unique_terminals
25- from ufl .domain import MeshSequence , extract_domains , extract_unique_domain
24+ from ufl .domain import AbstractDomain , MeshSequence , extract_domains , extract_unique_domain
2625from ufl .form import Form , Zero
2726from ufl .utils .formatting import estr , lstr , tstr
2827from ufl .utils .sequences import max_degree
@@ -99,7 +98,7 @@ def _compute_element_mapping(form: Form):
9998
10099def _compute_max_subdomain_ids (integral_data : list [IntegralData ]) -> dict [str , int ]:
101100 """Compute the maximum subdomain ids."""
102- max_subdomain_ids = {}
101+ max_subdomain_ids : dict [ str , int ] = {}
103102 for itg_data in integral_data :
104103 it = itg_data .integral_type
105104 for integral in itg_data .integrals :
@@ -141,8 +140,8 @@ def _check_facet_geometry(integral_data):
141140
142141
143142def _build_coefficient_replace_map (
144- coefficients : list [BaseCoefficient ], element_mapping = None
145- ) -> tuple [list [BaseCoefficient ], dict [BaseCoefficient , BaseCoefficient ]]:
143+ coefficients : list [Coefficient ], element_mapping = None
144+ ) -> tuple [list [Coefficient ], dict [Coefficient , Coefficient ]]:
146145 """Create new Coefficient objects with count starting at 0.
147146
148147 Returns:
@@ -175,10 +174,10 @@ class FormData:
175174
176175 _original_form : Form
177176 _integral_data : list [IntegralData ]
178- _reduced_coefficients : list [BaseCoefficient ]
179- _original_coefficient_positions : list [tuple [ int , BaseCoefficient ] ]
180- _function_replace_map : dict [BaseCoefficient , BaseCoefficient ]
181- _coefficient_elements : list [Any ]
177+ _reduced_coefficients : list [Coefficient ]
178+ _original_coefficient_positions : list [int ]
179+ _function_replace_map : dict [Coefficient , Coefficient ]
180+ _coefficient_elements : tuple [Any , ... ]
182181 _coefficient_split : dict [Coefficient , list [Coefficient ]]
183182
184183 def __init__ (
@@ -188,7 +187,7 @@ def __init__(
188187 do_apply_default_restrictions : bool = True ,
189188 do_apply_restrictions : bool = True ,
190189 do_replace_functions : bool = False ,
191- coefficients_to_split : tuple [BaseCoefficient , ...] | None = None ,
190+ coefficients_to_split : tuple [Coefficient , ...] | None = None ,
192191 complex_mode : bool = False ,
193192 ):
194193 """Create form-data for a form that has been processed.
@@ -223,8 +222,9 @@ def __init__(
223222 # Figure out which coefficients from the original form are
224223 # actually used in any integral (Differentiation may reduce the
225224 # set of coefficients w.r.t. the original form)
226- reduced_coefficients_set = set ()
225+ reduced_coefficients_set : set [ Coefficient ] = set ()
227226 for itg_data in self .integral_data :
227+ assert itg_data .integral_coefficients is not None
228228 reduced_coefficients_set .update (itg_data .integral_coefficients )
229229 self ._reduced_coefficients = sorted (reduced_coefficients_set , key = lambda c : c .count ())
230230 self ._original_coefficient_positions = [
@@ -236,6 +236,7 @@ def __init__(
236236 # Store back into integral data which form coefficients are used
237237 # by each integral
238238 for itg_data in self .integral_data :
239+ assert itg_data .integral_coefficients is not None
239240 itg_data .enabled_coefficients = [
240241 bool (coeff in itg_data .integral_coefficients ) for coeff in self .reduced_coefficients
241242 ]
@@ -285,7 +286,7 @@ def __init__(
285286 elem = c .ufl_element ()
286287 coefficient_split [c ] = [
287288 Coefficient (FunctionSpace (m , e ))
288- for m , e in zip (mesh .iterable_like (elem ), elem .sub_elements )
289+ for m , e in zip (mesh .iterable_like (elem ), elem .sub_elements ) # type: ignore
289290 ]
290291 self ._coefficient_split = coefficient_split
291292 coeff_splitter = CoefficientSplitter (self .coefficient_split )
@@ -309,6 +310,7 @@ def __init__(
309310 for _ , integral_type in itg_data .domain_integral_type_map .items ()
310311 ):
311312 continue
313+ default_restrictions : dict [AbstractDomain , str | None ] | None
312314 if do_apply_default_restrictions :
313315 default_restrictions = {
314316 domain : default_restriction_map [integral_type ]
@@ -412,12 +414,12 @@ def max_subdomain_ids(self) -> dict[str, int]:
412414 return _compute_max_subdomain_ids (self .integral_data )
413415
414416 @cached_property
415- def argument_elements (self ) -> list [Any ]:
417+ def argument_elements (self ) -> tuple [Any ]:
416418 """The set of elements the arguments in the form."""
417419 return tuple (f .ufl_element () for f in self .original_form .arguments ())
418420
419421 @property
420- def coefficient_elements (self ) -> list [Any ]:
422+ def coefficient_elements (self ) -> tuple [Any ]:
421423 """The set of elements used for coefficients in the form."""
422424 return self ._coefficient_elements
423425
0 commit comments