Skip to content

Commit 6f76f5e

Browse files
committed
add reshape codec
split up functions in reshape to make more readable split up resolveOutputShape
1 parent d5552e7 commit 6f76f5e

4 files changed

Lines changed: 655 additions & 0 deletions

File tree

src/main/java/dev/zarr/zarrjava/v3/codec/CodecBuilder.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ public CodecBuilder withTranspose(int[] order) {
6464
return this;
6565
}
6666

67+
/**
68+
* Adds a {@code reshape} codec. Each entry of {@code shape} must be a positive {@link Integer}, the
69+
* special value {@code -1} (at most once), or an {@code int[]} / array of input dimension indices.
70+
*/
71+
public CodecBuilder withReshape(Object[] shape) {
72+
codecs.add(new ReshapeCodec(new ReshapeCodec.Configuration(shape)));
73+
return this;
74+
}
75+
6776
public CodecBuilder withBytes(Endian endian) {
6877
if (dataType.getByteCount() <= 1)
6978
codecs.add(new BytesCodec());

src/main/java/dev/zarr/zarrjava/v3/codec/CodecRegistry.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class CodecRegistry {
1212

1313
static {
1414
addType("transpose", TransposeCodec.class);
15+
addType("reshape", ReshapeCodec.class);
1516
addType("bytes", BytesCodec.class);
1617
addType("blosc", BloscCodec.class);
1718
addType("gzip", GzipCodec.class);

0 commit comments

Comments
 (0)