Constants

String constants used in store metadata. Importing them turns a typo into an import error.

Format constants for the Zarr Vectors (ZV) format.

These are the canonical names, prefixes, and default values used throughout the specification. Changing a value here changes it everywhere in the package.

zarr_vectors.constants.CAP_DENSE_MANIFESTS: str = 'dense_manifests'

At least one level’s object index is (or will be written) in the dense layout, "dense_manifests_v1": fixed-width integer arrays rather than one vlen blob per object. Stamped with the root’s manifest_layout: "dense".

zarr_vectors.constants.CAP_FRAGMENT_INDEX: str = 'fragment_index'

The store uses the v0.6 fragment-index encoding for vertex_fragments and link_fragments (single uint8 blob per chunk; see zarr_vectors.encoding.fragments).

Reserved, not stamped: every store this package writes uses that encoding, and each sidecar array declares it itself (encoding: "fragment_index_v1" in its own metadata), which is what readers consult. Root format_capabilities never carries this token, so no reader may require it.

Store uses the multiscale links layout (links/<delta>/<offsets>/ and link_attributes/<name>/<delta>/<offsets>/) and may contain cross-pyramid-level edges (delta != 0). Since 0.9.0 there is no separate cross-chunk family — a cross-chunk link is a link with a non-zero offsets segment — so this token now marks only the presence of delta != 0 arrays.

zarr_vectors.constants.CAP_OCTREE_CHUNKS: str = 'octree_chunks'

its per-chunk arrays hold one cell per octree leaf (an aligned cube of the uniform grid’s cells, sized by its vertex count), at the leaf’s minimum-corner cell, with cross-leaf links named by (offset, depth change). A reader without it must not read such a level: it would take each leaf for one uniform cell. Readers that do not check capabilities are stopped by zarr itself: the level’s per-chunk arrays carry the zarr_vectors_octree_chunks codec (zarr_vectors.encoding.octree_marker), which a zarr reader must know to open them. Listed in the root’s required_capabilities as well as format_capabilities, for the same span, so a viewer that checks the first can refuse the store with a clear message. Optional, and converted to and from uniform chunks by zarr_vectors.octree_chunks.

Type:

A level of the store has octree chunks

zarr_vectors.constants.CAP_OCTREE_SHARDING: str = 'octree_sharding'

its sharded per-chunk arrays are written with zarr-octree’s octree_sharding codec (zarr_octree_sharding before 0.4; cells grouped into the leaves of an octree aimed at a target size, and a sparse shard index) instead of sharding_indexed. Stamped with the root’s octree_sharding block (the codec’s configuration); set at construction (Layout(octree=...)) or by zarr_vectors.sharding.set_octree(), which converts either way. Reading or writing such an array needs the zarr-octree package. Optional and additive: absent means sharding_indexed, as every other store.

Type:

The store is marked octree

zarr_vectors.constants.CAP_PRESERVED_OBJECT_IDS: str = 'preserved_object_ids'

At least one resolution level was written with ID-preserving sparsification (preserves_object_ids=True on the level metadata). A dropped object keeps its id as an empty manifest slot, so ids stay stable across levels, and parent_level carries semantic weight. (Pre-0.8.1 this also meant a zeroed present_mask byte; that sidecar is gone – presence is the manifest being empty.)

zarr_vectors.constants.CAP_SHARED_FRAGMENTS: str = 'shared_fragments'

At least one resolution level stores per-chunk fragments that may be referenced by multiple objects’ manifests (the v0.6 successor to shared_vertex_groups; the sharing primitive is now a fragment rather than a contiguous-byte vertex group).

zarr_vectors.constants.COARSEN_PER_OBJECT: str = 'per_object'

each surviving object’s vertices are aggregated into bin centroids (metavertices). Metavertices may be shared between objects; OIDs are preserved across levels.

Type:

Per-object pyramid

zarr_vectors.constants.DEFAULT_AXES_NAMES: tuple[str, ...] = ('x', 'y', 'z', 'w')

Default axis names used when create_store is called without an explicit axes kwarg. Indexed by sid_ndim (1 → ("x",), 2 → ("x", "y"), …). Stops at 4 dims; higher-dim stores must pass axes explicitly.

zarr_vectors.constants.DEFAULT_BIN_RATIO: tuple[int, ...] = (1, 1, 1)

Bin ratio at level 0 (no downsampling).

zarr_vectors.constants.DEFAULT_BOUNDS_SIDE: float = 128.0

Default per-dimension extent for a freshly-warmed store. When create_store(path) is called with no bounds kwarg, the store is created with bounds = ([0,...,0], [128,...,128]) for the resolved sid_ndim. Out-of-bounds writes raise unless an out_of_bounds= policy is supplied by the caller.

zarr_vectors.constants.DEFAULT_CROSS_LEVEL_DEPTH: int = 1

emit ±1 cross-level link arrays at every adjacent level pair. 0 disables, -1 means all available pyramid levels.

Type:

Default cross_level_depth

zarr_vectors.constants.DEFAULT_CROSS_LEVEL_STORAGE: str = 'explicit'

materialize both +N (at the finer level) and -N (at the coarser level).

Type:

Default cross_level_storage

zarr_vectors.constants.DEFAULT_OOB_POLICY: str = 'raise'

Default out_of_bounds policy applied by the top-level write functions when the caller does not specify one. Values: "raise" (reject the write), "ignore" (silently drop out-of-bounds vertices), "expand" (grow store bounds to include the new data).

zarr_vectors.constants.DEFAULT_REDUCTION_FACTOR: int = 8

only emit a new resolution level when vertex count drops by 8×.

Type:

Default

zarr_vectors.constants.DICTIONARY_ENCODING: str = 'dictionary'

encoding stamped on a dictionary-encoded (categorical) attribute: integer codes, with categories[code] recovering the value.

zarr_vectors.constants.FORMAT_VERSION: str = '0.10.0'

Current ZV specification version.

