Skip to content

Commit b43a1d0

Browse files
committed
[bug] restrict ArrayCoord to only array of arrays
1 parent 06f842c commit b43a1d0

2 files changed

Lines changed: 27 additions & 21 deletions

File tree

JData_specification.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -644,17 +644,23 @@ Here, the array annotation keywords are defined below:
644644
must be in the form `[["label_1", column_start_1, column_width_1], ["label_2", column_start_2, ...]]`,
645645
where optional integers `column_start_i` and `column_width_i` define the start and width, respectively,
646646
of the array indices that are associated with this label.
647-
* **`"_ArrayCoords_"`**: (optional) a structure mapping each dimension name (as defined in
648-
`"_ArrayLabel_"`) to a 1-D coordinate array of the same length as the corresponding
649-
dimension. This mirrors the coordinate-variable model used by xarray and NetCDF,
650-
enabling direct round-trip conversion with those formats. Each coordinate array may
651-
itself be an annotated JData array (a structure with `"_ArrayType_"` etc.) to preserve
652-
binary type information. For example:
647+
* **`"_ArrayCoords_"`**: (optional) a 1-D JSON array whose length equals the length of
648+
`"_ArrayLabel_"` (which must be present when `"_ArrayCoords_"` is used). Element `i`
649+
is the coordinate vector for the `i`-th dimension (in `"_ArrayLabel_"` order) and must
650+
have a length equal to `"_ArraySize_"[i]`. Each element may be either:
651+
1. a plain 1-D JSON array of numeric or string values; or
652+
2. an annotated JData array object (with `"_ArrayType_"`, `"_ArraySize_"`, etc.).
653+
When `"_ArrayShape_":"range"` is used, `"_ArrayData_"` must be a 2-element vector
654+
`[start, end]` (inclusive on both ends) and `"_ArraySize_"` must equal the
655+
dimension size.
656+
657+
For example:
653658
```
654-
"_ArrayCoords_": {
655-
"x": [0.0, 0.5, 1.0, 1.5, 2.0],
656-
"t": ["2024-01-01", "2024-01-02", "2024-01-03"]
657-
}
659+
"_ArrayLabel_": ["x", "t"],
660+
"_ArrayCoords_": [
661+
[0.0, 0.5, 1.0, 1.5, 2.0],
662+
["2024-01-01", "2024-01-02", "2024-01-03"]
663+
]
658664
```
659665
* **`"_ArrayUnits_"`**: (optional) a single string, or a 1-D array of strings with length
660666
equal to the number of dimensions (i.e., `length(_ArraySize_)`). Each string specifies
@@ -1211,12 +1217,12 @@ For example, the above table can be serialized using the below format
12111217
```
12121218
{
12131219
"_TableCols_": ["Name", "Age", "Degree", "Height"],
1214-
"_TableRows_": [],
1215-
"_TableRecords_": [
1216-
["Andy", 21, "BS", 69.2],
1217-
["William", 21, "MS", 71.0],
1218-
["Om", 22, "BS", 67.1]
1219-
]
1220+
"_TableRows_": [],
1221+
"_TableRecords_": [
1222+
["Andy", 21, "BS", 69.2],
1223+
["William", 21, "MS", 71.0],
1224+
["Om", 22, "BS", 67.1]
1225+
]
12201226
}
12211227
```
12221228

schema/jdata_format_schema.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,9 @@
325325
}
326326
},
327327
"_ArrayCoords_": {
328-
"type": "object",
329-
"description": "Maps each dimension name (as defined in _ArrayLabel_) to a 1-D coordinate array of the same length as that dimension. Mirrors the coordinate-variable model of xarray and NetCDF.",
330-
"additionalProperties": {
328+
"type": "array",
329+
"description": "Positional coordinate array, one element per dimension in _ArrayLabel_ order (requires _ArrayLabel_). Each element's length must equal the corresponding _ArraySize_ entry. Elements may be plain 1-D arrays or annotated JData array objects; when _ArrayShape_:\"range\" is used, _ArrayData_ must be a 2-element [start, end] vector and _ArraySize_ must equal the dimension size.",
330+
"items": {
331331
"oneOf": [
332332
{
333333
"type": "array",
@@ -383,7 +383,7 @@
383383
"minimum": 1
384384
},
385385
"minItems": 1,
386-
"description": "Tile (chunk) shape for partitioning the pre-processed array into independently compressible blocks. Length must equal the number of dimensions of the pre-processed array. When present, _ArrayData_ or _ArrayZipData_ becomes a 1-D array of per-chunk payloads in row-major order. The last chunk along any dimension may be smaller than the declared shape. _ArrayZipSize_ must also be present and stores the shape of the full pre-processed array (not the chunk shape)."
386+
"description": "Tile (chunk) shape for partitioning an array into independently compressible blocks. Two modes depending on array type: (1) Dense real/complex arrays: _ArrayChunks_ is in _ArraySize_ (original) order; the decoder computes tile counts as ceil(_ArraySize_ / _ArrayChunks_) and tiles the row-major permuted intermediate. (2) Non-dense arrays (sparse, complex-sparse, shaped, complex-shaped): _ArrayChunks_ is in _ArrayZipSize_ (processed) coordinate space; the decoder computes tile counts as ceil(_ArrayZipSize_ / _ArrayChunks_). When present, _ArrayZipData_ becomes a 1-D array of per-chunk payloads in row-major tile order. The last chunk along any dimension may be smaller than the declared shape."
387387
},
388388
"_ArrayZipType_": {
389389
"type": "string",
@@ -413,7 +413,7 @@
413413
"description": "Total element count of the pre-processed array (scalar shorthand for 1-D case)"
414414
}
415415
],
416-
"description": "Shape of the full pre-processed array before compression. When _ArrayChunks_ is present, this field MUST store the shape of the complete pre-processed array (NOT the chunk shape). The decoder uses ceil(_ArrayZipSize_ / _ArrayChunks_) to determine the number of chunks per dimension and the size of boundary tiles."
416+
"description": "Shape of the full pre-processed array before compression. For dense real arrays: [1, N] where N = total elements. For dense complex arrays: [2, N] where N = total elements. For non-dense arrays (sparse, shaped): the logical 2-D processed-array shape (e.g. [3, K] for a real sparse matrix with K nonzeros). When _ArrayChunks_ is absent, the decoder uses this shape to reconstruct the flat byte stream. When _ArrayChunks_ is present for dense arrays, tile counts are ceil(_ArraySize_ / _ArrayChunks_); for non-dense arrays, tile counts are ceil(_ArrayZipSize_ / _ArrayChunks_)."
417417
},
418418
"_ArrayZipData_": {
419419
"oneOf": [

0 commit comments

Comments
 (0)