diff --git a/hog/operator_generation/indexing.py b/hog/operator_generation/indexing.py index 1680e3942d3a72132392150fc99234f1c487b9b7..218a8fef66eb9cf5dcec11e9494d2bcd92e130ba 100644 --- a/hog/operator_generation/indexing.py +++ b/hog/operator_generation/indexing.py @@ -27,7 +27,7 @@ from hog.symbolizer import Symbolizer from pystencils.integer_functions import int_div from pystencils import TypedSymbol from enum import Enum -from typing import Tuple, List, Union +from typing import Tuple, List, Union, cast import operator import sympy as sp @@ -259,19 +259,20 @@ def linear_macro_cell_index(width: int, x: int, y: int, z: int) -> int: def facedof_index( level: int, - index: Tuple[int, int, int], + # Hack: see issue #46 for details + index: Union[Tuple[int, int], Tuple[int, int, int]], faceType: Union[None, EdgeType, FaceType, CellType], num_microfaces_per_face: sp.Symbol, num_microedges_per_edge: sp.Symbol, ) -> int: """Indexes triangles/faces. Used to compute offsets in volume dof indexing in 2D and AoS layout.""" - # Ugly hack; why do we receive an index with only two entries, - # and why do we expect one with three? + # second part of hack for #46 + # also see https://github.com/python/mypy/issues/1178 if len(index) == 3: - x, y, _ = index - elif len(index) == 2: - x, y = index + x, y, _ = cast(Tuple[int, int, int], index) + else: + x, y = cast(Tuple[int, int], index) # width = num_faces_per_row_by_type(level, faceType) if faceType == FaceType.GRAY: