@@ -1477,16 +1477,47 @@ def at_write(
1477
1477
with computation (PARALLEL ), interval (...):
1478
1478
global_field .at [1 , 0 , 2 ] = in_field
1479
1479
1480
- parse_definition (data_dims , name = inspect .stack ()[0 ][3 ], module = self .__class__ .__name__ )
1480
+ def ROField_access_as_IJK (
1481
+ out_field : gtscript .Field [gtscript .IJK , np .int32 ],
1482
+ global_field : gtscript .ROField [(np .int32 , (3 , 3 , 3 ))],
1483
+ ):
1484
+ with computation (PARALLEL ), interval (...):
1485
+ out_field = global_field [1 , 0 , 2 ]
1486
+
1487
+ def data_dims_with_at (
1488
+ out_field : gtscript .Field [gtscript .IJK , np .int32 ],
1489
+ global_field : gtscript .Field [(np .int32 , (3 , 3 , 3 ))],
1490
+ ):
1491
+ with computation (PARALLEL ), interval (...):
1492
+ out_field = global_field .at [1 , 0 , 2 ]
1481
1493
1494
+ # Check .at on read with a Field with data dimensions
1495
+ parse_definition (
1496
+ data_dims_with_at , name = inspect .stack ()[0 ][3 ], module = self .__class__ .__name__
1497
+ )
1498
+
1499
+ # Check .at on read
1482
1500
parse_definition (at_read , name = inspect .stack ()[0 ][3 ], module = self .__class__ .__name__ )
1483
1501
1502
+ # Check classic data dimensions are working
1503
+ parse_definition (data_dims , name = inspect .stack ()[0 ][3 ], module = self .__class__ .__name__ )
1504
+
1505
+ # Can't write to the field
1484
1506
with pytest .raises (
1485
1507
gt_frontend .GTScriptSyntaxError ,
1486
1508
match = r".*writing to a ROField \('at' global indexation\) is forbidden.*" ,
1487
1509
):
1488
1510
parse_definition (at_write , name = inspect .stack ()[0 ][3 ], module = self .__class__ .__name__ )
1489
1511
1512
+ # Can't index cartesian style
1513
+ with pytest .raises (
1514
+ gt_frontend .GTScriptSyntaxError ,
1515
+ match = "Incorrect offset specification detected. Found .* but the field has dimensions .* Did you mean .at" ,
1516
+ ):
1517
+ parse_definition (
1518
+ ROField_access_as_IJK , name = inspect .stack ()[0 ][3 ], module = self .__class__ .__name__
1519
+ )
1520
+
1490
1521
1491
1522
class TestNestedWithSyntax :
1492
1523
def test_nested_with (self ):
0 commit comments