zarr-metadata 0.8.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 +11 -7
- 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-grids.js → chunk-grid/rectilinear.js} +3 -60
- 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/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/semantics.d.ts +4 -4
- package/dist/semantics.d.ts.map +1 -1
- package/dist/semantics.js +9 -15
- package/dist/semantics.js.map +1 -1
- package/package.json +4 -2
- package/src/chunk-grid/index.ts +40 -0
- package/src/{chunk-grids.ts → chunk-grid/rectilinear.ts} +5 -75
- 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/index.ts +14 -3
- package/src/semantics.ts +9 -15
- package/dist/chunk-grids.d.ts +0 -40
- package/dist/chunk-grids.d.ts.map +0 -1
- package/dist/chunk-grids.js.map +0 -1
- package/dist/codecs.d.ts +0 -37
- package/dist/codecs.d.ts.map +0 -1
- package/dist/codecs.js +0 -182
- package/dist/codecs.js.map +0 -1
- package/dist/data-types.d.ts +0 -12
- package/dist/data-types.d.ts.map +0 -1
- package/dist/data-types.js +0 -70
- package/dist/data-types.js.map +0 -1
- package/src/codecs.ts +0 -214
- package/src/data-types.ts +0 -81
package/dist/chunk-grids.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The chunk grids this package interprets: syntax (configuration types) and
|
|
3
|
-
* semantics (the spec's prose rules) for `regular` and `rectilinear`, in
|
|
4
|
-
* one place per grid. The structural document layer never reads this
|
|
5
|
-
* module — extension points are uninterpreted there by spec design.
|
|
6
|
-
*/
|
|
7
|
-
import type { PathedIssue } from "./errors.js";
|
|
8
|
-
/** Configuration of the core `regular` chunk grid. */
|
|
9
|
-
export interface RegularChunkGridConfiguration {
|
|
10
|
-
chunk_shape: number[];
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* One dimension's spec in a rectilinear grid: a bare integer (uniform
|
|
14
|
-
* shorthand, no sum constraint) or a list of chunk sizes and
|
|
15
|
-
* `[size, count]` run-length pairs that must sum to the dimension length.
|
|
16
|
-
*/
|
|
17
|
-
export type RectilinearDimSpec = number | Array<number | [number, number]>;
|
|
18
|
-
/** Configuration of the zarr-extensions `rectilinear` chunk grid. */
|
|
19
|
-
export interface RectilinearChunkGridConfiguration {
|
|
20
|
-
kind: "inline";
|
|
21
|
-
chunk_shapes: RectilinearDimSpec[];
|
|
22
|
-
}
|
|
23
|
-
/** What interpreting a chunk grid yields for the rest of the semantic layer. */
|
|
24
|
-
export interface ChunkGridVerdict {
|
|
25
|
-
/** Issues, pathed relative to the `chunk_grid` field. */
|
|
26
|
-
issues: PathedIssue[];
|
|
27
|
-
/**
|
|
28
|
-
* Distinct chunk lengths per dimension — the division context a
|
|
29
|
-
* sharding codec's inner chunks must satisfy — when derivable.
|
|
30
|
-
*/
|
|
31
|
-
chunkSizes: number[][] | undefined;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Interpret a document's `chunk_grid` field: required members, cross-field
|
|
35
|
-
* rules against `shape`, and the division context for codec pipelines.
|
|
36
|
-
* Unrecognized grid names yield no issues and no context — the extension
|
|
37
|
-
* name space is open.
|
|
38
|
-
*/
|
|
39
|
-
export declare function chunkGridVerdict(rawGrid: unknown, shape: number[] | undefined): ChunkGridVerdict;
|
|
40
|
-
//# sourceMappingURL=chunk-grids.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-grids.d.ts","sourceRoot":"","sources":["../src/chunk-grids.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,sDAAsD;AACtD,MAAM,WAAW,6BAA6B;IAC5C,WAAW,EAAE,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AU,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"}
|
package/dist/codecs.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The codecs this package interprets — `transpose` and `sharding_indexed` —
|
|
3
|
-
* syntax (configuration types) and semantics together, plus the pipeline
|
|
4
|
-
* walker that threads dimensional context between codecs (mirroring
|
|
5
|
-
* zarr-python's chunk-spec threading): a valid transpose permutes the
|
|
6
|
-
* per-dimension chunk sizes for the codecs after it, and any codec this
|
|
7
|
-
* module cannot reason about — `reshape` may change a chunk's rank, and
|
|
8
|
-
* unknown codecs may do anything — invalidates the dimensional context for
|
|
9
|
-
* the rest of the pipeline instead of letting stale array-level facts
|
|
10
|
-
* produce false verdicts.
|
|
11
|
-
*
|
|
12
|
-
* Other codecs' required fields (blosc, gzip, zstd, ...) are deliberately
|
|
13
|
-
* NOT known here: they are registry-schema facts enforced by schema-driven
|
|
14
|
-
* tooling, and a second hardcoded source of truth would drift.
|
|
15
|
-
*/
|
|
16
|
-
import type { PathedIssue } from "./errors.js";
|
|
17
|
-
import { type Path } from "./guards.js";
|
|
18
|
-
/** Configuration of the core `transpose` codec. */
|
|
19
|
-
export interface TransposeCodecConfiguration {
|
|
20
|
-
order: number[];
|
|
21
|
-
}
|
|
22
|
-
/** Configuration of the core `sharding_indexed` codec. */
|
|
23
|
-
export interface ShardingIndexedCodecConfiguration {
|
|
24
|
-
chunk_shape: number[];
|
|
25
|
-
codecs: unknown[];
|
|
26
|
-
index_codecs: unknown[];
|
|
27
|
-
index_location?: "start" | "end";
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Walk one codec pipeline. `initialDims` is the array dimensionality at
|
|
31
|
-
* this point (undefined when unknowable); `initialChunkSizes` holds the
|
|
32
|
-
* distinct chunk lengths per dimension this pipeline may encode — what a
|
|
33
|
-
* sharding codec's inner chunks must divide. A regular grid contributes
|
|
34
|
-
* one size per dimension; a rectilinear grid may contribute several.
|
|
35
|
-
*/
|
|
36
|
-
export declare function pipelineIssues(pipeline: unknown[], path: Path, initialDims: number | undefined, initialChunkSizes: number[][] | undefined): PathedIssue[];
|
|
37
|
-
//# sourceMappingURL=codecs.d.ts.map
|
package/dist/codecs.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../src/codecs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAgD,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAEtF,mDAAmD;AACnD,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,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;AAOD;;;;;;GAMG;AACH,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,CAoKf"}
|
package/dist/codecs.js
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The codecs this package interprets — `transpose` and `sharding_indexed` —
|
|
3
|
-
* syntax (configuration types) and semantics together, plus the pipeline
|
|
4
|
-
* walker that threads dimensional context between codecs (mirroring
|
|
5
|
-
* zarr-python's chunk-spec threading): a valid transpose permutes the
|
|
6
|
-
* per-dimension chunk sizes for the codecs after it, and any codec this
|
|
7
|
-
* module cannot reason about — `reshape` may change a chunk's rank, and
|
|
8
|
-
* unknown codecs may do anything — invalidates the dimensional context for
|
|
9
|
-
* the rest of the pipeline instead of letting stale array-level facts
|
|
10
|
-
* produce false verdicts.
|
|
11
|
-
*
|
|
12
|
-
* Other codecs' required fields (blosc, gzip, zstd, ...) are deliberately
|
|
13
|
-
* NOT known here: they are registry-schema facts enforced by schema-driven
|
|
14
|
-
* tooling, and a second hardcoded source of truth would drift.
|
|
15
|
-
*/
|
|
16
|
-
import { configurationMissing, fieldParts, isIntArray } from "./guards.js";
|
|
17
|
-
function isPermutation(order) {
|
|
18
|
-
const seen = new Set(order);
|
|
19
|
-
return seen.size === order.length && order.every((entry) => entry >= 0 && entry < order.length);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Walk one codec pipeline. `initialDims` is the array dimensionality at
|
|
23
|
-
* this point (undefined when unknowable); `initialChunkSizes` holds the
|
|
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
|
-
export function pipelineIssues(pipeline, path, initialDims, initialChunkSizes) {
|
|
29
|
-
const issues = [];
|
|
30
|
-
// The dimensional context THREADS through the pipeline: transpose permutes
|
|
31
|
-
// it, and anything this module cannot reason about invalidates it for the
|
|
32
|
-
// remaining codecs.
|
|
33
|
-
let dims = initialDims;
|
|
34
|
-
let chunkSizes = initialChunkSizes;
|
|
35
|
-
const dropContext = () => {
|
|
36
|
-
dims = undefined;
|
|
37
|
-
chunkSizes = undefined;
|
|
38
|
-
};
|
|
39
|
-
pipeline.forEach((entry, index) => {
|
|
40
|
-
const parts = fieldParts(entry);
|
|
41
|
-
if (parts === undefined) {
|
|
42
|
-
dropContext(); // structurally invalid entry: no further reasoning
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const { name, configuration } = parts;
|
|
46
|
-
const configMissing = configurationMissing(entry);
|
|
47
|
-
if (name === "transpose") {
|
|
48
|
-
if (configMissing) {
|
|
49
|
-
issues.push({
|
|
50
|
-
path: [...path, index],
|
|
51
|
-
message: '"transpose" requires a configuration with "order"',
|
|
52
|
-
kind: "missing_key",
|
|
53
|
-
});
|
|
54
|
-
dropContext();
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (configuration !== undefined && !Object.hasOwn(configuration, "order")) {
|
|
58
|
-
issues.push({
|
|
59
|
-
path: [...path, index, "configuration", "order"],
|
|
60
|
-
message: "missing required key",
|
|
61
|
-
kind: "missing_key",
|
|
62
|
-
});
|
|
63
|
-
dropContext();
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const order = configuration?.["order"];
|
|
67
|
-
if (!isIntArray(order)) {
|
|
68
|
-
dropContext(); // shape errors are the schema layer's
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const orderPath = [...path, index, "configuration", "order"];
|
|
72
|
-
let sound = true;
|
|
73
|
-
if (!isPermutation(order)) {
|
|
74
|
-
sound = false;
|
|
75
|
-
issues.push({
|
|
76
|
-
path: orderPath,
|
|
77
|
-
message: `expected a permutation of the integers 0..${order.length - 1}`,
|
|
78
|
-
kind: "invalid_value",
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
if (dims !== undefined && order.length !== dims) {
|
|
82
|
-
sound = false;
|
|
83
|
-
issues.push({
|
|
84
|
-
path: orderPath,
|
|
85
|
-
message: `expected one entry per array dimension (${dims})`,
|
|
86
|
-
kind: "invalid_value",
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
if (!sound) {
|
|
90
|
-
dropContext();
|
|
91
|
-
}
|
|
92
|
-
else if (chunkSizes !== undefined) {
|
|
93
|
-
const sizes = chunkSizes;
|
|
94
|
-
chunkSizes =
|
|
95
|
-
order.length === sizes.length
|
|
96
|
-
? order.map((axis) => sizes[axis])
|
|
97
|
-
: undefined;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else if (name === "sharding_indexed") {
|
|
101
|
-
if (configMissing) {
|
|
102
|
-
issues.push({
|
|
103
|
-
path: [...path, index],
|
|
104
|
-
message: '"sharding_indexed" requires a configuration with "chunk_shape", "codecs", and "index_codecs"',
|
|
105
|
-
kind: "missing_key",
|
|
106
|
-
});
|
|
107
|
-
dropContext();
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (configuration !== undefined) {
|
|
111
|
-
for (const key of ["chunk_shape", "codecs", "index_codecs"]) {
|
|
112
|
-
if (!Object.hasOwn(configuration, key)) {
|
|
113
|
-
issues.push({
|
|
114
|
-
path: [...path, index, "configuration", key],
|
|
115
|
-
message: "missing required key",
|
|
116
|
-
kind: "missing_key",
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
const chunkShape = configuration?.["chunk_shape"];
|
|
122
|
-
if (!isIntArray(chunkShape)) {
|
|
123
|
-
// Still walk a present inner pipeline (entries deserve their own
|
|
124
|
-
// verdicts) before the context becomes unknowable.
|
|
125
|
-
const inner = configuration?.["codecs"];
|
|
126
|
-
if (Array.isArray(inner)) {
|
|
127
|
-
issues.push(...pipelineIssues(inner, [...path, index, "configuration", "codecs"], undefined, undefined));
|
|
128
|
-
}
|
|
129
|
-
dropContext();
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const chunkShapePath = [...path, index, "configuration", "chunk_shape"];
|
|
133
|
-
if (dims !== undefined && chunkShape.length !== dims) {
|
|
134
|
-
issues.push({
|
|
135
|
-
path: chunkShapePath,
|
|
136
|
-
message: `expected one length per array dimension (${dims})`,
|
|
137
|
-
kind: "invalid_value",
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
else if (chunkSizes !== undefined &&
|
|
141
|
-
chunkShape.length === chunkSizes.length &&
|
|
142
|
-
chunkShape.every((length) => length > 0)) {
|
|
143
|
-
let violation;
|
|
144
|
-
chunkSizes.forEach((sizes, axis) => {
|
|
145
|
-
if (violation !== undefined)
|
|
146
|
-
return;
|
|
147
|
-
const bad = sizes.find((size) => size % chunkShape[axis] !== 0);
|
|
148
|
-
if (bad !== undefined)
|
|
149
|
-
violation = { axis, size: bad };
|
|
150
|
-
});
|
|
151
|
-
if (violation !== undefined) {
|
|
152
|
-
const { axis, size } = violation;
|
|
153
|
-
const sizesNow = chunkSizes;
|
|
154
|
-
const uniform = sizesNow.every((sizes) => sizes.length === 1);
|
|
155
|
-
issues.push({
|
|
156
|
-
path: chunkShapePath,
|
|
157
|
-
message: uniform
|
|
158
|
-
? `expected ${JSON.stringify(chunkShape)} to evenly divide the outer chunk shape ${JSON.stringify(sizesNow.map((sizes) => sizes[0]))}`
|
|
159
|
-
: `expected ${JSON.stringify(chunkShape)} to evenly divide every chunk size of the grid (dimension ${axis} has chunk size ${size})`,
|
|
160
|
-
kind: "invalid_value",
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
const inner = configuration?.["codecs"];
|
|
165
|
-
if (Array.isArray(inner)) {
|
|
166
|
-
issues.push(...pipelineIssues(inner, [...path, index, "configuration", "codecs"], chunkShape.length, chunkShape.map((length) => [length])));
|
|
167
|
-
}
|
|
168
|
-
// index_codecs encode the shard index, whose shape differs from the
|
|
169
|
-
// array's — no dimensional context applies there. After the
|
|
170
|
-
// array -> bytes boundary the dimensional context is spent.
|
|
171
|
-
dropContext();
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
// A codec this module cannot reason about (reshape may change a
|
|
175
|
-
// chunk's rank; unknown codecs may do anything): stale array-level
|
|
176
|
-
// facts must not judge the codecs after it.
|
|
177
|
-
dropContext();
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
return issues;
|
|
181
|
-
}
|
|
182
|
-
//# sourceMappingURL=codecs.js.map
|
package/dist/codecs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codecs.js","sourceRoot":"","sources":["../src/codecs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,UAAU,EAAa,MAAM,aAAa,CAAC;AAetF,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;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,QAAmB,EACnB,IAAU,EACV,WAA+B,EAC/B,iBAAyC;IAEzC,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,2EAA2E;IAC3E,0EAA0E;IAC1E,oBAAoB;IACpB,IAAI,IAAI,GAAG,WAAW,CAAC;IACvB,IAAI,UAAU,GAAG,iBAAiB,CAAC;IACnC,MAAM,WAAW,GAAG,GAAS,EAAE;QAC7B,IAAI,GAAG,SAAS,CAAC;QACjB,UAAU,GAAG,SAAS,CAAC;IACzB,CAAC,CA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;YACH,CAAC;YACD,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC,QAAQ,CAAC,CAAC;YACxC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,MAAM,CAAC,IAAI,CACT,GAAG,cAAc,CACf,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;YACJ,CAAC;YACD,oEAAoE;YACpE,4DAA4D;YAC5D,4DAA4D;YAC5D,WAAW,EAAE,CAAC;QAChB,CAAC;aAAM,CAAC;YACN,gEAAgE;YAChE,mEAAmE;YACnE,4CAA4C;YAC5C,WAAW,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/data-types.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The core data types this package interprets: fill-value syntax per type,
|
|
3
|
-
* in one place per family. Extension data types are skipped — their shapes
|
|
4
|
-
* are registry-schema facts, and the name space is open.
|
|
5
|
-
*/
|
|
6
|
-
/** A float fill value: a JSON number, a non-finite sentinel, or a hex string. */
|
|
7
|
-
export type FloatFillValue = number | "NaN" | "Infinity" | "-Infinity" | string;
|
|
8
|
-
/** A complex fill value: `[real, imaginary]`, each a float fill form. */
|
|
9
|
-
export type ComplexFillValue = [FloatFillValue, FloatFillValue];
|
|
10
|
-
/** The fill_value issue for a KNOWN core data type, if any; undefined otherwise. */
|
|
11
|
-
export declare function fillValueIssue(dataTypeName: string, fill: unknown): string | undefined;
|
|
12
|
-
//# sourceMappingURL=data-types.d.ts.map
|
package/dist/data-types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data-types.d.ts","sourceRoot":"","sources":["../src/data-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iFAAiF;AACjF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAAC;AAEhF,yEAAyE;AACzE,MAAM,MAAM,gBAAgB,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;AAuChE,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CA8BtF"}
|
package/dist/data-types.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The core data types this package interprets: fill-value syntax per type,
|
|
3
|
-
* in one place per family. Extension data types are skipped — their shapes
|
|
4
|
-
* are registry-schema facts, and the name space is open.
|
|
5
|
-
*/
|
|
6
|
-
const INT_RANGES = {
|
|
7
|
-
int8: [-128, 127],
|
|
8
|
-
int16: [-32768, 32767],
|
|
9
|
-
int32: [-2147483648, 2147483647],
|
|
10
|
-
int64: [-9223372036854775808, 9223372036854775807],
|
|
11
|
-
uint8: [0, 255],
|
|
12
|
-
uint16: [0, 65535],
|
|
13
|
-
uint32: [0, 4294967295],
|
|
14
|
-
uint64: [0, 18446744073709551615],
|
|
15
|
-
};
|
|
16
|
-
const FLOAT_HEX_DIGITS = {
|
|
17
|
-
float16: 4,
|
|
18
|
-
float32: 8,
|
|
19
|
-
float64: 16,
|
|
20
|
-
};
|
|
21
|
-
/** Hex digit width of each complex type's component floats. */
|
|
22
|
-
const COMPLEX_COMPONENT_HEX_DIGITS = {
|
|
23
|
-
complex64: 8,
|
|
24
|
-
complex128: 16,
|
|
25
|
-
};
|
|
26
|
-
function isFloatFill(value, hexDigits) {
|
|
27
|
-
if (typeof value === "number")
|
|
28
|
-
return true;
|
|
29
|
-
if (typeof value !== "string")
|
|
30
|
-
return false;
|
|
31
|
-
if (value === "NaN" || value === "Infinity" || value === "-Infinity")
|
|
32
|
-
return true;
|
|
33
|
-
return new RegExp(`^0x[0-9a-fA-F]{${hexDigits}}$`).test(value);
|
|
34
|
-
}
|
|
35
|
-
function floatFillMessage(name, hexDigits) {
|
|
36
|
-
return (`expected a number, "NaN", "Infinity", "-Infinity", or a ` +
|
|
37
|
-
`${hexDigits}-hex-digit "0x..." string for data type ${JSON.stringify(name)}`);
|
|
38
|
-
}
|
|
39
|
-
/** The fill_value issue for a KNOWN core data type, if any; undefined otherwise. */
|
|
40
|
-
export function fillValueIssue(dataTypeName, fill) {
|
|
41
|
-
if (dataTypeName === "bool") {
|
|
42
|
-
return typeof fill === "boolean"
|
|
43
|
-
? undefined
|
|
44
|
-
: 'expected a boolean fill value for data type "bool"';
|
|
45
|
-
}
|
|
46
|
-
const intRange = INT_RANGES[dataTypeName];
|
|
47
|
-
if (intRange !== undefined) {
|
|
48
|
-
const [low, high] = intRange;
|
|
49
|
-
return Number.isInteger(fill) && fill >= low && fill <= high
|
|
50
|
-
? undefined
|
|
51
|
-
: `expected an integer in [${low}, ${high}] for data type ${JSON.stringify(dataTypeName)}`;
|
|
52
|
-
}
|
|
53
|
-
const floatDigits = FLOAT_HEX_DIGITS[dataTypeName];
|
|
54
|
-
if (floatDigits !== undefined) {
|
|
55
|
-
return isFloatFill(fill, floatDigits)
|
|
56
|
-
? undefined
|
|
57
|
-
: floatFillMessage(dataTypeName, floatDigits);
|
|
58
|
-
}
|
|
59
|
-
const complexDigits = COMPLEX_COMPONENT_HEX_DIGITS[dataTypeName];
|
|
60
|
-
if (complexDigits !== undefined) {
|
|
61
|
-
const ok = Array.isArray(fill) &&
|
|
62
|
-
fill.length === 2 &&
|
|
63
|
-
fill.every((part) => isFloatFill(part, complexDigits));
|
|
64
|
-
return ok
|
|
65
|
-
? undefined
|
|
66
|
-
: `expected a two-element [real, imaginary] array for data type ${JSON.stringify(dataTypeName)}`;
|
|
67
|
-
}
|
|
68
|
-
return undefined; // unrecognized data type: no verdict
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=data-types.js.map
|
package/dist/data-types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data-types.js","sourceRoot":"","sources":["../src/data-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,MAAM,UAAU,GAA8C;IAC5D,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,KAAK,EAAE,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,KAAK,EAAE,CAAC,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;IAClD,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC;IAClB,MAAM,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,CAAC,CAAC,EAAE,oBAAoB,CAAC;CAClC,CAAC;AAEF,MAAM,gBAAgB,GAA2B;IAC/C,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,+DAA+D;AAC/D,MAAM,4BAA4B,GAA2B;IAC3D,SAAS,EAAE,CAAC;IACZ,UAAU,EAAE,EAAE;CACf,CAAC;AAEF,SAAS,WAAW,CAAC,KAAc,EAAE,SAAiB;IACpD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAClF,OAAO,IAAI,MAAM,CAAC,kBAAkB,SAAS,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC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K,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC;QACzD,OAAO,EAAE;YACP,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,gEAAgE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC;IACrG,CAAC;IACD,OAAO,SAAS,CAAC,CAAC,qCAAqC;AACzD,CAAC"}
|
package/src/codecs.ts
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The codecs this package interprets — `transpose` and `sharding_indexed` —
|
|
3
|
-
* syntax (configuration types) and semantics together, plus the pipeline
|
|
4
|
-
* walker that threads dimensional context between codecs (mirroring
|
|
5
|
-
* zarr-python's chunk-spec threading): a valid transpose permutes the
|
|
6
|
-
* per-dimension chunk sizes for the codecs after it, and any codec this
|
|
7
|
-
* module cannot reason about — `reshape` may change a chunk's rank, and
|
|
8
|
-
* unknown codecs may do anything — invalidates the dimensional context for
|
|
9
|
-
* the rest of the pipeline instead of letting stale array-level facts
|
|
10
|
-
* produce false verdicts.
|
|
11
|
-
*
|
|
12
|
-
* Other codecs' required fields (blosc, gzip, zstd, ...) are deliberately
|
|
13
|
-
* NOT known here: they are registry-schema facts enforced by schema-driven
|
|
14
|
-
* tooling, and a second hardcoded source of truth would drift.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import type { PathedIssue } from "./errors.js";
|
|
18
|
-
import { configurationMissing, fieldParts, isIntArray, type Path } from "./guards.js";
|
|
19
|
-
|
|
20
|
-
/** Configuration of the core `transpose` codec. */
|
|
21
|
-
export interface TransposeCodecConfiguration {
|
|
22
|
-
order: number[];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** Configuration of the core `sharding_indexed` codec. */
|
|
26
|
-
export interface ShardingIndexedCodecConfiguration {
|
|
27
|
-
chunk_shape: number[];
|
|
28
|
-
codecs: unknown[];
|
|
29
|
-
index_codecs: unknown[];
|
|
30
|
-
index_location?: "start" | "end";
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function isPermutation(order: number[]): boolean {
|
|
34
|
-
const seen = new Set(order);
|
|
35
|
-
return seen.size === order.length && order.every((entry) => entry >= 0 && entry < order.length);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Walk one codec pipeline. `initialDims` is the array dimensionality at
|
|
40
|
-
* this point (undefined when unknowable); `initialChunkSizes` holds the
|
|
41
|
-
* distinct chunk lengths per dimension this pipeline may encode — what a
|
|
42
|
-
* sharding codec's inner chunks must divide. A regular grid contributes
|
|
43
|
-
* one size per dimension; a rectilinear grid may contribute several.
|
|
44
|
-
*/
|
|
45
|
-
export function pipelineIssues(
|
|
46
|
-
pipeline: unknown[],
|
|
47
|
-
path: Path,
|
|
48
|
-
initialDims: number | undefined,
|
|
49
|
-
initialChunkSizes: number[][] | undefined,
|
|
50
|
-
): PathedIssue[] {
|
|
51
|
-
const issues: PathedIssue[] = [];
|
|
52
|
-
// The dimensional context THREADS through the pipeline: transpose permutes
|
|
53
|
-
// it, and anything this module cannot reason about invalidates it for the
|
|
54
|
-
// remaining codecs.
|
|
55
|
-
let dims = initialDims;
|
|
56
|
-
let chunkSizes = initialChunkSizes;
|
|
57
|
-
const dropContext = (): void => {
|
|
58
|
-
dims = undefined;
|
|
59
|
-
chunkSizes = undefined;
|
|
60
|
-
};
|
|
61
|
-
pipeline.forEach((entry, index) => {
|
|
62
|
-
const parts = fieldParts(entry);
|
|
63
|
-
if (parts === undefined) {
|
|
64
|
-
dropContext(); // structurally invalid entry: no further reasoning
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const { name, configuration } = parts;
|
|
68
|
-
const configMissing = configurationMissing(entry);
|
|
69
|
-
if (name === "transpose") {
|
|
70
|
-
if (configMissing) {
|
|
71
|
-
issues.push({
|
|
72
|
-
path: [...path, index],
|
|
73
|
-
message: '"transpose" requires a configuration with "order"',
|
|
74
|
-
kind: "missing_key",
|
|
75
|
-
});
|
|
76
|
-
dropContext();
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (configuration !== undefined && !Object.hasOwn(configuration, "order")) {
|
|
80
|
-
issues.push({
|
|
81
|
-
path: [...path, index, "configuration", "order"],
|
|
82
|
-
message: "missing required key",
|
|
83
|
-
kind: "missing_key",
|
|
84
|
-
});
|
|
85
|
-
dropContext();
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const order = configuration?.["order"];
|
|
89
|
-
if (!isIntArray(order)) {
|
|
90
|
-
dropContext(); // shape errors are the schema layer's
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const orderPath = [...path, index, "configuration", "order"];
|
|
94
|
-
let sound = true;
|
|
95
|
-
if (!isPermutation(order)) {
|
|
96
|
-
sound = false;
|
|
97
|
-
issues.push({
|
|
98
|
-
path: orderPath,
|
|
99
|
-
message: `expected a permutation of the integers 0..${order.length - 1}`,
|
|
100
|
-
kind: "invalid_value",
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
if (dims !== undefined && order.length !== dims) {
|
|
104
|
-
sound = false;
|
|
105
|
-
issues.push({
|
|
106
|
-
path: orderPath,
|
|
107
|
-
message: `expected one entry per array dimension (${dims})`,
|
|
108
|
-
kind: "invalid_value",
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
if (!sound) {
|
|
112
|
-
dropContext();
|
|
113
|
-
} else if (chunkSizes !== undefined) {
|
|
114
|
-
const sizes = chunkSizes;
|
|
115
|
-
chunkSizes =
|
|
116
|
-
order.length === sizes.length
|
|
117
|
-
? order.map((axis) => sizes[axis] as number[])
|
|
118
|
-
: undefined;
|
|
119
|
-
}
|
|
120
|
-
} else if (name === "sharding_indexed") {
|
|
121
|
-
if (configMissing) {
|
|
122
|
-
issues.push({
|
|
123
|
-
path: [...path, index],
|
|
124
|
-
message:
|
|
125
|
-
'"sharding_indexed" requires a configuration with "chunk_shape", "codecs", and "index_codecs"',
|
|
126
|
-
kind: "missing_key",
|
|
127
|
-
});
|
|
128
|
-
dropContext();
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (configuration !== undefined) {
|
|
132
|
-
for (const key of ["chunk_shape", "codecs", "index_codecs"]) {
|
|
133
|
-
if (!Object.hasOwn(configuration, key)) {
|
|
134
|
-
issues.push({
|
|
135
|
-
path: [...path, index, "configuration", key],
|
|
136
|
-
message: "missing required key",
|
|
137
|
-
kind: "missing_key",
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
const chunkShape = configuration?.["chunk_shape"];
|
|
143
|
-
if (!isIntArray(chunkShape)) {
|
|
144
|
-
// Still walk a present inner pipeline (entries deserve their own
|
|
145
|
-
// verdicts) before the context becomes unknowable.
|
|
146
|
-
const inner = configuration?.["codecs"];
|
|
147
|
-
if (Array.isArray(inner)) {
|
|
148
|
-
issues.push(
|
|
149
|
-
...pipelineIssues(
|
|
150
|
-
inner,
|
|
151
|
-
[...path, index, "configuration", "codecs"],
|
|
152
|
-
undefined,
|
|
153
|
-
undefined,
|
|
154
|
-
),
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
dropContext();
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
const chunkShapePath = [...path, index, "configuration", "chunk_shape"];
|
|
161
|
-
if (dims !== undefined && chunkShape.length !== dims) {
|
|
162
|
-
issues.push({
|
|
163
|
-
path: chunkShapePath,
|
|
164
|
-
message: `expected one length per array dimension (${dims})`,
|
|
165
|
-
kind: "invalid_value",
|
|
166
|
-
});
|
|
167
|
-
} else if (
|
|
168
|
-
chunkSizes !== undefined &&
|
|
169
|
-
chunkShape.length === chunkSizes.length &&
|
|
170
|
-
chunkShape.every((length) => length > 0)
|
|
171
|
-
) {
|
|
172
|
-
let violation: { axis: number; size: number } | undefined;
|
|
173
|
-
chunkSizes.forEach((sizes, axis) => {
|
|
174
|
-
if (violation !== undefined) return;
|
|
175
|
-
const bad = sizes.find((size) => size % (chunkShape[axis] as number) !== 0);
|
|
176
|
-
if (bad !== undefined) violation = { axis, size: bad };
|
|
177
|
-
});
|
|
178
|
-
if (violation !== undefined) {
|
|
179
|
-
const { axis, size } = violation;
|
|
180
|
-
const sizesNow = chunkSizes;
|
|
181
|
-
const uniform = sizesNow.every((sizes) => sizes.length === 1);
|
|
182
|
-
issues.push({
|
|
183
|
-
path: chunkShapePath,
|
|
184
|
-
message: uniform
|
|
185
|
-
? `expected ${JSON.stringify(chunkShape)} to evenly divide the outer chunk shape ${JSON.stringify(sizesNow.map((sizes) => sizes[0]))}`
|
|
186
|
-
: `expected ${JSON.stringify(chunkShape)} to evenly divide every chunk size of the grid (dimension ${axis} has chunk size ${size})`,
|
|
187
|
-
kind: "invalid_value",
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
const inner = configuration?.["codecs"];
|
|
192
|
-
if (Array.isArray(inner)) {
|
|
193
|
-
issues.push(
|
|
194
|
-
...pipelineIssues(
|
|
195
|
-
inner,
|
|
196
|
-
[...path, index, "configuration", "codecs"],
|
|
197
|
-
chunkShape.length,
|
|
198
|
-
chunkShape.map((length) => [length]),
|
|
199
|
-
),
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
// index_codecs encode the shard index, whose shape differs from the
|
|
203
|
-
// array's — no dimensional context applies there. After the
|
|
204
|
-
// array -> bytes boundary the dimensional context is spent.
|
|
205
|
-
dropContext();
|
|
206
|
-
} else {
|
|
207
|
-
// A codec this module cannot reason about (reshape may change a
|
|
208
|
-
// chunk's rank; unknown codecs may do anything): stale array-level
|
|
209
|
-
// facts must not judge the codecs after it.
|
|
210
|
-
dropContext();
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
return issues;
|
|
214
|
-
}
|