Skip to content

Commit

Permalink
resolved some pre-commit errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nfarabullini committed Dec 13, 2023
1 parent f815712 commit 67f8117
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/gt4py/next/embedded/nd_array_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class NdArrayConnectivityField( # type: ignore[misc] # for __ne__, __eq__
common.ConnectivityField[common.DimsT, common.DimT],
NdArrayField[common.DimsT, core_defs.IntegralScalar],
):
_codomain: common.DimT
_codomain: common.DimT | fbuiltins.FieldOffset

@functools.cached_property
def _cache(self) -> dict:
Expand All @@ -337,7 +337,7 @@ def __gt_builtin_func__(cls, _: fbuiltins.BuiltInFunction) -> Never: # type: ig

@property
# type: ignore[override] # TODO(havogt): instead of inheriting from NdArrayField, steal implementation or common base
def codomain(self) -> common.DimT:
def codomain(self) -> common.DimT | fbuiltins.FieldOffset:
return self._codomain

@functools.cached_property
Expand All @@ -346,7 +346,11 @@ def kind(self) -> common.ConnectivityKind:
if self.domain.ndim > 1:
kind |= common.ConnectivityKind.MODIFY_RANK
kind |= common.ConnectivityKind.MODIFY_DIMS
if self.domain.dim_index(self.codomain) is None:
if isinstance(self.codomain, fbuiltins.FieldOffset):
codomain_new = self.codomain.source
else:
codomain_new = self.codomain
if self.domain.dim_index(codomain_new) is None:
kind |= common.ConnectivityKind.MODIFY_DIMS

return kind
Expand All @@ -356,7 +360,7 @@ def from_array( # type: ignore[override]
cls,
data: npt.ArrayLike | core_defs.NDArrayObject,
/,
codomain: common.DimT,
codomain: common.DimT | fbuiltins.FieldOffset,
*,
domain: common.DomainLike,
dtype: Optional[core_defs.DTypeLike] = None,
Expand Down Expand Up @@ -618,7 +622,7 @@ def _as_offset(offset_: fbuiltins.FieldOffset, field: common.Field) -> NdArrayCo
)


NdArrayField.register_builtin_func(experimental.as_offset, _as_offset)
NdArrayField.register_builtin_func(experimental.as_offset, _as_offset) # type: ignore[has-type] #type specified in experimental


def _get_slices_from_domain_slice(
Expand Down

0 comments on commit 67f8117

Please sign in to comment.