-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Labels
gt4py.cartesianIssues concerning the current version with support only for cartesian grids.Issues concerning the current version with support only for cartesian grids.module: backendRelated to analysis/backend subpackagesRelated to analysis/backend subpackagespriority: lowLow priority taskLow priority tasktriage: enhancementNew feature or requestNew feature or request
Description
Description
We got a false positive user report, which tracked down to the usage of float literals/expression in field offsets. Field offsets are expected to be of integer type. All eve nodes support datamodel validation. We could thus implement consistent checks for all field offsets (CartesianOffset, VariableKOffset) to either be an integer literal or evaluate to an integer expression.
Currently, we have such a datamodel validator for the "K" offset of VariableKOffset
gt4py/src/gt4py/cartesian/gtc/common.py
Lines 322 to 345 in cef9dee
| class CartesianOffset(eve.Node): | |
| i: int | |
| j: int | |
| k: int | |
| @classmethod | |
| def zero(cls) -> CartesianOffset: | |
| return cls(i=0, j=0, k=0) | |
| def to_dict(self) -> Dict[str, int]: | |
| return {"i": self.i, "j": self.j, "k": self.k} | |
| class VariableKOffset(eve.GenericNode, Generic[ExprT]): | |
| k: ExprT | |
| def to_dict(self) -> Dict[str, Optional[int]]: | |
| return {"i": 0, "j": 0, "k": None} | |
| @datamodels.validator("k") | |
| def offset_expr_is_int(self, attribute: datamodels.Attribute, value: Any) -> None: | |
| value = typing.cast(Expr, value) | |
| if value.dtype is not DataType.AUTO and not value.dtype.isinteger(): | |
| raise ValueError("Variable vertical index must be an integer expression") |
This PR suggests to use a similar validator for the members of CartesianOffset.
Metadata
Metadata
Assignees
Labels
gt4py.cartesianIssues concerning the current version with support only for cartesian grids.Issues concerning the current version with support only for cartesian grids.module: backendRelated to analysis/backend subpackagesRelated to analysis/backend subpackagespriority: lowLow priority taskLow priority tasktriage: enhancementNew feature or requestNew feature or request