Skip to content

Commit

Permalink
address review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
havogt committed Sep 13, 2023
1 parent e5b44a1 commit c05bdbb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/gt4py/next/iterator/embedded.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def _make_tuple(
named_indices: NamedFieldIndices,
*,
column_axis: Literal[None] = None,
) -> tuple[tuple | npt.DTypeLike, ...]: # arbitrary nesting
) -> tuple[tuple | npt.DTypeLike | Undefined, ...]: # arbitrary nesting
...


Expand All @@ -724,7 +724,7 @@ def _make_tuple(
named_indices: NamedFieldIndices,
*,
column_axis: Literal[None] = None,
) -> npt.DTypeLike:
) -> npt.DTypeLike | Undefined:
...


Expand All @@ -733,7 +733,7 @@ def _make_tuple(
named_indices: NamedFieldIndices,
*,
column_axis: Optional[Tag] = None,
) -> Column | npt.DTypeLike | tuple[tuple | Column | npt.DTypeLike, ...] | Undefined:
) -> Column | npt.DTypeLike | tuple[tuple | Column | npt.DTypeLike | Undefined, ...] | Undefined:
if column_axis is None:
if isinstance(field_or_tuple, tuple):
return tuple(_make_tuple(f, named_indices) for f in field_or_tuple)
Expand All @@ -753,7 +753,7 @@ def _make_tuple(
try:
col.append(
tuple(
_make_tuple(
_make_tuple( # type: ignore[misc] # TODO(havogt) don't want to waste time now trying to fix the error "Generator has incompatible item type"
f,
_single_vertical_idx(
named_indices, column_axis, i - column_range.start
Expand All @@ -770,7 +770,11 @@ def _make_tuple(
except embedded_exceptions.IndexOutOfBounds:
col.append(_UNDEFINED)

first = next((v for v in col if v != _UNDEFINED))
first = next((v for v in col if v != _UNDEFINED), None)
if first is None:
raise RuntimeError(
"Found 'Undefined' value, this should not happen for a legal program."
)
dtype = _column_dtype(first)
return Column(column_range.start, np.asarray(col, dtype=dtype))

Expand Down
2 changes: 1 addition & 1 deletion tests/next_tests/integration_tests/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
C2E = gtx.FieldOffset("E2V", source=Edge, target=(Cell, C2EDim))

ScalarValue: TypeAlias = np.int32 | np.int64 | np.float32 | np.float64 | np.generic
FieldValue: TypeAlias = gtx.Field # | embedded.LocatedFieldImpl
FieldValue: TypeAlias = gtx.Field
FieldViewArg: TypeAlias = FieldValue | ScalarValue | tuple["FieldViewArg", ...]
FieldViewInout: TypeAlias = FieldValue | tuple["FieldViewInout", ...]
ReferenceValue: TypeAlias = (
Expand Down

0 comments on commit c05bdbb

Please sign in to comment.