zarr-metadata 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -6
- package/dist/chunk-grid/index.d.ts +27 -0
- package/dist/chunk-grid/index.d.ts.map +1 -0
- package/dist/chunk-grid/index.js +21 -0
- package/dist/chunk-grid/index.js.map +1 -0
- package/dist/chunk-grid/rectilinear.d.ts +14 -0
- package/dist/chunk-grid/rectilinear.d.ts.map +1 -0
- package/dist/chunk-grid/rectilinear.js +76 -0
- package/dist/chunk-grid/rectilinear.js.map +1 -0
- package/dist/chunk-grid/regular.d.ts +7 -0
- package/dist/chunk-grid/regular.d.ts.map +1 -0
- package/dist/chunk-grid/regular.js +36 -0
- package/dist/chunk-grid/regular.js.map +1 -0
- package/dist/codec/index.d.ts +34 -0
- package/dist/codec/index.d.ts.map +1 -0
- package/dist/codec/index.js +35 -0
- package/dist/codec/index.js.map +1 -0
- package/dist/codec/sharding-indexed.d.ts +26 -0
- package/dist/codec/sharding-indexed.d.ts.map +1 -0
- package/dist/codec/sharding-indexed.js +80 -0
- package/dist/codec/sharding-indexed.js.map +1 -0
- package/dist/codec/transpose.d.ts +19 -0
- package/dist/codec/transpose.d.ts.map +1 -0
- package/dist/codec/transpose.js +66 -0
- package/dist/codec/transpose.js.map +1 -0
- package/dist/data-type/bool.d.ts +4 -0
- package/dist/data-type/bool.d.ts.map +1 -0
- package/dist/data-type/bool.js +7 -0
- package/dist/data-type/bool.js.map +1 -0
- package/dist/data-type/bytes.d.ts +11 -0
- package/dist/data-type/bytes.d.ts.map +1 -0
- package/dist/data-type/bytes.js +18 -0
- package/dist/data-type/bytes.js.map +1 -0
- package/dist/data-type/complex128.d.ts +3 -0
- package/dist/data-type/complex128.d.ts.map +1 -0
- package/dist/data-type/complex128.js +4 -0
- package/dist/data-type/complex128.js.map +1 -0
- package/dist/data-type/complex64.d.ts +3 -0
- package/dist/data-type/complex64.d.ts.map +1 -0
- package/dist/data-type/complex64.js +4 -0
- package/dist/data-type/complex64.js.map +1 -0
- package/dist/data-type/descriptor.d.ts +44 -0
- package/dist/data-type/descriptor.d.ts.map +1 -0
- package/dist/data-type/descriptor.js +57 -0
- package/dist/data-type/descriptor.js.map +1 -0
- package/dist/data-type/float16.d.ts +3 -0
- package/dist/data-type/float16.d.ts.map +1 -0
- package/dist/data-type/float16.js +4 -0
- package/dist/data-type/float16.js.map +1 -0
- package/dist/data-type/float32.d.ts +3 -0
- package/dist/data-type/float32.d.ts.map +1 -0
- package/dist/data-type/float32.js +4 -0
- package/dist/data-type/float32.js.map +1 -0
- package/dist/data-type/float64.d.ts +3 -0
- package/dist/data-type/float64.d.ts.map +1 -0
- package/dist/data-type/float64.js +4 -0
- package/dist/data-type/float64.js.map +1 -0
- package/dist/data-type/index.d.ts +23 -0
- package/dist/data-type/index.d.ts.map +1 -0
- package/dist/data-type/index.js +92 -0
- package/dist/data-type/index.js.map +1 -0
- package/dist/data-type/int16.d.ts +3 -0
- package/dist/data-type/int16.d.ts.map +1 -0
- package/dist/data-type/int16.js +4 -0
- package/dist/data-type/int16.js.map +1 -0
- package/dist/data-type/int32.d.ts +3 -0
- package/dist/data-type/int32.d.ts.map +1 -0
- package/dist/data-type/int32.js +4 -0
- package/dist/data-type/int32.js.map +1 -0
- package/dist/data-type/int64.d.ts +3 -0
- package/dist/data-type/int64.d.ts.map +1 -0
- package/dist/data-type/int64.js +4 -0
- package/dist/data-type/int64.js.map +1 -0
- package/dist/data-type/int8.d.ts +3 -0
- package/dist/data-type/int8.d.ts.map +1 -0
- package/dist/data-type/int8.js +4 -0
- package/dist/data-type/int8.js.map +1 -0
- package/dist/data-type/numpy-datetime64.d.ts +18 -0
- package/dist/data-type/numpy-datetime64.d.ts.map +1 -0
- package/dist/data-type/numpy-datetime64.js +14 -0
- package/dist/data-type/numpy-datetime64.js.map +1 -0
- package/dist/data-type/numpy-timedelta64.d.ts +4 -0
- package/dist/data-type/numpy-timedelta64.d.ts.map +1 -0
- package/dist/data-type/numpy-timedelta64.js +4 -0
- package/dist/data-type/numpy-timedelta64.js.map +1 -0
- package/dist/data-type/raw.d.ts +10 -0
- package/dist/data-type/raw.d.ts.map +1 -0
- package/dist/data-type/raw.js +26 -0
- package/dist/data-type/raw.js.map +1 -0
- package/dist/data-type/string.d.ts +6 -0
- package/dist/data-type/string.d.ts.map +1 -0
- package/dist/data-type/string.js +7 -0
- package/dist/data-type/string.js.map +1 -0
- package/dist/data-type/struct.d.ts +17 -0
- package/dist/data-type/struct.d.ts.map +1 -0
- package/dist/data-type/struct.js +44 -0
- package/dist/data-type/struct.js.map +1 -0
- package/dist/data-type/uint16.d.ts +3 -0
- package/dist/data-type/uint16.d.ts.map +1 -0
- package/dist/data-type/uint16.js +4 -0
- package/dist/data-type/uint16.js.map +1 -0
- package/dist/data-type/uint32.d.ts +3 -0
- package/dist/data-type/uint32.d.ts.map +1 -0
- package/dist/data-type/uint32.js +4 -0
- package/dist/data-type/uint32.js.map +1 -0
- package/dist/data-type/uint64.d.ts +3 -0
- package/dist/data-type/uint64.d.ts.map +1 -0
- package/dist/data-type/uint64.js +4 -0
- package/dist/data-type/uint64.js.map +1 -0
- package/dist/data-type/uint8.d.ts +3 -0
- package/dist/data-type/uint8.d.ts.map +1 -0
- package/dist/data-type/uint8.js +4 -0
- package/dist/data-type/uint8.js.map +1 -0
- package/dist/guards.d.ts +21 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +39 -0
- package/dist/guards.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/semantics.d.ts +14 -42
- package/dist/semantics.d.ts.map +1 -1
- package/dist/semantics.js +22 -416
- package/dist/semantics.js.map +1 -1
- package/package.json +4 -2
- package/src/chunk-grid/index.ts +40 -0
- package/src/chunk-grid/rectilinear.ts +88 -0
- package/src/chunk-grid/regular.ts +42 -0
- package/src/codec/index.ts +76 -0
- package/src/codec/sharding-indexed.ts +113 -0
- package/src/codec/transpose.ts +80 -0
- package/src/data-type/bool.ts +8 -0
- package/src/data-type/bytes.ts +26 -0
- package/src/data-type/complex128.ts +4 -0
- package/src/data-type/complex64.ts +4 -0
- package/src/data-type/descriptor.ts +115 -0
- package/src/data-type/float16.ts +4 -0
- package/src/data-type/float32.ts +4 -0
- package/src/data-type/float64.ts +4 -0
- package/src/data-type/index.ts +129 -0
- package/src/data-type/int16.ts +4 -0
- package/src/data-type/int32.ts +4 -0
- package/src/data-type/int64.ts +4 -0
- package/src/data-type/int8.ts +4 -0
- package/src/data-type/numpy-datetime64.ts +33 -0
- package/src/data-type/numpy-timedelta64.ts +9 -0
- package/src/data-type/raw.ts +31 -0
- package/src/data-type/string.ts +11 -0
- package/src/data-type/struct.ts +55 -0
- package/src/data-type/uint16.ts +4 -0
- package/src/data-type/uint32.ts +4 -0
- package/src/data-type/uint64.ts +4 -0
- package/src/data-type/uint8.ts +4 -0
- package/src/guards.ts +48 -0
- package/src/index.ts +22 -0
- package/src/semantics.ts +24 -444
package/README.md
CHANGED
|
@@ -78,18 +78,25 @@ format the conformance corpus asserts on.
|
|
|
78
78
|
|
|
79
79
|
The structural validators check key presence, value shapes, and fixed
|
|
80
80
|
literals without interpreting extension points, matching the Python
|
|
81
|
-
package's layering. `
|
|
82
|
-
TS-only
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
package's layering. The semantic layer (`validateSemanticsV3` /
|
|
82
|
+
`validateArraySemanticsV3`) is TS-only and sits on top, organized by
|
|
83
|
+
content: `chunk-grid/`, `codec/`, and `data-type/` hold one module per
|
|
84
|
+
interpreted name, each with its syntax (configuration and fill-value
|
|
85
|
+
types) and semantics (required members, cross-field prose rules — grid
|
|
86
|
+
arity and sums, transpose permutations, sharding divisibility, fill_value
|
|
87
|
+
vs data type). Interpreted data types cover the core scalars, the `r<N>`
|
|
88
|
+
raw-bits family, and the established zarr-extensions conventions —
|
|
89
|
+
`string`, `bytes`, `numpy.datetime64`/`timedelta64`, and `struct` (whose
|
|
90
|
+
fill is judged per field, recursively). `semantics.ts` is the
|
|
91
|
+
document-walking orchestrator. Unrecognized names are skipped — the
|
|
92
|
+
extension name space is open.
|
|
86
93
|
|
|
87
94
|
Consumers include the
|
|
88
95
|
[Zarr Metadata VS Code extension](https://github.com/d-v-b/vscode-zarr).
|
|
89
96
|
|
|
90
97
|
## How correctness is maintained
|
|
91
98
|
|
|
92
|
-
The [conformance corpus](conformance
|
|
99
|
+
The [conformance corpus](https://github.com/d-v-b/zarr-metadata.js/tree/main/conformance) is the contract with the Python
|
|
93
100
|
reference implementation: shared JSON fixtures asserting the exact problem
|
|
94
101
|
set (loc + kind) each document must produce. Both test suites run every
|
|
95
102
|
case; a spec change updates the corpus first, turning both implementations
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chunk grids this package interprets, one module per grid, assembled
|
|
3
|
+
* into the dispatch the semantic layer uses. The structural document layer
|
|
4
|
+
* never reads these modules — extension points are uninterpreted there by
|
|
5
|
+
* spec design.
|
|
6
|
+
*/
|
|
7
|
+
import type { PathedIssue } from "../errors.js";
|
|
8
|
+
export type { RegularChunkGridConfiguration } from "./regular.js";
|
|
9
|
+
export type { RectilinearChunkGridConfiguration, RectilinearDimSpec } from "./rectilinear.js";
|
|
10
|
+
/** What interpreting a chunk grid yields for the rest of the semantic layer. */
|
|
11
|
+
export interface ChunkGridVerdict {
|
|
12
|
+
/** Issues, pathed relative to the `chunk_grid` field. */
|
|
13
|
+
issues: PathedIssue[];
|
|
14
|
+
/**
|
|
15
|
+
* Distinct chunk lengths per dimension — the division context a
|
|
16
|
+
* sharding codec's inner chunks must satisfy — when derivable.
|
|
17
|
+
*/
|
|
18
|
+
chunkSizes: number[][] | undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Interpret a document's `chunk_grid` field: required members, cross-field
|
|
22
|
+
* rules against `shape`, and the division context for codec pipelines.
|
|
23
|
+
* Unrecognized grid names yield no issues and no context — the extension
|
|
24
|
+
* name space is open.
|
|
25
|
+
*/
|
|
26
|
+
export declare function chunkGridVerdict(rawGrid: unknown, shape: number[] | undefined): ChunkGridVerdict;
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/chunk-grid/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKhD,YAAY,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAClE,YAAY,EAAE,iCAAiC,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE9F,gFAAgF;AAChF,MAAM,WAAW,gBAAgB;IAC/B,yDAAyD;IACzD,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB;;;OAGG;IACH,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,SAAS,CAAC;CACpC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,gBAAgB,CAQhG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { fieldParts, isPlainObject } from "../guards.js";
|
|
2
|
+
import { regularIssues } from "./regular.js";
|
|
3
|
+
import { rectilinearIssues } from "./rectilinear.js";
|
|
4
|
+
/**
|
|
5
|
+
* Interpret a document's `chunk_grid` field: required members, cross-field
|
|
6
|
+
* rules against `shape`, and the division context for codec pipelines.
|
|
7
|
+
* Unrecognized grid names yield no issues and no context — the extension
|
|
8
|
+
* name space is open.
|
|
9
|
+
*/
|
|
10
|
+
export function chunkGridVerdict(rawGrid, shape) {
|
|
11
|
+
if (!isPlainObject(rawGrid) && typeof rawGrid !== "string") {
|
|
12
|
+
return { issues: [], chunkSizes: undefined }; // structural layer's problem
|
|
13
|
+
}
|
|
14
|
+
const name = fieldParts(rawGrid)?.name;
|
|
15
|
+
if (name === "regular")
|
|
16
|
+
return regularIssues(rawGrid, shape);
|
|
17
|
+
if (name === "rectilinear")
|
|
18
|
+
return rectilinearIssues(rawGrid, shape);
|
|
19
|
+
return { issues: [], chunkSizes: undefined };
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/chunk-grid/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAgBrD;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgB,EAAE,KAA2B;IAC5E,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC3D,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,6BAA6B;IAC7E,CAAC;IACD,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;IACvC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7D,IAAI,IAAI,KAAK,aAAa;QAAE,OAAO,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACrE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ChunkGridVerdict } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* One dimension's spec in a rectilinear grid: a bare integer (uniform
|
|
4
|
+
* shorthand, no sum constraint) or a list of chunk sizes and
|
|
5
|
+
* `[size, count]` run-length pairs that must sum to the dimension length.
|
|
6
|
+
*/
|
|
7
|
+
export type RectilinearDimSpec = number | Array<number | [number, number]>;
|
|
8
|
+
/** Configuration of the zarr-extensions `rectilinear` chunk grid. */
|
|
9
|
+
export interface RectilinearChunkGridConfiguration {
|
|
10
|
+
kind: "inline";
|
|
11
|
+
chunk_shapes: RectilinearDimSpec[];
|
|
12
|
+
}
|
|
13
|
+
export declare function rectilinearIssues(rawGrid: unknown, shape: number[] | undefined): ChunkGridVerdict;
|
|
14
|
+
//# sourceMappingURL=rectilinear.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rectilinear.d.ts","sourceRoot":"","sources":["../../src/chunk-grid/rectilinear.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE3E,qEAAqE;AACrE,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,EAAE,kBAAkB,EAAE,CAAC;CACpC;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,gBAAgB,CAqEjG"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { configurationMissing, fieldParts } from "../guards.js";
|
|
2
|
+
export function rectilinearIssues(rawGrid, shape) {
|
|
3
|
+
const issues = [];
|
|
4
|
+
let chunkSizes;
|
|
5
|
+
const configuration = fieldParts(rawGrid)?.configuration;
|
|
6
|
+
if (configurationMissing(rawGrid)) {
|
|
7
|
+
issues.push({
|
|
8
|
+
path: [],
|
|
9
|
+
message: '"rectilinear" requires a configuration with "kind" and "chunk_shapes"',
|
|
10
|
+
kind: "missing_key",
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
else if (configuration !== undefined) {
|
|
14
|
+
for (const key of ["kind", "chunk_shapes"]) {
|
|
15
|
+
if (!Object.hasOwn(configuration, key)) {
|
|
16
|
+
issues.push({
|
|
17
|
+
path: ["configuration", key],
|
|
18
|
+
message: "missing required key",
|
|
19
|
+
kind: "missing_key",
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const specs = configuration?.["chunk_shapes"];
|
|
25
|
+
if (Array.isArray(specs)) {
|
|
26
|
+
if (shape !== undefined && specs.length !== shape.length) {
|
|
27
|
+
issues.push({
|
|
28
|
+
path: ["configuration", "chunk_shapes"],
|
|
29
|
+
message: `expected one entry per dimension of shape (${shape.length})`,
|
|
30
|
+
kind: "invalid_value",
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const perDim = specs.map((spec, dim) => {
|
|
35
|
+
// Bare integer: uniform shorthand, no sum constraint (edge chunks
|
|
36
|
+
// are permitted, as with the regular grid).
|
|
37
|
+
if (Number.isInteger(spec))
|
|
38
|
+
return spec > 0 ? [spec] : undefined;
|
|
39
|
+
if (!Array.isArray(spec))
|
|
40
|
+
return undefined; // registry schema's problem
|
|
41
|
+
const sizes = new Set();
|
|
42
|
+
let total = 0;
|
|
43
|
+
for (const entry of spec) {
|
|
44
|
+
if (Number.isInteger(entry)) {
|
|
45
|
+
sizes.add(entry);
|
|
46
|
+
total += entry;
|
|
47
|
+
}
|
|
48
|
+
else if (Array.isArray(entry) &&
|
|
49
|
+
entry.length === 2 &&
|
|
50
|
+
Number.isInteger(entry[0]) &&
|
|
51
|
+
Number.isInteger(entry[1])) {
|
|
52
|
+
sizes.add(entry[0]);
|
|
53
|
+
total += entry[0] * entry[1];
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return undefined; // malformed entry: registry schema's problem
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const extent = shape?.[dim];
|
|
60
|
+
if (extent !== undefined && total !== extent) {
|
|
61
|
+
issues.push({
|
|
62
|
+
path: ["configuration", "chunk_shapes", dim],
|
|
63
|
+
message: `expected chunk sizes summing to ${extent} along dimension ${dim}, got ${total}`,
|
|
64
|
+
kind: "invalid_value",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return [...sizes];
|
|
68
|
+
});
|
|
69
|
+
if (perDim.every((sizes) => sizes !== undefined)) {
|
|
70
|
+
chunkSizes = perDim;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return { issues, chunkSizes };
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=rectilinear.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rectilinear.js","sourceRoot":"","sources":["../../src/chunk-grid/rectilinear.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAc,MAAM,cAAc,CAAC;AAgB5E,MAAM,UAAU,iBAAiB,CAAC,OAAgB,EAAE,KAA2B;IAC7E,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,IAAI,UAAkC,CAAC;IACvC,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IACzD,IAAI,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,EAAE;YACR,OAAO,EAAE,uEAAuE;YAChF,IAAI,EAAE,aAAa;SACpB,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QACvC,KAAK,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE,CAAC;gBACvC,MAAM,CAAC,IAAI,CAAC;oBACV,IA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OAAO,CAAC,KAAK,CAAC;wBACpB,KAAK,CAAC,MAAM,KAAK,CAAC;wBAClB,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;wBAC1B,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAC1B,CAAC;wBACD,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAW,CAAC,CAAC;wBAC9B,KAAK,IAAK,KAAK,CAAC,CAAC,CAAY,GAAI,KAAK,CAAC,CAAC,CAAY,CAAC;oBACvD,CAAC;yBAAM,CAAC;wBACN,OAAO,SAAS,CAAC,CAAC,6CAA6C;oBACjE,CAAC;gBACH,CAAC;gBACD,MAAM,MAAM,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;gBAC5B,IAAI,MAAM,KAAK,SAAS,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;oBAC7C,MAAM,CAAC,IAAI,CAAC;wBACV,IAAI,EAAE,CAAC,eAAe,EAAE,cAAc,EAAE,GAAG,CAAC;wBAC5C,OAAO,EAAE,mCAAmC,MAAM,oBAAoB,GAAG,SAAS,KAAK,EAAE;wBACzF,IAAI,EAAE,eAAe;qBACtB,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;YACH,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,EAAE,CAAC;gBACjD,UAAU,GAAG,MAAoB,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ChunkGridVerdict } from "./index.js";
|
|
2
|
+
/** Configuration of the core `regular` chunk grid. */
|
|
3
|
+
export interface RegularChunkGridConfiguration {
|
|
4
|
+
chunk_shape: number[];
|
|
5
|
+
}
|
|
6
|
+
export declare function regularIssues(rawGrid: unknown, shape: number[] | undefined): ChunkGridVerdict;
|
|
7
|
+
//# sourceMappingURL=regular.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regular.d.ts","sourceRoot":"","sources":["../../src/chunk-grid/regular.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,sDAAsD;AACtD,MAAM,WAAW,6BAA6B;IAC5C,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,gBAAgB,CA+B7F"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { configurationMissing, fieldParts, isIntArray } from "../guards.js";
|
|
2
|
+
export function regularIssues(rawGrid, shape) {
|
|
3
|
+
const issues = [];
|
|
4
|
+
let chunkSizes;
|
|
5
|
+
const configuration = fieldParts(rawGrid)?.configuration;
|
|
6
|
+
if (configurationMissing(rawGrid)) {
|
|
7
|
+
issues.push({
|
|
8
|
+
path: [],
|
|
9
|
+
message: '"regular" requires a configuration with "chunk_shape"',
|
|
10
|
+
kind: "missing_key",
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
else if (configuration !== undefined && !Object.hasOwn(configuration, "chunk_shape")) {
|
|
14
|
+
issues.push({
|
|
15
|
+
path: ["configuration", "chunk_shape"],
|
|
16
|
+
message: "missing required key",
|
|
17
|
+
kind: "missing_key",
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const configured = configuration?.["chunk_shape"];
|
|
21
|
+
if (isIntArray(configured)) {
|
|
22
|
+
if (shape !== undefined && configured.length !== shape.length) {
|
|
23
|
+
issues.push({
|
|
24
|
+
path: ["configuration", "chunk_shape"],
|
|
25
|
+
message: `expected one length per dimension of shape (${shape.length})`,
|
|
26
|
+
kind: "invalid_value",
|
|
27
|
+
});
|
|
28
|
+
// wrong arity: unusable as division context
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
chunkSizes = configured.map((length) => [length]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return { issues, chunkSizes };
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=regular.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regular.js","sourceRoot":"","sources":["../../src/chunk-grid/regular.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAQ5E,MAAM,UAAU,aAAa,CAAC,OAAgB,EAAE,KAA2B;IACzE,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,IAAI,UAAkC,CAAC;IACvC,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IACzD,IAAI,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,EAAE;YACR,OAAO,EAAE,uDAAuD;YAChE,IAAI,EAAE,aAAa;SACpB,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,aAAa,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,EAAE,CAAC;QACvF,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,CAAC,eAAe,EAAE,aAAa,CAAC;YACtC,OAAO,EAAE,sBAAsB;YAC/B,IAAI,EAAE,aAAa;SACpB,CAAC,CAAC;IACL,CAAC;IACD,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC,aAAa,CAAC,CAAC;IAClD,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3B,IAAI,KAAK,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;YAC9D,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,CAAC,eAAe,EAAE,aAAa,CAAC;gBACtC,OAAO,EAAE,+CAA+C,KAAK,CAAC,MAAM,GAAG;gBACvE,IAAI,EAAE,eAAe;aACtB,CAAC,CAAC;YACH,4CAA4C;QAC9C,CAAC;aAAM,CAAC;YACN,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The codecs this package interprets, one module per codec, plus the
|
|
3
|
+
* pipeline walker that threads dimensional context between codecs
|
|
4
|
+
* (mirroring zarr-python's chunk-spec threading): a valid transpose
|
|
5
|
+
* permutes the per-dimension chunk sizes for the codecs after it, and any
|
|
6
|
+
* codec this package cannot reason about — `reshape` may change a chunk's
|
|
7
|
+
* rank, and unknown codecs may do anything — invalidates the dimensional
|
|
8
|
+
* context for the rest of the pipeline instead of letting stale
|
|
9
|
+
* array-level facts produce false verdicts.
|
|
10
|
+
*
|
|
11
|
+
* Other codecs' required fields (blosc, gzip, zstd, ...) are deliberately
|
|
12
|
+
* NOT known here: they are registry-schema facts enforced by schema-driven
|
|
13
|
+
* tooling, and a second hardcoded source of truth would drift.
|
|
14
|
+
*/
|
|
15
|
+
import type { PathedIssue } from "../errors.js";
|
|
16
|
+
import { type Path } from "../guards.js";
|
|
17
|
+
export type { ShardingIndexedCodecConfiguration } from "./sharding-indexed.js";
|
|
18
|
+
export type { TransposeCodecConfiguration } from "./transpose.js";
|
|
19
|
+
/** The dimensional facts threaded between the codecs of one pipeline. */
|
|
20
|
+
export interface PipelineContext {
|
|
21
|
+
/** Array dimensionality at this point; undefined when unknowable. */
|
|
22
|
+
dims: number | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Distinct chunk lengths per dimension this pipeline may encode — what a
|
|
25
|
+
* sharding codec's inner chunks must divide. A regular grid contributes
|
|
26
|
+
* one size per dimension; a rectilinear grid may contribute several.
|
|
27
|
+
*/
|
|
28
|
+
chunkSizes: number[][] | undefined;
|
|
29
|
+
}
|
|
30
|
+
/** The spent/unknowable context. */
|
|
31
|
+
export declare const DROPPED: PipelineContext;
|
|
32
|
+
/** Walk one codec pipeline, threading the dimensional context. */
|
|
33
|
+
export declare function pipelineIssues(pipeline: unknown[], path: Path, initialDims: number | undefined, initialChunkSizes: number[][] | undefined): PathedIssue[];
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codec/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAoC,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAI3E,YAAY,EAAE,iCAAiC,EAAE,MAAM,uBAAuB,CAAC;AAC/E,YAAY,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAElE,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB;;;;OAIG;IACH,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,SAAS,CAAC;CACpC;AAED,oCAAoC;AACpC,eAAO,MAAM,OAAO,EAAE,eAA4D,CAAC;AAEnF,kEAAkE;AAClE,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,OAAO,EAAE,EACnB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,iBAAiB,EAAE,MAAM,EAAE,EAAE,GAAG,SAAS,GACxC,WAAW,EAAE,CAgCf"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { configurationMissing, fieldParts } from "../guards.js";
|
|
2
|
+
import { shardingIndexedIssues } from "./sharding-indexed.js";
|
|
3
|
+
import { transposeIssues } from "./transpose.js";
|
|
4
|
+
/** The spent/unknowable context. */
|
|
5
|
+
export const DROPPED = { dims: undefined, chunkSizes: undefined };
|
|
6
|
+
/** Walk one codec pipeline, threading the dimensional context. */
|
|
7
|
+
export function pipelineIssues(pipeline, path, initialDims, initialChunkSizes) {
|
|
8
|
+
const issues = [];
|
|
9
|
+
let context = { dims: initialDims, chunkSizes: initialChunkSizes };
|
|
10
|
+
pipeline.forEach((entry, index) => {
|
|
11
|
+
const parts = fieldParts(entry);
|
|
12
|
+
if (parts === undefined) {
|
|
13
|
+
context = DROPPED; // structurally invalid entry: no further reasoning
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const configMissing = configurationMissing(entry);
|
|
17
|
+
if (parts.name === "transpose") {
|
|
18
|
+
const result = transposeIssues(parts.configuration, configMissing, path, index, context);
|
|
19
|
+
issues.push(...result.issues);
|
|
20
|
+
context = result.context;
|
|
21
|
+
}
|
|
22
|
+
else if (parts.name === "sharding_indexed") {
|
|
23
|
+
const result = shardingIndexedIssues(parts.configuration, configMissing, path, index, context, pipelineIssues);
|
|
24
|
+
issues.push(...result.issues);
|
|
25
|
+
context = result.context;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// A codec this package cannot reason about: stale array-level facts
|
|
29
|
+
// must not judge the codecs after it.
|
|
30
|
+
context = DROPPED;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return issues;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/codec/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAa,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB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GAAG,MAAM,CAAC,OAAO,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,oEAAoE;YACpE,sCAAsC;YACtC,OAAO,GAAG,OAAO,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** The core `sharding_indexed` codec: syntax and semantics. */
|
|
2
|
+
import type { PathedIssue } from "../errors.js";
|
|
3
|
+
import { type Path } from "../guards.js";
|
|
4
|
+
import { type PipelineContext } from "./index.js";
|
|
5
|
+
/** Configuration of the core `sharding_indexed` codec. */
|
|
6
|
+
export interface ShardingIndexedCodecConfiguration {
|
|
7
|
+
chunk_shape: number[];
|
|
8
|
+
codecs: unknown[];
|
|
9
|
+
index_codecs: unknown[];
|
|
10
|
+
index_location?: "start" | "end";
|
|
11
|
+
}
|
|
12
|
+
type Walk = (pipeline: unknown[], path: Path, dims: number | undefined, chunkSizes: number[][] | undefined) => PathedIssue[];
|
|
13
|
+
/**
|
|
14
|
+
* Judge one sharding entry: it requires `chunk_shape`, `codecs`, and
|
|
15
|
+
* `index_codecs`; its chunk_shape must match the array's dimensionality
|
|
16
|
+
* and evenly divide every chunk it shards. The inner pipeline is walked
|
|
17
|
+
* with the shard's own chunk context (`index_codecs` encode the shard
|
|
18
|
+
* index, whose shape differs — no dimensional context applies there), and
|
|
19
|
+
* the array -> bytes boundary spends the context for whatever follows.
|
|
20
|
+
*/
|
|
21
|
+
export declare function shardingIndexedIssues(configuration: Record<string, unknown> | undefined, configMissing: boolean, path: Path, index: number, context: PipelineContext, walk: Walk): {
|
|
22
|
+
issues: PathedIssue[];
|
|
23
|
+
context: PipelineContext;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=sharding-indexed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharding-indexed.d.ts","sourceRoot":"","sources":["../../src/codec/sharding-indexed.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAW,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAE3D,0DAA0D;AAC1D,MAAM,WAAW,iCAAiC;IAChD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,YAAY,EAAE,OAAO,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;CAClC;AAED,KAAK,IAAI,GAAG,CACV,QAAQ,EAAE,OAAO,EAAE,EACnB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,SAAS,KAC/B,WAAW,EAAE,CAAC;AAEnB;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAClD,aAAa,EAAE,OAAO,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,IAAI,GACT;IAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CA6ErD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { isIntArray } from "../guards.js";
|
|
2
|
+
import { DROPPED } from "./index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Judge one sharding entry: it requires `chunk_shape`, `codecs`, and
|
|
5
|
+
* `index_codecs`; its chunk_shape must match the array's dimensionality
|
|
6
|
+
* and evenly divide every chunk it shards. The inner pipeline is walked
|
|
7
|
+
* with the shard's own chunk context (`index_codecs` encode the shard
|
|
8
|
+
* index, whose shape differs — no dimensional context applies there), and
|
|
9
|
+
* the array -> bytes boundary spends the context for whatever follows.
|
|
10
|
+
*/
|
|
11
|
+
export function shardingIndexedIssues(configuration, configMissing, path, index, context, walk) {
|
|
12
|
+
const issues = [];
|
|
13
|
+
if (configMissing) {
|
|
14
|
+
issues.push({
|
|
15
|
+
path: [...path, index],
|
|
16
|
+
message: '"sharding_indexed" requires a configuration with "chunk_shape", "codecs", and "index_codecs"',
|
|
17
|
+
kind: "missing_key",
|
|
18
|
+
});
|
|
19
|
+
return { issues, context: DROPPED };
|
|
20
|
+
}
|
|
21
|
+
if (configuration !== undefined) {
|
|
22
|
+
for (const key of ["chunk_shape", "codecs", "index_codecs"]) {
|
|
23
|
+
if (!Object.hasOwn(configuration, key)) {
|
|
24
|
+
issues.push({
|
|
25
|
+
path: [...path, index, "configuration", key],
|
|
26
|
+
message: "missing required key",
|
|
27
|
+
kind: "missing_key",
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const chunkShape = configuration?.["chunk_shape"];
|
|
33
|
+
if (!isIntArray(chunkShape)) {
|
|
34
|
+
// Still walk a present inner pipeline (entries deserve their own
|
|
35
|
+
// verdicts) before the context becomes unknowable.
|
|
36
|
+
const inner = configuration?.["codecs"];
|
|
37
|
+
if (Array.isArray(inner)) {
|
|
38
|
+
issues.push(...walk(inner, [...path, index, "configuration", "codecs"], undefined, undefined));
|
|
39
|
+
}
|
|
40
|
+
return { issues, context: DROPPED };
|
|
41
|
+
}
|
|
42
|
+
const chunkShapePath = [...path, index, "configuration", "chunk_shape"];
|
|
43
|
+
if (context.dims !== undefined && chunkShape.length !== context.dims) {
|
|
44
|
+
issues.push({
|
|
45
|
+
path: chunkShapePath,
|
|
46
|
+
message: `expected one length per array dimension (${context.dims})`,
|
|
47
|
+
kind: "invalid_value",
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else if (context.chunkSizes !== undefined &&
|
|
51
|
+
chunkShape.length === context.chunkSizes.length &&
|
|
52
|
+
chunkShape.every((length) => length > 0)) {
|
|
53
|
+
let violation;
|
|
54
|
+
context.chunkSizes.forEach((sizes, axis) => {
|
|
55
|
+
if (violation !== undefined)
|
|
56
|
+
return;
|
|
57
|
+
const bad = sizes.find((size) => size % chunkShape[axis] !== 0);
|
|
58
|
+
if (bad !== undefined)
|
|
59
|
+
violation = { axis, size: bad };
|
|
60
|
+
});
|
|
61
|
+
if (violation !== undefined) {
|
|
62
|
+
const { axis, size } = violation;
|
|
63
|
+
const sizesNow = context.chunkSizes;
|
|
64
|
+
const uniform = sizesNow.every((sizes) => sizes.length === 1);
|
|
65
|
+
issues.push({
|
|
66
|
+
path: chunkShapePath,
|
|
67
|
+
message: uniform
|
|
68
|
+
? `expected ${JSON.stringify(chunkShape)} to evenly divide the outer chunk shape ${JSON.stringify(sizesNow.map((sizes) => sizes[0]))}`
|
|
69
|
+
: `expected ${JSON.stringify(chunkShape)} to evenly divide every chunk size of the grid (dimension ${axis} has chunk size ${size})`,
|
|
70
|
+
kind: "invalid_value",
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const inner = configuration?.["codecs"];
|
|
75
|
+
if (Array.isArray(inner)) {
|
|
76
|
+
issues.push(...walk(inner, [...path, index, "configuration", "codecs"], chunkShape.length, chunkShape.map((length) => [length])));
|
|
77
|
+
}
|
|
78
|
+
return { issues, context: DROPPED };
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=sharding-indexed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharding-indexed.js","sourceRoot":"","sources":["../../src/codec/sharding-indexed.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAa,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,EAAwB,MAAM,YAAY,CAAC;AAiB3D;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,aAAkD,EAClD,aAAsB,EACtB,IAAU,EACV,KAAa,EACb,OAAwB,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9D,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,cAAc;gBACpB,OAAO,EAAE,OAAO;oBACd,CAAC,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,2CAA2C,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;oBACtI,CAAC,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,6DAA6D,IAAI,mBAAmB,IAAI,GAAG;gBACrI,IAAI,EAAE,eAAe;aACtB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,CAAC,IAAI,CACT,GAAG,IAAI,CACL,KAAK,EACL,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,CAAC,EAC3C,UAAU,CAAC,MAAM,EACjB,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CACrC,CACF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** The core `transpose` codec: syntax and semantics. */
|
|
2
|
+
import type { PathedIssue } from "../errors.js";
|
|
3
|
+
import { type Path } from "../guards.js";
|
|
4
|
+
import { type PipelineContext } from "./index.js";
|
|
5
|
+
/** Configuration of the core `transpose` codec. */
|
|
6
|
+
export interface TransposeCodecConfiguration {
|
|
7
|
+
order: number[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Judge one transpose entry: it requires a configuration with `order`,
|
|
11
|
+
* which must be a permutation with one entry per array dimension. A sound
|
|
12
|
+
* transpose permutes the context's chunk sizes; an unsound one makes the
|
|
13
|
+
* downstream context unknowable.
|
|
14
|
+
*/
|
|
15
|
+
export declare function transposeIssues(configuration: Record<string, unknown> | undefined, configMissing: boolean, path: Path, index: number, context: PipelineContext): {
|
|
16
|
+
issues: PathedIssue[];
|
|
17
|
+
context: PipelineContext;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=transpose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transpose.d.ts","sourceRoot":"","sources":["../../src/codec/transpose.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAW,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAE3D,mDAAmD;AACnD,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAOD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAClD,aAAa,EAAE,OAAO,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,eAAe,GACvB;IAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAoDrD"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { isIntArray } from "../guards.js";
|
|
2
|
+
import { DROPPED } from "./index.js";
|
|
3
|
+
function isPermutation(order) {
|
|
4
|
+
const seen = new Set(order);
|
|
5
|
+
return seen.size === order.length && order.every((entry) => entry >= 0 && entry < order.length);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Judge one transpose entry: it requires a configuration with `order`,
|
|
9
|
+
* which must be a permutation with one entry per array dimension. A sound
|
|
10
|
+
* transpose permutes the context's chunk sizes; an unsound one makes the
|
|
11
|
+
* downstream context unknowable.
|
|
12
|
+
*/
|
|
13
|
+
export function transposeIssues(configuration, configMissing, path, index, context) {
|
|
14
|
+
const issues = [];
|
|
15
|
+
if (configMissing) {
|
|
16
|
+
issues.push({
|
|
17
|
+
path: [...path, index],
|
|
18
|
+
message: '"transpose" requires a configuration with "order"',
|
|
19
|
+
kind: "missing_key",
|
|
20
|
+
});
|
|
21
|
+
return { issues, context: DROPPED };
|
|
22
|
+
}
|
|
23
|
+
if (configuration !== undefined && !Object.hasOwn(configuration, "order")) {
|
|
24
|
+
issues.push({
|
|
25
|
+
path: [...path, index, "configuration", "order"],
|
|
26
|
+
message: "missing required key",
|
|
27
|
+
kind: "missing_key",
|
|
28
|
+
});
|
|
29
|
+
return { issues, context: DROPPED };
|
|
30
|
+
}
|
|
31
|
+
const order = configuration?.["order"];
|
|
32
|
+
if (!isIntArray(order)) {
|
|
33
|
+
return { issues, context: DROPPED }; // shape errors are the schema layer's
|
|
34
|
+
}
|
|
35
|
+
const orderPath = [...path, index, "configuration", "order"];
|
|
36
|
+
let sound = true;
|
|
37
|
+
if (!isPermutation(order)) {
|
|
38
|
+
sound = false;
|
|
39
|
+
issues.push({
|
|
40
|
+
path: orderPath,
|
|
41
|
+
message: `expected a permutation of the integers 0..${order.length - 1}`,
|
|
42
|
+
kind: "invalid_value",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (context.dims !== undefined && order.length !== context.dims) {
|
|
46
|
+
sound = false;
|
|
47
|
+
issues.push({
|
|
48
|
+
path: orderPath,
|
|
49
|
+
message: `expected one entry per array dimension (${context.dims})`,
|
|
50
|
+
kind: "invalid_value",
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (!sound)
|
|
54
|
+
return { issues, context: DROPPED };
|
|
55
|
+
const sizes = context.chunkSizes;
|
|
56
|
+
return {
|
|
57
|
+
issues,
|
|
58
|
+
context: {
|
|
59
|
+
dims: context.dims,
|
|
60
|
+
chunkSizes: sizes !== undefined && order.length === sizes.length
|
|
61
|
+
? order.map((axis) => sizes[axis])
|
|
62
|
+
: undefined,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=transpose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transpose.js","sourceRoot":"","sources":["../../src/codec/transpose.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAa,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,EAAwB,MAAM,YAAY,CAAC;AAO3D,SAAS,aAAa,CAAC,KAAe;IACpC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AAClG,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,aAAkD,EAClD,aAAsB,EACtB,IAAU,EACV,KAAa,EACb,OAAwB;IAExB,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC;YACtB,OAAO,EAAE,mDAAmD;YAC5D,IAAI,EAAE,aAAa;SACpB,CAAC,CAAC;QACH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IACtC,CAAC;IACD,IAAI,aAAa,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC;QAC1E,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,CAAC,GAAG,IAAI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AE,OAAO,CAAC,IAAI;YAClB,UAAU,EACR,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;gBAClD,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAa,CAAC;gBAC9C,CAAC,CAAC,SAAS;SAChB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bool.d.ts","sourceRoot":"","sources":["../../src/data-type/bool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,iCAAiC;AACjC,eAAO,MAAM,IAAI,EAAE,kBAIlB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { named, simple } from "./descriptor.js";
|
|
2
|
+
/** The core `bool` data type. */
|
|
3
|
+
export const bool = {
|
|
4
|
+
matches: named("bool"),
|
|
5
|
+
fillIssues: (fill) => typeof fill === "boolean" ? [] : simple('expected a boolean fill value for data type "bool"'),
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=bool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bool.js","sourceRoot":"","sources":["../../src/data-type/bool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAA2B,MAAM,iBAAiB,CAAC;AAEzE,iCAAiC;AACjC,MAAM,CAAC,MAAM,IAAI,GAAuB;IACtC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC;IACtB,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CACnB,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,oDAAoD,CAAC;CAChG,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type DataTypeDescriptor } from "./descriptor.js";
|
|
2
|
+
/**
|
|
3
|
+
* Fill value of the `bytes` data type: an array of integers in `[0, 255]`
|
|
4
|
+
* (one per byte) or a standard-alphabet base64 string.
|
|
5
|
+
*/
|
|
6
|
+
export type BytesFillValue = number[] | string;
|
|
7
|
+
/** Whether `value` is standard-alphabet base64 (padded length a multiple of 4). */
|
|
8
|
+
export declare function isBase64(value: string): boolean;
|
|
9
|
+
/** The zarr-extensions `bytes` data type (variable-length raw bytes). */
|
|
10
|
+
export declare const bytes: DataTypeDescriptor;
|
|
11
|
+
//# sourceMappingURL=bytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/data-type/bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEtF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;AAI/C,mFAAmF;AACnF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED,yEAAyE;AACzE,eAAO,MAAM,KAAK,EAAE,kBASnB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { isByteArray, named, simple } from "./descriptor.js";
|
|
2
|
+
const BASE64 = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
3
|
+
/** Whether `value` is standard-alphabet base64 (padded length a multiple of 4). */
|
|
4
|
+
export function isBase64(value) {
|
|
5
|
+
return value.length % 4 === 0 && BASE64.test(value);
|
|
6
|
+
}
|
|
7
|
+
/** The zarr-extensions `bytes` data type (variable-length raw bytes). */
|
|
8
|
+
export const bytes = {
|
|
9
|
+
matches: named("bytes"),
|
|
10
|
+
fillIssues: (fill) => {
|
|
11
|
+
if (isByteArray(fill))
|
|
12
|
+
return [];
|
|
13
|
+
if (typeof fill === "string" && isBase64(fill))
|
|
14
|
+
return [];
|
|
15
|
+
return simple('expected an array of integers in [0, 255] or a base64 string for data type "bytes"');
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../src/data-type/bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAA2B,MAAM,iBAAiB,CAAC;AAQtF,MAAM,MAAM,GAAG,wBAAwB,CAAC;AAExC,mFAAmF;AACnF,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtD,CAAC;AAED,yEAAyE;AACzE,MAAM,CAAC,MAAM,KAAK,GAAuB;IACvC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;IACvB,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE;QACnB,IAAI,WAAW,CAAC,IAAI,CAAC;YAAE,OAAO,EAAE,CAAC;QACjC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO,EAAE,CAAC;QAC1D,OAAO,MAAM,CACX,oFAAoF,CACrF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complex128.d.ts","sourceRoot":"","sources":["../../src/data-type/complex128.ts"],"names":[],"mappings":"AAEA,gEAAgE;AAChE,eAAO,MAAM,UAAU,8CAAoC,CAAC"}
|