Skip to content

Commit

Permalink
fixes transpose codec
Browse files Browse the repository at this point in the history
  • Loading branch information
normanrz committed Aug 1, 2023
1 parent e1b2498 commit 8cbf4e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tests/test_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ async def test_order(
runtime_read_order: Literal["F", "C"],
with_sharding: bool,
):
data = np.arange(0, 256, dtype="uint16").reshape((16, 16), order=input_order)
data = np.arange(0, 256, dtype="uint16").reshape((32, 8), order=input_order)

codecs_: List[CodecMetadata] = (
[
codecs.sharding_codec(
(8, 8),
(16, 8),
codecs=[codecs.transpose_codec(store_order), codecs.endian_codec()],
)
]
Expand All @@ -201,7 +201,7 @@ async def test_order(
a = await Array.create_async(
store / "order",
shape=data.shape,
chunk_shape=(16, 16),
chunk_shape=(32, 8),
dtype=data.dtype,
fill_value=0,
chunk_key_encoding=("v2", "."),
Expand Down Expand Up @@ -231,7 +231,7 @@ async def test_order(
# Compare with zarr-python
z = zarr.create(
shape=data.shape,
chunks=(16, 16),
chunks=(32, 8),
dtype="<u2",
order=store_order,
compressor=None,
Expand Down
4 changes: 3 additions & 1 deletion zarrita/codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ async def decode(
if isinstance(new_order, tuple):
chunk_array = chunk_array.transpose(new_order)
elif new_order == "F":
chunk_array = chunk_array.T
chunk_array = chunk_array.ravel().reshape(
self.array_metadata.chunk_shape, order="F"
)
return chunk_array

async def encode(
Expand Down

0 comments on commit 8cbf4e1

Please sign in to comment.