Skip to content

Commit 55cf242

Browse files
committed
disallow slicing CartesianConnectivity
1 parent f15783c commit 55cf242

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/gt4py/next/common.py

+4-15
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,6 @@ class NeighborTable(Connectivity, Protocol):
887887
class CartesianConnectivity(ConnectivityField[DimsT, DimT]):
888888
dimension: DimT
889889
offset: int = 0
890-
_cur_index: Optional[core_defs.IntegralScalar] = None
891890

892891
@classmethod
893892
def __gt_builtin_func__(cls, _: fbuiltins.BuiltInFunction) -> Never: # type: ignore[override]
@@ -900,20 +899,12 @@ def ndarray(self) -> Never:
900899
def asnumpy(self) -> Never:
901900
raise NotImplementedError()
902901

903-
def as_scalar(self) -> core_defs.IntegralScalar:
904-
if self.domain.ndim != 0:
905-
raise ValueError(
906-
"'as_scalar' is only valid on 0-dimensional 'Field's, got a {self.domain.ndim}-dimensional 'Field'."
907-
)
908-
assert self._cur_index is not None
909-
return self._cur_index
902+
def as_scalar(self) -> Never:
903+
raise NotImplementedError()
910904

911905
@functools.cached_property
912906
def domain(self) -> Domain:
913-
if self._cur_index is None:
914-
return Domain(dims=(self.dimension,), ranges=(UnitRange.infinite(),))
915-
else:
916-
return Domain()
907+
return Domain(dims=(self.dimension,), ranges=(UnitRange.infinite(),))
917908

918909
@property
919910
def __gt_origin__(self) -> Never:
@@ -962,9 +953,7 @@ def remap(self, index_field: ConnectivityField | fbuiltins.FieldOffset) -> Conne
962953

963954
__call__ = remap
964955

965-
def restrict(self, index: AnyIndexSpec) -> ConnectivityField[DimsT, DimT]:
966-
if is_int_index(index):
967-
return dataclasses.replace(self, _cur_index=index + self.offset)
956+
def restrict(self, index: AnyIndexSpec) -> Never:
968957
raise NotImplementedError() # we could possibly implement with a FunctionField, but we don't have a use-case
969958

970959
__getitem__ = restrict

0 commit comments

Comments
 (0)