Transpose codec (version 1.0)#
Editor’s draft 26 July 2019
- Specification URI:
https://zarr-specs.readthedocs.io/en/latest/v3/codecs/transpose/v1.0.html
- Corresponding ZEP:
- Issue tracking:
- Suggest an edit for this spec:
Copyright 2020-Present Zarr core development team. This work is licensed under a Creative Commons Attribution 3.0 Unported License.
Abstract#
Defines an array -> array
codec that permutes the dimensions of the chunk
array.
Status of this document#
ZEP0001 was accepted on May 15th, 2023 via zarr-developers/zarr-specs#227.
Document conventions#
Conformance requirements are expressed with a combination of descriptive assertions and [RFC2119] terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in [RFC2119]. However, for readability, these words do not appear in all uppercase letters in this specification.
All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. Examples in this specification are introduced with the words “for example”.
Codec name#
The value of the name
member in the codec object MUST be transpose
.
Configuration parameters#
- order:
Required. Must be an array of integers specifying a permutation of
0
,1
, …, n-1`, wheren
is the number of dimensions in the decoded chunk representation provided as input to this codec.
Format and algorithm#
This is an array -> array
codec.
Given a chunk array A
with shape A_shape
as the decoded representation,
the encoded representation is an array B
with the same data type as A
and shape B_shape
, where:
B_shape[i] = A_shape[order[i]]
for all dimension indicesi
, andB[B_pos] = A[A_pos]
, whereB_pos[i] = A_pos[order[i]]
, for all chunk positionsA_pos
and dimension indicesi
.
Note
Implementations of this codec may simply construct a virtual view that represents the transposed result, and avoid physically transposing the in-memory representation when possible.
References#
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119
Change log#
Changes after acceptance of ZEP 1#
The order
configuration parameter no longer supports the constants "C"
or "F"
and must instead always be specified as an explicit permutation.