Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
havogt committed Dec 5, 2024
1 parent 7c115af commit 38fd60c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/gt4py/next/iterator/embedded.py
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,9 @@ def impl(*iters: ItIterator):


def _dimension_to_tag(domain: Domain) -> dict[Tag, range]:
return {k.value if isinstance(k, common.Dimension) else k: v for k, v in domain.items()}
return type(domain)( # persist kind of domain
**{k.value if isinstance(k, common.Dimension) else k: v for k, v in domain.items()}
)


def _validate_domain(domain: Domain, offset_provider_type: common.OffsetProviderType) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,20 @@ def foo(inp):
dtype=None,
)

I = gtx.Dimension("I")


def test_deduce_domain():
assert isinstance(_deduce_domain({}, {}), CartesianDomain)
assert isinstance(_deduce_domain(UnstructuredDomain(), {}), UnstructuredDomain)
assert isinstance(_deduce_domain({}, {"foo": connectivity}), UnstructuredDomain)
assert isinstance(
_deduce_domain(CartesianDomain([("I", range(1))]), {"foo": connectivity}), CartesianDomain
_deduce_domain(CartesianDomain([(I, range(1))]), {"foo": connectivity}), CartesianDomain
)


I = gtx.Dimension("I")


def test_embedded_error_on_wrong_domain():
dom = CartesianDomain([("I", range(1))])
dom = CartesianDomain([(I, range(1))])

out = gtx.as_field([I], np.zeros(1))
with pytest.raises(RuntimeError, match="expected 'UnstructuredDomain'"):
Expand Down

0 comments on commit 38fd60c

Please sign in to comment.