Skip to content

Commit

Permalink
include sym_expr as union type and do not try type conversion for uni…
Browse files Browse the repository at this point in the history
…on type objects
  • Loading branch information
emmetfrancis authored Jul 20, 2024
1 parent 0a3a1df commit e168915
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions smart/model_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from enum import Enum
from pprint import pformat
from textwrap import wrap
from typing import Any, List, Optional, Union
from typing import Any, List, Optional, Union, get_origin
import warnings

import dolfin as d
Expand Down Expand Up @@ -399,7 +399,7 @@ def _check_input_type_validity(self):
"Check that the inputs have the same type (or are convertible) to the type hint."
for field in dataclasses.fields(self):
value = getattr(self, field.name)
if field.type == Any:
if field.type == Any or get_origin(field.type) == Union:
continue
elif not isinstance(value, field.type):
try:
Expand Down Expand Up @@ -573,7 +573,7 @@ class Parameter(ObjectInstance):
group: str = ""
notes: str = ""
use_preintegration: bool = False
sym_expr: Any = ""
sym_expr: Union[str, sym.core.Expr] = ""

def to_dict(self):
"""Convert to a dict that can be used to recreate the object."""
Expand Down

0 comments on commit e168915

Please sign in to comment.