Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ codecs for use in data storage and communication applications.
.. image:: https://readthedocs.org/projects/numcodecs/badge/?version=latest
:target: http://numcodecs.readthedocs.io/en/latest/?badge=latest

.. image:: https://travis-ci.org/alimanfoo/numcodecs.svg?branch=master
:target: https://travis-ci.org/alimanfoo/numcodecs
.. image:: https://travis-ci.org/zarr-developers/numcodecs.svg?branch=master
:target: https://travis-ci.org/zarr-developers/numcodecs

.. image:: https://ci.appveyor.com/api/projects/status/r35av34952d9fcyn?svg=true
:target: https://ci.appveyor.com/project/alimanfoo/numcodecs
.. image:: https://ci.appveyor.com/api/projects/status/jhaaaxotvel24n9g?svg=true
:target: https://ci.appveyor.com/project/zarr-developers/numcodecs

.. image:: https://coveralls.io/repos/github/alimanfoo/numcodecs/badge.svg?branch=master
:target: https://coveralls.io/github/alimanfoo/numcodecs?branch=master
.. image:: https://coveralls.io/repos/github/zarr-developers/numcodecs/badge.svg?branch=master
:target: https://coveralls.io/github/zarr-developers/numcodecs?branch=master
Binary file modified fixture/gzip/array.02.npy
Binary file not shown.
Binary file modified fixture/gzip/array.03.npy
Binary file not shown.
Binary file modified fixture/gzip/array.04.npy
Binary file not shown.
Binary file modified fixture/gzip/array.05.npy
Binary file not shown.
Binary file modified fixture/gzip/array.06.npy
Binary file not shown.
Binary file modified fixture/gzip/array.07.npy
Binary file not shown.
Binary file modified fixture/gzip/array.08.npy
Binary file not shown.
Binary file modified fixture/gzip/codec.00/encoded.00.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.00/encoded.01.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.00/encoded.02.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.00/encoded.03.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.00/encoded.04.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.00/encoded.05.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.00/encoded.06.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.00/encoded.07.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.00/encoded.08.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.01/encoded.00.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.01/encoded.01.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.01/encoded.02.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.01/encoded.03.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.01/encoded.04.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.01/encoded.05.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.01/encoded.06.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.01/encoded.07.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.01/encoded.08.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.02/encoded.00.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.02/encoded.01.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.02/encoded.02.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.02/encoded.03.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.02/encoded.04.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.02/encoded.05.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.02/encoded.06.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.02/encoded.07.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.02/encoded.08.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.03/encoded.00.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.03/encoded.01.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.03/encoded.02.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.03/encoded.03.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.03/encoded.04.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.03/encoded.05.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.03/encoded.06.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.03/encoded.07.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.03/encoded.08.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.04/encoded.00.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.04/encoded.01.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.04/encoded.02.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.04/encoded.03.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.04/encoded.04.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.04/encoded.05.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.04/encoded.06.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.04/encoded.07.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.04/encoded.08.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.05/encoded.00.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.05/encoded.01.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.05/encoded.02.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.05/encoded.03.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.05/encoded.04.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.05/encoded.05.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.05/encoded.06.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.05/encoded.07.dat
Binary file not shown.
Binary file modified fixture/gzip/codec.05/encoded.08.dat
Binary file not shown.
18 changes: 12 additions & 6 deletions numcodecs/gzip.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, division
import zlib as _zlib
import gzip as _gzip
import io


import numpy as np
Expand Down Expand Up @@ -45,9 +46,12 @@ def encode(self, buf):
buf = buffer_tobytes(buf)

# do compression
compress = _zlib.compressobj(self.level, _zlib.DEFLATED, 16 + 15)
compressed = compress.compress(buf)
compressed += compress.flush()
compressed = io.BytesIO()
with _gzip.GzipFile(fileobj=compressed,
mode='wb',
compresslevel=self.level) as compressor:
compressor.write(buf)
compressed = compressed.getvalue()

return compressed

Expand All @@ -59,9 +63,11 @@ def decode(self, buf, out=None):
buf = buffer_tobytes(buf)

# do decompression
dec = _zlib.decompress(buf, 15 + 32)
buf = io.BytesIO(buf)
with _gzip.GzipFile(fileobj=buf, mode='rb') as decompressor:
decompressed = decompressor.read()

# handle destination - Python standard library zlib module does not
# support direct decompression into buffer, so we have to copy into
# out if given
return buffer_copy(dec, out)
return buffer_copy(decompressed, out)