|
20 | 20 |
|
21 | 21 | import itertools
|
22 | 22 | import logging
|
| 23 | +import sys |
23 | 24 | import typing
|
24 | 25 | import warnings
|
25 | 26 |
|
|
40 | 41 |
|
41 | 42 | def basix_cell_from_string(string: str) -> basix.CellType:
|
42 | 43 | """Convert a string to a Basix CellType."""
|
| 44 | + # Note: vertex -> point, rest identity |
43 | 45 | if string == "vertex":
|
44 | 46 | return basix.CellType.point
|
45 |
| - return getattr(basix.CellType, string) |
| 47 | + elif string == "interval": |
| 48 | + return basix.CellType.interval |
| 49 | + elif string == "triangle": |
| 50 | + return basix.CellType.triangle |
| 51 | + elif string == "tetrahedron": |
| 52 | + return basix.CellType.tetrahedron |
| 53 | + elif string == "quadrilateral": |
| 54 | + return basix.CellType.quadrilateral |
| 55 | + elif string == "hexahedron": |
| 56 | + return basix.CellType.hexahedron |
| 57 | + elif string == "prism": |
| 58 | + return basix.CellType.prism |
| 59 | + elif string == "pyramid": |
| 60 | + return basix.CellType.pyramid |
| 61 | + else: |
| 62 | + raise KeyError(f"Can not map '{string}' to a basix type.") |
| 63 | + |
| 64 | + # TODO: Replace on 31 Oct 2025 with (Python 3.9 does not support match): |
| 65 | + # match string: |
| 66 | + # case "vertex": |
| 67 | + # return basix.CellType.point |
| 68 | + # case "interval": |
| 69 | + # return basix.CellType.interval |
| 70 | + # case "triangle": |
| 71 | + # return basix.CellType.triangle |
| 72 | + # case "tetrahedron": |
| 73 | + # return basix.CellType.tetrahedron |
| 74 | + # case "quadrilateral": |
| 75 | + # return basix.CellType.quadrilateral |
| 76 | + # case "hexahedron": |
| 77 | + # return basix.CellType.hexahedron |
| 78 | + # case "prism": |
| 79 | + # return basix.CellType.prism |
| 80 | + # case "pyramid": |
| 81 | + # return basix.CellType.pyramid |
| 82 | + # case _: |
| 83 | + # raise KeyError(f"Can not map '{string}' to a basix type.") |
46 | 84 |
|
47 | 85 |
|
48 | 86 | class FormIR(typing.NamedTuple):
|
|
0 commit comments