def test_1d_nd_converions(self):
        import datacube.drivers.s3.storage.s3aio as s3aio

        s = s3aio.S3AIO()
        assert s.to_1d((3, 1, 4, 1), (6, 7, 8, 9)) == np.ravel_multi_index(
            (3, 1, 4, 1), (6, 7, 8, 9))
        assert s.to_nd(1621,
                       (6, 7, 8, 9)) == np.unravel_index(1621, (6, 7, 8, 9))
    def test_get_point_without_compression(self, tmpdir):
        import datacube.drivers.s3.storage.s3aio as s3aio

        s = s3aio.S3IO(False, str(tmpdir))
        data = np.arange(4 * 4 * 4, dtype=np.uint8).reshape((4, 4, 4))
        s.put_bytes("arrayio", "array444", bytes(data.data))

        s = s3aio.S3AIO(False, False, str(tmpdir))
        d = s.get_point((0, 0, 0), (4, 4, 4), np.uint8, 'arrayio', 'array444')

        assert d == 0
    def test_get_point_with_compression(self, tmpdir):
        import datacube.drivers.s3.storage.s3aio as s3aio

        s = s3aio.S3IO(False, str(tmpdir))
        data = np.arange(4 * 4 * 4, dtype=np.uint8).reshape((4, 4, 4))
        import zstd
        cctx = zstd.ZstdCompressor(level=9, write_content_size=True)
        data = cctx.compress(data)
        s.put_bytes("arrayio", "array444", bytes(data))

        s = s3aio.S3AIO(True, False, str(tmpdir))
        d = s.get_point((0, 0, 0), (4, 4, 4), np.uint8, 'arrayio', 'array444')

        assert d == 0
    def test_get_slice_without_compression(self, tmpdir):
        import datacube.drivers.s3.storage.s3aio as s3aio

        s = s3aio.S3IO(False, str(tmpdir))

        data = np.arange(4 * 4 * 4, dtype=np.uint8).reshape((4, 4, 4))
        s.put_bytes("arrayio", "array444", bytes(data.data))

        s = s3aio.S3AIO(False, False, str(tmpdir))

        d = s.get_slice((slice(0, 2), slice(0, 4), slice(0, 4)), (4, 4, 4),
                        np.uint8, 'arrayio', 'array444')
        assert np.array_equal(d, data[0:2, 0:4, 0:4])

        d = s.get_slice_mp((slice(0, 2), slice(0, 4), slice(0, 4)), (4, 4, 4),
                           np.uint8, 'arrayio', 'array444')
        assert np.array_equal(d, data[0:2, 0:4, 0:4])

        d = s.get_slice_by_bbox((slice(0, 2), slice(0, 4), slice(0, 4)),
                                (4, 4, 4), np.uint8, 'arrayio', 'array444')
        assert np.array_equal(d, data[0:2, 0:4, 0:4])
    def test_get_slice_with_compression(self, tmpdir):
        import datacube.drivers.s3.storage.s3aio as s3aio

        s = s3aio.S3IO(False, str(tmpdir))

        data = np.arange(4 * 4 * 4, dtype=np.uint8).reshape((4, 4, 4))
        import zstd
        cctx = zstd.ZstdCompressor(level=9, write_content_size=True)
        cdata = cctx.compress(data)
        s.put_bytes("arrayio", "array444", bytes(cdata))

        s = s3aio.S3AIO(True, False, str(tmpdir))

        d = s.get_slice((slice(0, 2), slice(0, 4), slice(0, 4)), (4, 4, 4),
                        np.uint8, 'arrayio', 'array444')
        assert np.array_equal(d, data[0:2, 0:4, 0:4])

        d = s.get_slice_mp((slice(0, 2), slice(0, 4), slice(0, 4)), (4, 4, 4),
                           np.uint8, 'arrayio', 'array444')
        assert np.array_equal(d, data[0:2, 0:4, 0:4])

        d = s.get_slice_by_bbox((slice(0, 2), slice(0, 4), slice(0, 4)),
                                (4, 4, 4), np.uint8, 'arrayio', 'array444')
        assert np.array_equal(d, data[0:2, 0:4, 0:4])
 def test_create_s3aio(self, tmpdir):
     import datacube.drivers.s3.storage.s3aio as s3aio
     s = s3aio.S3AIO()