0.10.0: the metadata moves onto the Zarr Vectors convention (https://github.com/Andrew-Keenlyside/zarr-vectors, v0.1.0). Cell payloads are byte-for-byte those of 0.9.4; only where metadata lives changes, so 0.9.x stores migrate in place with zarr_vectors.building.migrate_metadata_0_10() and no data is rewritten.

  • Every node’s Zarr Vectors properties sit under one attribute, zarr_vectors, discriminated by kind: root, level, parametric, or an array kind. Array fields (dtype, name, nonempty_chunks, …) move inside it, zarr_vectors_level becomes zarr_vectors with kind: "level", and the level’s zarr_vectors_presence becomes its presence field. Two array kinds are renamed: attribute -> vertex_attribute and groupings_attribute -> group_attribute. In memory, array metadata keeps its flat zv_array shape (zarr_vectors.core.convention).

  • zarr_conventions registers the convention on every such node, and the multiscales (and, with a CRS, proj) conventions on the root.

  • Axes move from NGFF multiscales[0].axes into zarr_vectors.axes.

  • The bare-root OME-NGFF 0.4 multiscales list – which pointed datasets at groups and reused scale / translation for bin geometry – is replaced by the registered multiscales convention’s {"layout": [{"asset": "<level>"}]}, with no transform: vertex coordinates are the same at every level, so there is no coordinate transform to state. A coarse level’s bin_shape and bin_ratio live only in its own zarr_vectors object.

  • crs leaves the root object for the proj convention’s proj:projjson.

A 0.9.x reader cannot read a 0.10.0 store, and this package refuses a 0.9.x store with UnsupportedFormatVersionError naming the migration.

0.9.4: an optional dense object-index layout, "dense_manifests_v1": object_index/manifest_spans (int64 (n_objects, 2), start and count) indexing object_index/manifest_blocks (int64 (n_blocks, sid_ndim + 1), chunk coordinates then fragment index, one row per fragment an object references), with object_index/object_ids as in the V2 vlen layout. Chosen per store by the root’s manifest_layout: "dense" (absent means vlen, so every 0.9.3 store reads unchanged), and declared by the dense_manifests capability. A store that uses it is not readable by a 0.9.3 build, whose object index reader rejects the unknown layout with an error rather than misreading it.

0.9.3: optional, backward-compatible shard_shape on the root (absent ⇒ unsharded, so 0.9.0-0.9.2 stores read unchanged). Cells per shard per axis – an int when every axis agrees, a list when they do not.

The store’s declared PACKING, which had nowhere to live before. Sharding was per-array and per-call: a writer passed shard_shape= and the arrays that call created were sharded, while every array allocated later – an attribute array or links segment made on first write, in a worker that never saw the argument – came out flat. Recording it on the root is what lets those paths find it. create_store(shard_shape=) previously had no parameter at all, so the value was absorbed by **backend_kwargs and dropped without a word.

Additive: no reader needs it. Sharding is transparent to any conformant Zarr v3 reader, and each array’s own zarr.json remains the truth about that array – this is a writer default, not a claim about what is on disk, which is why it is a field rather than a format_capabilities token. A 0.9.2 reader ignoring the key reads the store correctly.

Also in 0.9.3, both additive in the same sense:

  • The root ome scene’s world coordinate system carries id beside name, so a collection elsewhere can bind an edge to it; a reader that looks for name finds it unchanged.

  • A per-chunk array may omit nonempty_chunks, meaning presence is not recorded and a reader takes it from the store. That happens only while a level declares presence "deferred" (from 0.10.0 the level object’s presence field) – a build-time state that the coordinator’s rebuild ends, restoring every manifest – so a finished store is readable by a 0.9.2 reader. One caught mid-build is not: that reader treats the missing manifest as an empty array.

0.9.2: optional, backward-compatible ome block on the root (absent ⇒ the prior behaviour, so 0.9.0 and 0.9.1 stores read unchanged). It is an OME-Zarr RFC 8 node — version, type: "collection", name, one zv:level leaf per resolution level, and a scene declaring the world coordinate system with the store’s axes and units. That is what an OME collection elsewhere needs in order to name this store by path: a resolver following {"type": "zarr", "path": "./x.zarrvectors"} fetches the root zarr.json and looks for a legal node under ome, and before 0.9.2 there was none. Declaring world is what makes the membership useful rather than merely legal — a viewer can place the store beside an image pyramid.

Additive in the strict sense: nothing moved, nothing was removed, and no reader in this package or downstream consults the block. Every field in it restates one already carried by zarr_vectors or multiscales, which remain the source of truth. Re-seating the format on RFC 8 — dropping the repurposed coordinateTransformations, minting node types for the arrays, collapsing the attribute discriminators — is the separate 0.10.0 change; this block is forward-compatible with it. Because it only adds, an existing store can be brought up to it in place, without rewriting data: zarr_vectors.building.stamp_ome_node(). See zarr_vectors.core.ome.

0.9.1: optional, backward-compatible attribute_specs block on the root (absent ⇒ the prior behaviour, so 0.9.0 stores read unchanged). It records what a store declares its attributes to be, by scope — {"vertex": {"intensity": {"dtype": "float32", "unit": "microvolt"}}, "object": {...}, "link": {...}} — so a zarr_vectors.api.schema.Schema round-trips through Schema.from_store and open_or_create can report a store that is missing an attribute the caller declared. A declaration is not a promise the array exists; the array appears when data is written. unit and description are additionally stamped onto the attribute array’s own metadata block when it is written. No migration: an undeclared store is simply undeclared.

0.9.0: single-array layout for every per-spatial-chunk array. Each logical array — vertices, vertex_fragments, link_fragments, links/<delta>, vertex_attributes/<name>, fragment_attributes/<name>, link_attributes/<name>/<delta> — is now ONE Zarr v3 vlen-bytes array whose shape is the level’s chunk grid (<array>/zarr.json + one chunk file per cell at <array>/c/i/j/k), replacing the previous “Option G” layout where every spatial chunk was its own single-chunk uint8 sub-array under a per-array group. A spatial chunk at absolute coord c lands in cell c - origin where origin = floor(min_corner / chunk_shape) is stored as the array’s chunk_grid_origin attribute (absent ⇒ zero origin); this lets data with negative coordinates map onto a 0-indexed array. Non-empty cells are tracked in the array’s nonempty_chunks attribute for O(1) enumeration. Optional shard_shape= wraps the cells in the Zarr v3 sharding_indexed codec. Hard break: 0.8.x stores wrote per-chunk sub-arrays and cannot be read; rewrite from source.

0.9.0 also merges cross_chunk_links / cross_chunk_link_attributes into links / link_attributes. Connectivity is ONE family: an intra-chunk link is just a link whose relative chunk offset is zero. links/<delta> becomes a group whose children are one rank-D vlen array per relative-offset segment — links/<delta>/<offsets>, cell = the record’s SOURCE chunk, vi_k local to src + o_k — and link_attributes/<name>/<delta>/<offsets> mirrors it exactly (same offsets, same cells, same row order). Endpoint tuples are no longer part of any path, so both families are ordinary chunk-grid arrays and shard like everything else. See zarr_vectors.core.paths.

0.8.1: flat single-array layout for dense / ragged blobs. Removes the group-with-data-child pattern used by every non-spatial array (object_attributes, group_attributes, groups, parametric blobs, composite links) and writes each logical array as a single standard Zarr v3 array at its logical path. Sparse coverage is expressed via the array’s fill_value (NaN for floats, sentinel for integers) instead of a sibling present_mask child array. Ragged arrays move to vlen-bytes codec, matching the layout object_index/manifests already used. Custom per-array attrs move from the parent group’s attributes into the array’s own attributes block. Hard break: 0.8.0 stores are not readable; rewrite from source.

0.8.1 also adds three optional, backward-compatible fields to the cross_chunk_links/<delta>/ family .zattrs (absent ⇒ the prior behaviour, so existing 0.8.1 stores read unchanged): directed (bool; when true endpoint order is preserved and A→B / B→A are distinct cells — used by streamline and skeleton parent→child edges), store ("canonical" = one cell per record, or "duplicate" = one cell per distinct incident chunk for prefix-scan incidence reads), and num_physical_records (on-disk row count, > num_links when duplicated). num_links remains the logical record count. A decentralized write_cross_chunk_link_cells + finalize_cross_chunk_links pair lets independent workers append into disjoint cells race-free. (That family and those helpers were merged into links/ after 0.8.1 — see docs/spec/object_model/links.md for the layout that replaced it.)

0.8.0: per-tuple cross_chunk_links layout. The global flat cross_chunk_links/<delta>/data blob is replaced by per-cell arrays keyed on the canonical-sorted L-tuple of endpoint chunks (cross_chunk_links/<delta>/<chunk_0.x.y.z>.<chunk_1.x.y.z>...) where L = link_width. Each cell stores only the records spanning that exact chunk-tuple — readers scale with cell size, not store size. Endpoint order is preserved via a Lehmer-coded perm_idx int64 per record so mesh-face winding and directed- edge direction survive the canonical sort. write_cross_chunk_links returns a CrossChunkLinkPartition instead of an int; legacy callers can still int(partition) for the first_new field. Hard break: 0.7.x stores are not readable; rewrite from source.

0.7.0: per-level chunk_shape. RootMetadata.chunk_shape remains the level-0 default; LevelMetadata gains an optional chunk_shape field that, when set, overrides root for that level. Required invariant: per-level chunk_shape must be a positive integer multiple of the root chunk_shape along every axis (nested chunk grids). This lets coarser pyramid levels use larger chunks the way OME-Zarr image pyramids grow physical chunk extent via voxel-size scaling. Cross-level link arrays keep the single-chunk-key convention; the differing level’s chunk coord is computed by integer division using the per-level chunk_shape ratio. Hard break: 0.6.x stores are not readable; rewrite from source.

0.6.0: fragment-index schema. Replaces vertex_group_offsets with vertex_fragments and splits the v0.5 inline-header link blob into a flat links/0/<chunk> payload plus a sibling link_fragments/<chunk> group. The fragment-index byte layout expresses each per-group boundary as either a contiguous index range [start, count) or an explicit list of row indices, supporting vertex re-use across fragments. object_index/data now uses a per-chunk manifest-block format with single / range / explicit modes; cross-level link arrays (cross_chunk_links, delta != 0) are unchanged. Hard break: 0.5.x stores are not readable; rewrite from source.

0.5.0: NGFF-alignment cleanup + format simplification. The 0.5 series went through several on-disk simplifications without a version bump (consumers should pin to a specific point release):

  • vertex_counts/ per-chunk sidecars removed; per-chunk vertex counts are derived from vertex_group_offsets and the vertices/<key> blob size.

  • vertex_group_offsets/<key> is a plain (K,) int64 array of vertex byte offsets (the legacy (K, 2) paired layout with a link-offset column is gone).

  • attributes/<name>/<key>_offsets sibling blobs removed. Attribute groups align 1:1 with vertex groups; per-group byte offsets are computed at read time.

  • metanode_children/ removed. Pyramid drill-down uses the links/<+1>/ + cross_chunk_links/<+1>/ arrays emitted inline during coarsening (mirrored as -1 on the coarse side under cross_level_storage="explicit").

  • cross_chunk_faces/ removed. Cross-chunk face identity uses cross_chunk_links/<delta>/ with link_width=3. The cross_chunk_links array carries a link_width metadata field (default 2 for edges).

  • object_index/pending/ staging tree removed. Incremental writes go directly into object_index/; transactional backends (icechunk) make this cheap.

Earlier 0.5 changes (now baseline): renamed format_version to zv_version, moved axes to multiscales[0].axes, dropped per-array dtype duplication.

0.4.1: bare-integer resolution-level group names (0/, 1/).

zarr_vectors.constants.FRAGMENT_ATTRIBUTES: str = 'fragment_attributes'

Per-fragment attribute arrays. Dense per-chunk blob with one row per fragment in that chunk ((F,) or (F, C)). Optional — used when callers want to materialize per-fragment data, including parent-IDs (e.g. an object_id fragment attribute carrying the OID that owns each fragment).

Connectivity family. links/<delta> is a group; its children are one rank-D vlen array per relative-offset segment (links/<delta>/<offsets>). There is no array at links/<delta> itself — compose paths via zarr_vectors.core.paths.

Per-link attribute family. link_attributes/<name>/<delta> is a group mirroring links/<delta>: one array per offsets segment, same cells, same per-cell row order, so attribute rows align 1:1 with link records without storing a row id.

Per-chunk fragment-index describing how rows of the intra-chunk link array group into fragments. Keyed by chunk ALONE — it carries no delta and no offsets segment — so exactly one array may write it: the all-zero-offsets array at delta == 0 (links/0/<intra offsets>/<chunk>). Every other offset array, and every delta != 0 array, uses an inline self-describing blob and has no sidecar; see zarr_vectors.core.arrays.write_chunk_links().

zarr_vectors.constants.OCTREE_CODEC_NAMES: tuple[str, ...] = ('octree_sharding', 'zarr_octree_sharding')

octree_sharding (its zarr-extensions registry name, written since zarr-octree 0.4) and zarr_octree_sharding (written by zarr-octree 0.3 and earlier, and still read). An array whose first codec has either name is octree-sharded.

Type:

Names zarr-octree’s codec is stored under

zarr_vectors.constants.OME_ATTRS_KEY: str = 'ome'

Root-attribute key the ome block lives under. Reserved by NGFF 0.5+.

zarr_vectors.constants.OME_VERSION: str = '0.6'

NGFF version stamped on the node.

"0.6": RFC 8 is a proposal and is not part of NGFF 0.5, so the node declares the next NGFF version, the one RFC 8 targets. Until RFC 8 lands that version is not settled; it is a single constant so that correcting it is a one-line change.

RFC 8 requires version on the root node of a document and forbids it on any other, so it appears here and nowhere else in the store.

zarr_vectors.constants.PARAMETRIC_GROUP: str = 'parametric'

Name of the root-level parametric objects group.

zarr_vectors.constants.RESOLUTION_PREFIX: str = ''

Empty under the 0.4.1 layout — resolution level groups are bare integer names (0, 1, …) to mirror OME-Zarr’s convention. Retained as a symbol so callers that build paths via f"{RESOLUTION_PREFIX}{n}" keep working without import churn.

zarr_vectors.constants.VERTEX_FRAGMENTS: str = 'vertex_fragments'

Per-chunk fragment-index group describing how rows of vertices/<chunk> group into fragments. See zarr_vectors.encoding.fragments.

Geometry type values

Constant

Value

Use

GEOM_POINT_CLOUD

"point_cloud"

Unconnected vertices

GEOM_LINE

"line"

Independent line segment pairs

GEOM_POLYLINE

"polyline"

Ordered vertex paths

GEOM_STREAMLINE

"streamline"

Tractography paths with metadata

GEOM_GRAPH

"graph"

Arbitrary vertex–edge graph

GEOM_SKELETON

"skeleton"

Tree-structured morphology (SWC-compatible)

GEOM_MESH

"mesh"

Triangulated surface mesh