From 45afc4d02a457735ee627223006a735a588d6447 Mon Sep 17 00:00:00 2001 From: Guido Zuidhof Date: Sun, 30 Jun 2019 23:55:12 +0100 Subject: [PATCH] Add zar package, add test --- Dockerfile | 3 +++ tests/test_zarr.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/test_zarr.py diff --git a/Dockerfile b/Dockerfile index db51c0b3..248828cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -131,6 +131,9 @@ RUN apt-get -y install zlib1g-dev liblcms2-dev libwebp-dev libgeos-dev && \ pip install --upgrade numpy && \ pip install gluonnlp && \ pip install gluoncv && \ + # zarr with numcodecs library + pip install zarr && \ + pip install numcodecs && \ # h2o (requires java) # requires java apt-get install -y default-jdk && \ diff --git a/tests/test_zarr.py b/tests/test_zarr.py new file mode 100644 index 00000000..18c253bf --- /dev/null +++ b/tests/test_zarr.py @@ -0,0 +1,16 @@ +import unittest + +import zarr +from numcodecs import Blosc + +class TestZARR(unittest.TestCase): + def test_zarr(self): + z = zarr.zeros((10, 10), chunks=(2, 2), dtype='i4') + z.resize(20, 20) + z[:] = 42 + self.assertEqual(42, z[0,0]) + + def test_zarr_with_specified_compression(self): + compressor = Blosc(cname='zstd', clevel=3, shuffle=Blosc.BITSHUFFLE) + z = zarr.zeros((10, 10), chunks=(2, 2), dtype='i4', compressor=compressor) + self.assertIsNotNone(z.compressor)