Skip to content

Commit fb807b9

Browse files
committed
add test for effect of bitshuffle
1 parent 244a1e1 commit fb807b9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

zarr/tests/test_chunk.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,24 @@ def create_chunk(self, **kwargs):
231231
lambda: os.remove(path) if os.path.exists(path) else None
232232
)
233233
return SynchronizedPersistentChunk(**kwargs)
234+
235+
236+
def test_shuffles():
237+
238+
# setup
239+
a = np.arange(256, dtype='u1')
240+
# no shuffle
241+
c0 = Chunk(shape=a.shape, dtype=a.dtype, shuffle=0)
242+
c0[:] = a
243+
# byte shuffle
244+
c1 = Chunk(shape=a.shape, dtype=a.dtype, shuffle=1)
245+
c1[:] = a
246+
# bit shuffle
247+
c2 = Chunk(shape=a.shape, dtype=a.dtype, shuffle=2)
248+
c2[:] = a
249+
250+
# expect no effect of byte shuffle because using single byte dtype
251+
assert c0.cbytes == c1.cbytes
252+
253+
# expect improvement from bitshuffle
254+
assert c2.cbytes < c1.cbytes

0 commit comments

Comments
 (0)