From 97fc7c9c3546ac292dfaa514f9717cbedd604888 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Thu, 29 Nov 2018 11:14:47 -0500 Subject: [PATCH 1/4] Ensure `encode` returns a `ndarray` Standardize the output of the `encode` function a bit by ensuring it returns an `ndarray`. This is done without copying as it only takes a view onto the data. Has the advantage of leveraging objects under the hood that might not appear as nice like objects' internal buffers without impacting the user or unnecessarily copying the data to `bytes`. Also makes it a bit easier to work with the output as users can do anything they would normally want to with `ndarray`s. --- numcodecs/blosc.pyx | 5 +++-- numcodecs/bz2.py | 4 ++-- numcodecs/gzip.py | 10 +++++++--- numcodecs/lz4.pyx | 4 ++-- numcodecs/lzma.py | 6 +++--- numcodecs/vlen.pyx | 4 ++-- numcodecs/zlib.py | 4 ++-- numcodecs/zstd.pyx | 4 ++-- 8 files changed, 23 insertions(+), 18 deletions(-) diff --git a/numcodecs/blosc.pyx b/numcodecs/blosc.pyx index e66616da..22491721 100644 --- a/numcodecs/blosc.pyx +++ b/numcodecs/blosc.pyx @@ -16,7 +16,7 @@ from cpython.bytes cimport PyBytes_FromStringAndSize, PyBytes_AS_STRING from .compat_ext cimport Buffer from .compat_ext import Buffer -from .compat import PY2, text_type, ensure_contiguous_ndarray +from .compat import PY2, text_type, ensure_ndarray, ensure_contiguous_ndarray from .abc import Codec @@ -488,7 +488,8 @@ class Blosc(Codec): def encode(self, buf): buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - return compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) + out = compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) + return ensure_ndarray(out) def decode(self, buf, out=None): buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) diff --git a/numcodecs/bz2.py b/numcodecs/bz2.py index 8e34213d..a9685640 100644 --- a/numcodecs/bz2.py +++ b/numcodecs/bz2.py @@ -4,7 +4,7 @@ from numcodecs.abc import Codec -from numcodecs.compat import ndarray_copy, ensure_contiguous_ndarray +from numcodecs.compat import ndarray_copy, ensure_ndarray, ensure_contiguous_ndarray class BZ2(Codec): @@ -28,7 +28,7 @@ def encode(self, buf): buf = ensure_contiguous_ndarray(buf) # do compression - return _bz2.compress(buf, self.level) + return ensure_ndarray(_bz2.compress(buf, self.level)) # noinspection PyMethodMayBeStatic def decode(self, buf, out=None): diff --git a/numcodecs/gzip.py b/numcodecs/gzip.py index ffba649b..83d76ab6 100644 --- a/numcodecs/gzip.py +++ b/numcodecs/gzip.py @@ -5,7 +5,7 @@ from .abc import Codec -from .compat import ndarray_copy, ensure_contiguous_ndarray, PY2 +from .compat import ndarray_copy, ensure_ndarray, ensure_contiguous_ndarray, PY2 class GZip(Codec): @@ -38,9 +38,13 @@ def encode(self, buf): mode='wb', compresslevel=self.level) as compressor: compressor.write(buf) - compressed = compressed.getvalue() - return compressed + try: + compressed = compressed.getbuffer() + except AttributeError: # pragma: py3 no cover + compressed = compressed.getvalue() + + return ensure_ndarray(compressed) # noinspection PyMethodMayBeStatic def decode(self, buf, out=None): diff --git a/numcodecs/lz4.pyx b/numcodecs/lz4.pyx index ea6289c3..c5c43ebc 100644 --- a/numcodecs/lz4.pyx +++ b/numcodecs/lz4.pyx @@ -13,7 +13,7 @@ from cpython.bytes cimport PyBytes_FromStringAndSize, PyBytes_AS_STRING from .compat_ext cimport Buffer from .compat_ext import Buffer -from .compat import PY2, ensure_contiguous_ndarray +from .compat import PY2, ensure_ndarray, ensure_contiguous_ndarray from .abc import Codec @@ -219,7 +219,7 @@ class LZ4(Codec): def encode(self, buf): buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - return compress(buf, self.acceleration) + return ensure_ndarray(compress(buf, self.acceleration)) def decode(self, buf, out=None): buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) diff --git a/numcodecs/lzma.py b/numcodecs/lzma.py index 4f6d724e..54359c81 100644 --- a/numcodecs/lzma.py +++ b/numcodecs/lzma.py @@ -15,7 +15,7 @@ if _lzma: from .abc import Codec - from .compat import ndarray_copy, ensure_contiguous_ndarray + from .compat import ndarray_copy, ensure_ndarray, ensure_contiguous_ndarray # noinspection PyShadowingBuiltins class LZMA(Codec): @@ -51,8 +51,8 @@ def encode(self, buf): buf = ensure_contiguous_ndarray(buf) # do compression - return _lzma.compress(buf, format=self.format, check=self.check, - preset=self.preset, filters=self.filters) + return ensure_ndarray(_lzma.compress(buf, format=self.format, check=self.check, + preset=self.preset, filters=self.filters)) def decode(self, buf, out=None): diff --git a/numcodecs/vlen.pyx b/numcodecs/vlen.pyx index 2e838eb9..5cc90490 100644 --- a/numcodecs/vlen.pyx +++ b/numcodecs/vlen.pyx @@ -13,7 +13,7 @@ import numpy as np from .abc import Codec from .compat_ext cimport Buffer from .compat_ext import Buffer -from .compat import ensure_contiguous_ndarray +from .compat import ensure_ndarray, ensure_contiguous_ndarray from cpython cimport (PyBytes_GET_SIZE, PyBytes_AS_STRING, PyBytes_Check, PyBytes_FromStringAndSize, PyUnicode_AsUTF8String) from cpython.buffer cimport PyBUF_ANY_CONTIGUOUS @@ -130,7 +130,7 @@ class VLenUTF8(Codec): memcpy(data, encv, l) data += l - return out + return ensure_ndarray(out) @cython.wraparound(False) @cython.boundscheck(False) diff --git a/numcodecs/zlib.py b/numcodecs/zlib.py index 382225bb..70f1d81f 100644 --- a/numcodecs/zlib.py +++ b/numcodecs/zlib.py @@ -4,7 +4,7 @@ from .abc import Codec -from .compat import ndarray_copy, ensure_contiguous_ndarray +from .compat import ndarray_copy, ensure_ndarray, ensure_contiguous_ndarray class Zlib(Codec): @@ -28,7 +28,7 @@ def encode(self, buf): buf = ensure_contiguous_ndarray(buf) # do compression - return _zlib.compress(buf, self.level) + return ensure_ndarray(_zlib.compress(buf, self.level)) # noinspection PyMethodMayBeStatic def decode(self, buf, out=None): diff --git a/numcodecs/zstd.pyx b/numcodecs/zstd.pyx index 3fc2e99a..f6f50117 100644 --- a/numcodecs/zstd.pyx +++ b/numcodecs/zstd.pyx @@ -13,7 +13,7 @@ from cpython.bytes cimport PyBytes_FromStringAndSize, PyBytes_AS_STRING from .compat_ext cimport Buffer from .compat_ext import Buffer -from .compat import ensure_contiguous_ndarray +from .compat import ensure_ndarray, ensure_contiguous_ndarray from .abc import Codec @@ -214,7 +214,7 @@ class Zstd(Codec): def encode(self, buf): buf = ensure_contiguous_ndarray(buf) - return compress(buf, self.level) + return ensure_ndarray(compress(buf, self.level)) def decode(self, buf, out=None): buf = ensure_contiguous_ndarray(buf) From f1ed57b66d62218002519abea87f0315b0037a35 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Thu, 29 Nov 2018 11:14:48 -0500 Subject: [PATCH 2/4] Return `ndarray`s from `decode` where possible Where possible, ensure that `decode` returns an `ndarray`. Many codecs already do this except for some unusual ones that work with Python objects or text data. In the cases where the data is known to be binary, try to return `ndarray`s. This makes it pretty easy for end users of this data to do whatever they would like with it. --- numcodecs/blosc.pyx | 3 ++- numcodecs/lz4.pyx | 2 +- numcodecs/zstd.pyx | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/numcodecs/blosc.pyx b/numcodecs/blosc.pyx index 22491721..a7244903 100644 --- a/numcodecs/blosc.pyx +++ b/numcodecs/blosc.pyx @@ -493,7 +493,8 @@ class Blosc(Codec): def decode(self, buf, out=None): buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - return decompress(buf, out) + out = decompress(buf, out) + return ensure_ndarray(out) def __repr__(self): r = '%s(cname=%r, clevel=%r, shuffle=%s, blocksize=%s)' % \ diff --git a/numcodecs/lz4.pyx b/numcodecs/lz4.pyx index c5c43ebc..092d83f3 100644 --- a/numcodecs/lz4.pyx +++ b/numcodecs/lz4.pyx @@ -223,7 +223,7 @@ class LZ4(Codec): def decode(self, buf, out=None): buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - return decompress(buf, out) + return ensure_ndarray(decompress(buf, out)) def __repr__(self): r = '%s(acceleration=%r)' % \ diff --git a/numcodecs/zstd.pyx b/numcodecs/zstd.pyx index f6f50117..571b489f 100644 --- a/numcodecs/zstd.pyx +++ b/numcodecs/zstd.pyx @@ -218,7 +218,7 @@ class Zstd(Codec): def decode(self, buf, out=None): buf = ensure_contiguous_ndarray(buf) - return decompress(buf, out) + return ensure_ndarray(decompress(buf, out)) def __repr__(self): r = '%s(level=%r)' % \ From 90505c9ab294dd03e0776a5fb6b21ffdf8257327 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Thu, 29 Nov 2018 11:14:49 -0500 Subject: [PATCH 3/4] Regenerate C files from Cython files --- numcodecs/blosc.c | 300 ++++++++++++++++++++++++++++------------------ numcodecs/lz4.c | 222 +++++++++++++++++++++------------- numcodecs/vlen.c | 107 ++++++++++------- numcodecs/zstd.c | 268 ++++++++++++++++++++++++----------------- 4 files changed, 549 insertions(+), 348 deletions(-) diff --git a/numcodecs/blosc.c b/numcodecs/blosc.c index 4b3a0638..31653f3e 100644 --- a/numcodecs/blosc.c +++ b/numcodecs/blosc.c @@ -33,72 +33,72 @@ "include_dirs": [ "c-blosc/blosc", "c-blosc/internal-complibs/lz4-1.8.1.2", + "c-blosc/internal-complibs/snappy-1.1.1", "c-blosc/internal-complibs/zlib-1.2.8", "c-blosc/internal-complibs/zstd-1.3.4", - "c-blosc/internal-complibs/snappy-1.1.1", + "c-blosc/internal-complibs/zstd-1.3.4/common", "c-blosc/internal-complibs/zstd-1.3.4/compress", - "c-blosc/internal-complibs/zstd-1.3.4/legacy", + "c-blosc/internal-complibs/zstd-1.3.4/decompress", "c-blosc/internal-complibs/zstd-1.3.4/deprecated", "c-blosc/internal-complibs/zstd-1.3.4/dictBuilder", - "c-blosc/internal-complibs/zstd-1.3.4/decompress", - "c-blosc/internal-complibs/zstd-1.3.4/common", - "c-blosc/internal-complibs/zstd-1.3.4/dll" + "c-blosc/internal-complibs/zstd-1.3.4/dll", + "c-blosc/internal-complibs/zstd-1.3.4/legacy" ], "name": "numcodecs.blosc", "sources": [ "numcodecs/blosc.pyx", - "c-blosc/blosc/fastcopy.c", - "c-blosc/blosc/blosc.c", - "c-blosc/blosc/shuffle.c", "c-blosc/blosc/bitshuffle-generic.c", - "c-blosc/blosc/shuffle-generic.c", + "c-blosc/blosc/blosc.c", "c-blosc/blosc/blosclz.c", + "c-blosc/blosc/fastcopy.c", + "c-blosc/blosc/shuffle-generic.c", + "c-blosc/blosc/shuffle.c", "c-blosc/internal-complibs/lz4-1.8.1.2/lz4.c", "c-blosc/internal-complibs/lz4-1.8.1.2/lz4hc.c", - "c-blosc/internal-complibs/snappy-1.1.1/snappy.cc", + "c-blosc/internal-complibs/snappy-1.1.1/snappy-c.cc", "c-blosc/internal-complibs/snappy-1.1.1/snappy-sinksource.cc", "c-blosc/internal-complibs/snappy-1.1.1/snappy-stubs-internal.cc", - "c-blosc/internal-complibs/snappy-1.1.1/snappy-c.cc", - "c-blosc/internal-complibs/zlib-1.2.8/zutil.c", - "c-blosc/internal-complibs/zlib-1.2.8/compress.c", - "c-blosc/internal-complibs/zlib-1.2.8/inftrees.c", + "c-blosc/internal-complibs/snappy-1.1.1/snappy.cc", "c-blosc/internal-complibs/zlib-1.2.8/adler32.c", - "c-blosc/internal-complibs/zlib-1.2.8/inffast.c", + "c-blosc/internal-complibs/zlib-1.2.8/compress.c", "c-blosc/internal-complibs/zlib-1.2.8/crc32.c", - "c-blosc/internal-complibs/zlib-1.2.8/trees.c", "c-blosc/internal-complibs/zlib-1.2.8/deflate.c", "c-blosc/internal-complibs/zlib-1.2.8/gzclose.c", - "c-blosc/internal-complibs/zlib-1.2.8/gzwrite.c", - "c-blosc/internal-complibs/zlib-1.2.8/uncompr.c", + "c-blosc/internal-complibs/zlib-1.2.8/gzlib.c", "c-blosc/internal-complibs/zlib-1.2.8/gzread.c", + "c-blosc/internal-complibs/zlib-1.2.8/gzwrite.c", "c-blosc/internal-complibs/zlib-1.2.8/infback.c", - "c-blosc/internal-complibs/zlib-1.2.8/gzlib.c", + "c-blosc/internal-complibs/zlib-1.2.8/inffast.c", "c-blosc/internal-complibs/zlib-1.2.8/inflate.c", - "c-blosc/internal-complibs/zstd-1.3.4/common/error_private.c", - "c-blosc/internal-complibs/zstd-1.3.4/common/xxhash.c", - "c-blosc/internal-complibs/zstd-1.3.4/common/zstd_common.c", + "c-blosc/internal-complibs/zlib-1.2.8/inftrees.c", + "c-blosc/internal-complibs/zlib-1.2.8/trees.c", + "c-blosc/internal-complibs/zlib-1.2.8/uncompr.c", + "c-blosc/internal-complibs/zlib-1.2.8/zutil.c", "c-blosc/internal-complibs/zstd-1.3.4/common/entropy_common.c", + "c-blosc/internal-complibs/zstd-1.3.4/common/error_private.c", "c-blosc/internal-complibs/zstd-1.3.4/common/fse_decompress.c", - "c-blosc/internal-complibs/zstd-1.3.4/common/threading.c", "c-blosc/internal-complibs/zstd-1.3.4/common/pool.c", - "c-blosc/internal-complibs/zstd-1.3.4/compress/huf_compress.c", - "c-blosc/internal-complibs/zstd-1.3.4/compress/zstdmt_compress.c", - "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_lazy.c", - "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_fast.c", - "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_opt.c", - "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_double_fast.c", + "c-blosc/internal-complibs/zstd-1.3.4/common/threading.c", + "c-blosc/internal-complibs/zstd-1.3.4/common/xxhash.c", + "c-blosc/internal-complibs/zstd-1.3.4/common/zstd_common.c", "c-blosc/internal-complibs/zstd-1.3.4/compress/fse_compress.c", + "c-blosc/internal-complibs/zstd-1.3.4/compress/huf_compress.c", "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_compress.c", + "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_double_fast.c", + "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_fast.c", + "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_lazy.c", "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_ldm.c", + "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_opt.c", + "c-blosc/internal-complibs/zstd-1.3.4/compress/zstdmt_compress.c", "c-blosc/internal-complibs/zstd-1.3.4/decompress/huf_decompress.c", "c-blosc/internal-complibs/zstd-1.3.4/decompress/zstd_decompress.c", - "c-blosc/internal-complibs/zstd-1.3.4/dictBuilder/zdict.c", "c-blosc/internal-complibs/zstd-1.3.4/dictBuilder/cover.c", "c-blosc/internal-complibs/zstd-1.3.4/dictBuilder/divsufsort.c", + "c-blosc/internal-complibs/zstd-1.3.4/dictBuilder/zdict.c", "c-blosc/blosc/bitshuffle-sse2.c", "c-blosc/blosc/shuffle-sse2.c", - "c-blosc/blosc/shuffle-avx2.c", - "c-blosc/blosc/bitshuffle-avx2.c" + "c-blosc/blosc/bitshuffle-avx2.c", + "c-blosc/blosc/shuffle-avx2.c" ] }, "module_name": "numcodecs.blosc" @@ -1618,6 +1618,7 @@ static const char __pyx_k_MAX_BUFFERSIZE[] = "MAX_BUFFERSIZE"; static const char __pyx_k_VERSION_STRING[] = "VERSION_STRING"; static const char __pyx_k_compressor_set[] = "compressor_set"; static const char __pyx_k_current_thread[] = "current_thread"; +static const char __pyx_k_ensure_ndarray[] = "ensure_ndarray"; static const char __pyx_k_cbuffer_complib[] = "cbuffer_complib"; static const char __pyx_k_current_process[] = "current_process"; static const char __pyx_k_get_use_threads[] = "_get_use_threads"; @@ -1701,6 +1702,7 @@ static PyObject *__pyx_n_s_destroy; static PyObject *__pyx_n_s_doc; static PyObject *__pyx_n_s_encode; static PyObject *__pyx_n_s_ensure_contiguous_ndarray; +static PyObject *__pyx_n_s_ensure_ndarray; static PyObject *__pyx_n_s_enter; static PyObject *__pyx_n_s_err_bad_cname; static PyObject *__pyx_kp_s_error_during_blosc_compression_d; @@ -5282,7 +5284,7 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc___init__(CYTHON_UNUSED PyObje * * def encode(self, buf): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) + * out = compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) */ /* Python wrapper */ @@ -5349,6 +5351,7 @@ static PyObject *__pyx_pw_9numcodecs_5blosc_5Blosc_3encode(PyObject *__pyx_self, } static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_2encode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_buf) { + PyObject *__pyx_v_out = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -5367,8 +5370,8 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_2encode(CYTHON_UNUSED PyObjec * * def encode(self, buf): * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) # <<<<<<<<<<<<<< - * return compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) - * + * out = compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) + * return ensure_ndarray(out) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ensure_contiguous_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); @@ -5427,11 +5430,10 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_2encode(CYTHON_UNUSED PyObjec /* "numcodecs/blosc.pyx":491 * def encode(self, buf): * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) # <<<<<<<<<<<<<< + * out = compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) # <<<<<<<<<<<<<< + * return ensure_ndarray(out) * - * def decode(self, buf, out=None): */ - __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_compress); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 491, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cname_bytes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 491, __pyx_L1_error) @@ -5504,6 +5506,34 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_2encode(CYTHON_UNUSED PyObjec __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_out = __pyx_t_1; + __pyx_t_1 = 0; + + /* "numcodecs/blosc.pyx":492 + * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) + * out = compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) + * return ensure_ndarray(out) # <<<<<<<<<<<<<< + * + * def decode(self, buf, out=None): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ensure_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 492, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_9 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_9, __pyx_v_out) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_out); + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 492, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; @@ -5513,7 +5543,7 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_2encode(CYTHON_UNUSED PyObjec * * def encode(self, buf): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) + * out = compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) */ /* function exit code */ @@ -5529,18 +5559,19 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_2encode(CYTHON_UNUSED PyObjec __Pyx_AddTraceback("numcodecs.blosc.Blosc.encode", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_out); __Pyx_XDECREF(__pyx_v_buf); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "numcodecs/blosc.pyx":493 - * return compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) +/* "numcodecs/blosc.pyx":494 + * return ensure_ndarray(out) * * def decode(self, buf, out=None): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return decompress(buf, out) + * out = decompress(buf, out) */ /* Python wrapper */ @@ -5580,7 +5611,7 @@ static PyObject *__pyx_pw_9numcodecs_5blosc_5Blosc_5decode(PyObject *__pyx_self, case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("decode", 0, 2, 3, 1); __PYX_ERR(0, 493, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("decode", 0, 2, 3, 1); __PYX_ERR(0, 494, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: @@ -5590,7 +5621,7 @@ static PyObject *__pyx_pw_9numcodecs_5blosc_5Blosc_5decode(PyObject *__pyx_self, } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "decode") < 0)) __PYX_ERR(0, 493, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "decode") < 0)) __PYX_ERR(0, 494, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -5608,7 +5639,7 @@ static PyObject *__pyx_pw_9numcodecs_5blosc_5Blosc_5decode(PyObject *__pyx_self, } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("decode", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 493, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("decode", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 494, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("numcodecs.blosc.Blosc.decode", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -5632,17 +5663,18 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_4decode(CYTHON_UNUSED PyObjec PyObject *__pyx_t_6 = NULL; __Pyx_RefNannySetupContext("decode", 0); __Pyx_INCREF(__pyx_v_buf); + __Pyx_INCREF(__pyx_v_out); - /* "numcodecs/blosc.pyx":494 + /* "numcodecs/blosc.pyx":495 * * def decode(self, buf, out=None): * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) # <<<<<<<<<<<<<< - * return decompress(buf, out) - * + * out = decompress(buf, out) + * return ensure_ndarray(out) */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ensure_contiguous_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 494, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ensure_contiguous_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 495, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_max_buffer_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 494, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_max_buffer_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 495, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; @@ -5659,7 +5691,7 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_4decode(CYTHON_UNUSED PyObjec #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_buf, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 494, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -5668,14 +5700,14 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_4decode(CYTHON_UNUSED PyObjec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_buf, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 494, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { - __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 494, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 495, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; @@ -5686,7 +5718,7 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_4decode(CYTHON_UNUSED PyObjec __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_3); __pyx_t_3 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 494, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } @@ -5694,15 +5726,14 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_4decode(CYTHON_UNUSED PyObjec __Pyx_DECREF_SET(__pyx_v_buf, __pyx_t_1); __pyx_t_1 = 0; - /* "numcodecs/blosc.pyx":495 + /* "numcodecs/blosc.pyx":496 * def decode(self, buf, out=None): * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return decompress(buf, out) # <<<<<<<<<<<<<< + * out = decompress(buf, out) # <<<<<<<<<<<<<< + * return ensure_ndarray(out) * - * def __repr__(self): */ - __Pyx_XDECREF(__pyx_r); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_decompress); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 495, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_decompress); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 496, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = NULL; __pyx_t_5 = 0; @@ -5719,7 +5750,7 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_4decode(CYTHON_UNUSED PyObjec #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_buf, __pyx_v_out}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); } else @@ -5727,13 +5758,13 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_4decode(CYTHON_UNUSED PyObjec #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_buf, __pyx_v_out}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { - __pyx_t_3 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 495, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 496, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL; @@ -5744,21 +5775,49 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_4decode(CYTHON_UNUSED PyObjec __Pyx_INCREF(__pyx_v_out); __Pyx_GIVEREF(__pyx_v_out); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_5, __pyx_v_out); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_out, __pyx_t_1); + __pyx_t_1 = 0; + + /* "numcodecs/blosc.pyx":497 + * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) + * out = decompress(buf, out) + * return ensure_ndarray(out) # <<<<<<<<<<<<<< + * + * def __repr__(self): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ensure_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 497, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_out) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_out); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 497, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "numcodecs/blosc.pyx":493 - * return compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) + /* "numcodecs/blosc.pyx":494 + * return ensure_ndarray(out) * * def decode(self, buf, out=None): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return decompress(buf, out) + * out = decompress(buf, out) */ /* function exit code */ @@ -5772,13 +5831,14 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_4decode(CYTHON_UNUSED PyObjec __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_buf); + __Pyx_XDECREF(__pyx_v_out); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "numcodecs/blosc.pyx":497 - * return decompress(buf, out) +/* "numcodecs/blosc.pyx":499 + * return ensure_ndarray(out) * * def __repr__(self): # <<<<<<<<<<<<<< * r = '%s(cname=%r, clevel=%r, shuffle=%s, blocksize=%s)' % \ @@ -5812,72 +5872,72 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_6__repr__(CYTHON_UNUSED PyObj PyObject *__pyx_t_6 = NULL; __Pyx_RefNannySetupContext("__repr__", 0); - /* "numcodecs/blosc.pyx":499 + /* "numcodecs/blosc.pyx":501 * def __repr__(self): * r = '%s(cname=%r, clevel=%r, shuffle=%s, blocksize=%s)' % \ * (type(self).__name__, # <<<<<<<<<<<<<< * self.cname, * self.clevel, */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_self)), __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 499, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_self)), __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 501, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - /* "numcodecs/blosc.pyx":500 + /* "numcodecs/blosc.pyx":502 * r = '%s(cname=%r, clevel=%r, shuffle=%s, blocksize=%s)' % \ * (type(self).__name__, * self.cname, # <<<<<<<<<<<<<< * self.clevel, * _shuffle_repr[self.shuffle + 1], */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cname); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 500, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cname); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 502, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - /* "numcodecs/blosc.pyx":501 + /* "numcodecs/blosc.pyx":503 * (type(self).__name__, * self.cname, * self.clevel, # <<<<<<<<<<<<<< * _shuffle_repr[self.shuffle + 1], * self.blocksize) */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_clevel); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 501, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_clevel); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - /* "numcodecs/blosc.pyx":502 + /* "numcodecs/blosc.pyx":504 * self.cname, * self.clevel, * _shuffle_repr[self.shuffle + 1], # <<<<<<<<<<<<<< * self.blocksize) * return r */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_shuffle_repr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 502, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_shuffle_repr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 502, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_t_5, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 502, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_t_5, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 502, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "numcodecs/blosc.pyx":503 + /* "numcodecs/blosc.pyx":505 * self.clevel, * _shuffle_repr[self.shuffle + 1], * self.blocksize) # <<<<<<<<<<<<<< * return r */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_blocksize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 503, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_blocksize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - /* "numcodecs/blosc.pyx":499 + /* "numcodecs/blosc.pyx":501 * def __repr__(self): * r = '%s(cname=%r, clevel=%r, shuffle=%s, blocksize=%s)' % \ * (type(self).__name__, # <<<<<<<<<<<<<< * self.cname, * self.clevel, */ - __pyx_t_4 = PyTuple_New(5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 499, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 501, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); @@ -5895,20 +5955,20 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_6__repr__(CYTHON_UNUSED PyObj __pyx_t_5 = 0; __pyx_t_6 = 0; - /* "numcodecs/blosc.pyx":498 + /* "numcodecs/blosc.pyx":500 * * def __repr__(self): * r = '%s(cname=%r, clevel=%r, shuffle=%s, blocksize=%s)' % \ # <<<<<<<<<<<<<< * (type(self).__name__, * self.cname, */ - __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s_cname_r_clevel_r_shuffle_s_bl, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 498, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s_cname_r_clevel_r_shuffle_s_bl, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 500, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_r = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; - /* "numcodecs/blosc.pyx":504 + /* "numcodecs/blosc.pyx":506 * _shuffle_repr[self.shuffle + 1], * self.blocksize) * return r # <<<<<<<<<<<<<< @@ -5918,8 +5978,8 @@ static PyObject *__pyx_pf_9numcodecs_5blosc_5Blosc_6__repr__(CYTHON_UNUSED PyObj __pyx_r = __pyx_v_r; goto __pyx_L0; - /* "numcodecs/blosc.pyx":497 - * return decompress(buf, out) + /* "numcodecs/blosc.pyx":499 + * return ensure_ndarray(out) * * def __repr__(self): # <<<<<<<<<<<<<< * r = '%s(cname=%r, clevel=%r, shuffle=%s, blocksize=%s)' % \ @@ -6053,6 +6113,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, {&__pyx_n_s_ensure_contiguous_ndarray, __pyx_k_ensure_contiguous_ndarray, sizeof(__pyx_k_ensure_contiguous_ndarray), 0, 0, 1, 1}, + {&__pyx_n_s_ensure_ndarray, __pyx_k_ensure_ndarray, sizeof(__pyx_k_ensure_ndarray), 0, 0, 1, 1}, {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1}, {&__pyx_n_s_err_bad_cname, __pyx_k_err_bad_cname, sizeof(__pyx_k_err_bad_cname), 0, 0, 1, 1}, {&__pyx_kp_s_error_during_blosc_compression_d, __pyx_k_error_during_blosc_compression_d, sizeof(__pyx_k_error_during_blosc_compression_d), 0, 0, 1, 0}, @@ -6301,39 +6362,39 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * * def encode(self, buf): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) + * out = compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) */ - __pyx_tuple__30 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_buf); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 489, __pyx_L1_error) + __pyx_tuple__30 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_buf, __pyx_n_s_out); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 489, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__30); __Pyx_GIVEREF(__pyx_tuple__30); - __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numcodecs_blosc_pyx, __pyx_n_s_encode, 489, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 489, __pyx_L1_error) + __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numcodecs_blosc_pyx, __pyx_n_s_encode, 489, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 489, __pyx_L1_error) - /* "numcodecs/blosc.pyx":493 - * return compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) + /* "numcodecs/blosc.pyx":494 + * return ensure_ndarray(out) * * def decode(self, buf, out=None): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return decompress(buf, out) + * out = decompress(buf, out) */ - __pyx_tuple__32 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_buf, __pyx_n_s_out); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 493, __pyx_L1_error) + __pyx_tuple__32 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_buf, __pyx_n_s_out); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 494, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__32); __Pyx_GIVEREF(__pyx_tuple__32); - __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numcodecs_blosc_pyx, __pyx_n_s_decode, 493, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 493, __pyx_L1_error) - __pyx_tuple__34 = PyTuple_Pack(1, ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 493, __pyx_L1_error) + __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numcodecs_blosc_pyx, __pyx_n_s_decode, 494, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 494, __pyx_L1_error) + __pyx_tuple__34 = PyTuple_Pack(1, ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 494, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__34); __Pyx_GIVEREF(__pyx_tuple__34); - /* "numcodecs/blosc.pyx":497 - * return decompress(buf, out) + /* "numcodecs/blosc.pyx":499 + * return ensure_ndarray(out) * * def __repr__(self): # <<<<<<<<<<<<<< * r = '%s(cname=%r, clevel=%r, shuffle=%s, blocksize=%s)' % \ * (type(self).__name__, */ - __pyx_tuple__35 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_r); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 497, __pyx_L1_error) + __pyx_tuple__35 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_r); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 499, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__35); __Pyx_GIVEREF(__pyx_tuple__35); - __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numcodecs_blosc_pyx, __pyx_n_s_repr, 497, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 497, __pyx_L1_error) + __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numcodecs_blosc_pyx, __pyx_n_s_repr, 499, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 499, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -6685,7 +6746,7 @@ if (!__Pyx_RefNanny) { * * from .compat_ext cimport Buffer * from .compat_ext import Buffer # <<<<<<<<<<<<<< - * from .compat import PY2, text_type, ensure_contiguous_ndarray + * from .compat import PY2, text_type, ensure_ndarray, ensure_contiguous_ndarray * from .abc import Codec */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error) @@ -6701,11 +6762,11 @@ if (!__Pyx_RefNanny) { /* "numcodecs/blosc.pyx":19 * from .compat_ext cimport Buffer * from .compat_ext import Buffer - * from .compat import PY2, text_type, ensure_contiguous_ndarray # <<<<<<<<<<<<<< + * from .compat import PY2, text_type, ensure_ndarray, ensure_contiguous_ndarray # <<<<<<<<<<<<<< * from .abc import Codec * */ - __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error) + __pyx_t_2 = PyList_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_PY2); __Pyx_GIVEREF(__pyx_n_s_PY2); @@ -6713,9 +6774,12 @@ if (!__Pyx_RefNanny) { __Pyx_INCREF(__pyx_n_s_text_type); __Pyx_GIVEREF(__pyx_n_s_text_type); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_text_type); + __Pyx_INCREF(__pyx_n_s_ensure_ndarray); + __Pyx_GIVEREF(__pyx_n_s_ensure_ndarray); + PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_ensure_ndarray); __Pyx_INCREF(__pyx_n_s_ensure_contiguous_ndarray); __Pyx_GIVEREF(__pyx_n_s_ensure_contiguous_ndarray); - PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_ensure_contiguous_ndarray); + PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_s_ensure_contiguous_ndarray); __pyx_t_1 = __Pyx_Import(__pyx_n_s_compat, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -6727,6 +6791,10 @@ if (!__Pyx_RefNanny) { __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_text_type, __pyx_t_2) < 0) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ensure_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ensure_ndarray, __pyx_t_2) < 0) __PYX_ERR(0, 19, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ensure_contiguous_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ensure_contiguous_ndarray, __pyx_t_2) < 0) __PYX_ERR(0, 19, __pyx_L1_error) @@ -6735,7 +6803,7 @@ if (!__Pyx_RefNanny) { /* "numcodecs/blosc.pyx":20 * from .compat_ext import Buffer - * from .compat import PY2, text_type, ensure_contiguous_ndarray + * from .compat import PY2, text_type, ensure_ndarray, ensure_contiguous_ndarray * from .abc import Codec # <<<<<<<<<<<<<< * * @@ -7408,36 +7476,36 @@ if (!__Pyx_RefNanny) { * * def encode(self, buf): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) + * out = compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) */ __pyx_t_10 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9numcodecs_5blosc_5Blosc_3encode, 0, __pyx_n_s_Blosc_encode, NULL, __pyx_n_s_numcodecs_blosc, __pyx_d, ((PyObject *)__pyx_codeobj__31)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_encode, __pyx_t_10) < 0) __PYX_ERR(0, 489, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "numcodecs/blosc.pyx":493 - * return compress(buf, self._cname_bytes, self.clevel, self.shuffle, self.blocksize) + /* "numcodecs/blosc.pyx":494 + * return ensure_ndarray(out) * * def decode(self, buf, out=None): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return decompress(buf, out) + * out = decompress(buf, out) */ - __pyx_t_10 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9numcodecs_5blosc_5Blosc_5decode, 0, __pyx_n_s_Blosc_decode, NULL, __pyx_n_s_numcodecs_blosc, __pyx_d, ((PyObject *)__pyx_codeobj__33)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 493, __pyx_L1_error) + __pyx_t_10 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9numcodecs_5blosc_5Blosc_5decode, 0, __pyx_n_s_Blosc_decode, NULL, __pyx_n_s_numcodecs_blosc, __pyx_d, ((PyObject *)__pyx_codeobj__33)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 494, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_10, __pyx_tuple__34); - if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_decode, __pyx_t_10) < 0) __PYX_ERR(0, 493, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_decode, __pyx_t_10) < 0) __PYX_ERR(0, 494, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "numcodecs/blosc.pyx":497 - * return decompress(buf, out) + /* "numcodecs/blosc.pyx":499 + * return ensure_ndarray(out) * * def __repr__(self): # <<<<<<<<<<<<<< * r = '%s(cname=%r, clevel=%r, shuffle=%s, blocksize=%s)' % \ * (type(self).__name__, */ - __pyx_t_10 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9numcodecs_5blosc_5Blosc_7__repr__, 0, __pyx_n_s_Blosc___repr, NULL, __pyx_n_s_numcodecs_blosc, __pyx_d, ((PyObject *)__pyx_codeobj__36)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 497, __pyx_L1_error) + __pyx_t_10 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9numcodecs_5blosc_5Blosc_7__repr__, 0, __pyx_n_s_Blosc___repr, NULL, __pyx_n_s_numcodecs_blosc, __pyx_d, ((PyObject *)__pyx_codeobj__36)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 499, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_repr, __pyx_t_10) < 0) __PYX_ERR(0, 497, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_repr, __pyx_t_10) < 0) __PYX_ERR(0, 499, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "numcodecs/blosc.pyx":448 diff --git a/numcodecs/lz4.c b/numcodecs/lz4.c index 4a6d18b2..19acdac3 100644 --- a/numcodecs/lz4.c +++ b/numcodecs/lz4.c @@ -1361,6 +1361,7 @@ static const char __pyx_k_numcodecs_lz4[] = "numcodecs.lz4"; static const char __pyx_k_source_buffer[] = "source_buffer"; static const char __pyx_k_VERSION_STRING[] = "VERSION_STRING"; static const char __pyx_k_bad_input_data[] = "bad input data"; +static const char __pyx_k_ensure_ndarray[] = "ensure_ndarray"; static const char __pyx_k_compressed_size[] = "compressed_size"; static const char __pyx_k_max_buffer_size[] = "max_buffer_size"; static const char __pyx_k_s_acceleration_r[] = "%s(acceleration=%r)"; @@ -1416,6 +1417,7 @@ static PyObject *__pyx_kp_s_destination_buffer_too_small_exp; static PyObject *__pyx_n_s_doc; static PyObject *__pyx_n_s_encode; static PyObject *__pyx_n_s_ensure_contiguous_ndarray; +static PyObject *__pyx_n_s_ensure_ndarray; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_init; static PyObject *__pyx_n_s_lz4; @@ -2793,7 +2795,7 @@ static PyObject *__pyx_pf_9numcodecs_3lz4_3LZ4___init__(CYTHON_UNUSED PyObject * * * def encode(self, buf): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return compress(buf, self.acceleration) + * return ensure_ndarray(compress(buf, self.acceleration)) */ /* Python wrapper */ @@ -2868,6 +2870,8 @@ static PyObject *__pyx_pf_9numcodecs_3lz4_3LZ4_2encode(CYTHON_UNUSED PyObject *_ PyObject *__pyx_t_4 = NULL; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("encode", 0); __Pyx_INCREF(__pyx_v_buf); @@ -2875,7 +2879,7 @@ static PyObject *__pyx_pf_9numcodecs_3lz4_3LZ4_2encode(CYTHON_UNUSED PyObject *_ * * def encode(self, buf): * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) # <<<<<<<<<<<<<< - * return compress(buf, self.acceleration) + * return ensure_ndarray(compress(buf, self.acceleration)) * */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ensure_contiguous_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L1_error) @@ -2935,61 +2939,79 @@ static PyObject *__pyx_pf_9numcodecs_3lz4_3LZ4_2encode(CYTHON_UNUSED PyObject *_ /* "numcodecs/lz4.pyx":222 * def encode(self, buf): * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return compress(buf, self.acceleration) # <<<<<<<<<<<<<< + * return ensure_ndarray(compress(buf, self.acceleration)) # <<<<<<<<<<<<<< * * def decode(self, buf, out=None): */ __Pyx_XDECREF(__pyx_r); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_compress); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ensure_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_acceleration); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 222, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = NULL; + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_compress); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_acceleration); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = NULL; __pyx_t_5 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_7)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); + __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_buf, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_buf, __pyx_t_4}; + __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_buf, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_buf, __pyx_t_4}; + __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { - __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 222, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (__pyx_t_3) { - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; + __pyx_t_8 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_7) { + __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_v_buf); __Pyx_GIVEREF(__pyx_v_buf); - PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_buf); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_5, __pyx_v_buf); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_5, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } } + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3000,7 +3022,7 @@ static PyObject *__pyx_pf_9numcodecs_3lz4_3LZ4_2encode(CYTHON_UNUSED PyObject *_ * * def encode(self, buf): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return compress(buf, self.acceleration) + * return ensure_ndarray(compress(buf, self.acceleration)) */ /* function exit code */ @@ -3010,6 +3032,8 @@ static PyObject *__pyx_pf_9numcodecs_3lz4_3LZ4_2encode(CYTHON_UNUSED PyObject *_ __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("numcodecs.lz4.LZ4.encode", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -3020,11 +3044,11 @@ static PyObject *__pyx_pf_9numcodecs_3lz4_3LZ4_2encode(CYTHON_UNUSED PyObject *_ } /* "numcodecs/lz4.pyx":224 - * return compress(buf, self.acceleration) + * return ensure_ndarray(compress(buf, self.acceleration)) * * def decode(self, buf, out=None): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) */ /* Python wrapper */ @@ -3114,6 +3138,7 @@ static PyObject *__pyx_pf_9numcodecs_3lz4_3LZ4_4decode(CYTHON_UNUSED PyObject *_ PyObject *__pyx_t_4 = NULL; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("decode", 0); __Pyx_INCREF(__pyx_v_buf); @@ -3121,7 +3146,7 @@ static PyObject *__pyx_pf_9numcodecs_3lz4_3LZ4_4decode(CYTHON_UNUSED PyObject *_ * * def decode(self, buf, out=None): * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) # <<<<<<<<<<<<<< - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) * */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ensure_contiguous_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 225, __pyx_L1_error) @@ -3181,68 +3206,86 @@ static PyObject *__pyx_pf_9numcodecs_3lz4_3LZ4_4decode(CYTHON_UNUSED PyObject *_ /* "numcodecs/lz4.pyx":226 * def decode(self, buf, out=None): * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return decompress(buf, out) # <<<<<<<<<<<<<< + * return ensure_ndarray(decompress(buf, out)) # <<<<<<<<<<<<<< * * def __repr__(self): */ __Pyx_XDECREF(__pyx_r); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_decompress); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ensure_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = NULL; + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_decompress); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = NULL; __pyx_t_5 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_6); + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); + __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_buf, __pyx_v_out}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_buf, __pyx_v_out}; + __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 226, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_6); } else #endif #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_buf, __pyx_v_out}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_buf, __pyx_v_out}; + __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 226, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_6); } else #endif { - __pyx_t_3 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 226, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL; + __pyx_t_7 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_4) { + __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_v_buf); __Pyx_GIVEREF(__pyx_v_buf); - PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_5, __pyx_v_buf); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_5, __pyx_v_buf); __Pyx_INCREF(__pyx_v_out); __Pyx_GIVEREF(__pyx_v_out); - PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_5, __pyx_v_out); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_5, __pyx_v_out); + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } } + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "numcodecs/lz4.pyx":224 - * return compress(buf, self.acceleration) + * return ensure_ndarray(compress(buf, self.acceleration)) * * def decode(self, buf, out=None): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) */ /* function exit code */ @@ -3252,6 +3295,7 @@ static PyObject *__pyx_pf_9numcodecs_3lz4_3LZ4_4decode(CYTHON_UNUSED PyObject *_ __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("numcodecs.lz4.LZ4.decode", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -3262,7 +3306,7 @@ static PyObject *__pyx_pf_9numcodecs_3lz4_3LZ4_4decode(CYTHON_UNUSED PyObject *_ } /* "numcodecs/lz4.pyx":228 - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) * * def __repr__(self): # <<<<<<<<<<<<<< * r = '%s(acceleration=%r)' % \ @@ -3352,7 +3396,7 @@ static PyObject *__pyx_pf_9numcodecs_3lz4_3LZ4_6__repr__(CYTHON_UNUSED PyObject goto __pyx_L0; /* "numcodecs/lz4.pyx":228 - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) * * def __repr__(self): # <<<<<<<<<<<<<< * r = '%s(acceleration=%r)' % \ @@ -3460,6 +3504,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, {&__pyx_n_s_ensure_contiguous_ndarray, __pyx_k_ensure_contiguous_ndarray, sizeof(__pyx_k_ensure_contiguous_ndarray), 0, 0, 1, 1}, + {&__pyx_n_s_ensure_ndarray, __pyx_k_ensure_ndarray, sizeof(__pyx_k_ensure_ndarray), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1}, {&__pyx_n_s_lz4, __pyx_k_lz4, sizeof(__pyx_k_lz4), 0, 0, 1, 1}, @@ -3562,7 +3607,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * * def encode(self, buf): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return compress(buf, self.acceleration) + * return ensure_ndarray(compress(buf, self.acceleration)) */ __pyx_tuple__10 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_buf); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 220, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); @@ -3570,11 +3615,11 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numcodecs_lz4_pyx, __pyx_n_s_encode, 220, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 220, __pyx_L1_error) /* "numcodecs/lz4.pyx":224 - * return compress(buf, self.acceleration) + * return ensure_ndarray(compress(buf, self.acceleration)) * * def decode(self, buf, out=None): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) */ __pyx_tuple__12 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_buf, __pyx_n_s_out); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__12); @@ -3585,7 +3630,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GIVEREF(__pyx_tuple__14); /* "numcodecs/lz4.pyx":228 - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) * * def __repr__(self): # <<<<<<<<<<<<<< * r = '%s(acceleration=%r)' % \ @@ -3904,7 +3949,7 @@ if (!__Pyx_RefNanny) { * * from .compat_ext cimport Buffer * from .compat_ext import Buffer # <<<<<<<<<<<<<< - * from .compat import PY2, ensure_contiguous_ndarray + * from .compat import PY2, ensure_ndarray, ensure_contiguous_ndarray * from .abc import Codec */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error) @@ -3920,18 +3965,21 @@ if (!__Pyx_RefNanny) { /* "numcodecs/lz4.pyx":16 * from .compat_ext cimport Buffer * from .compat_ext import Buffer - * from .compat import PY2, ensure_contiguous_ndarray # <<<<<<<<<<<<<< + * from .compat import PY2, ensure_ndarray, ensure_contiguous_ndarray # <<<<<<<<<<<<<< * from .abc import Codec * */ - __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) + __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_PY2); __Pyx_GIVEREF(__pyx_n_s_PY2); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PY2); + __Pyx_INCREF(__pyx_n_s_ensure_ndarray); + __Pyx_GIVEREF(__pyx_n_s_ensure_ndarray); + PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_ensure_ndarray); __Pyx_INCREF(__pyx_n_s_ensure_contiguous_ndarray); __Pyx_GIVEREF(__pyx_n_s_ensure_contiguous_ndarray); - PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_ensure_contiguous_ndarray); + PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_ensure_contiguous_ndarray); __pyx_t_1 = __Pyx_Import(__pyx_n_s_compat, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -3939,6 +3987,10 @@ if (!__Pyx_RefNanny) { __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_PY2, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ensure_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ensure_ndarray, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ensure_contiguous_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ensure_contiguous_ndarray, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error) @@ -3947,7 +3999,7 @@ if (!__Pyx_RefNanny) { /* "numcodecs/lz4.pyx":17 * from .compat_ext import Buffer - * from .compat import PY2, ensure_contiguous_ndarray + * from .compat import PY2, ensure_ndarray, ensure_contiguous_ndarray * from .abc import Codec # <<<<<<<<<<<<<< * * @@ -4135,7 +4187,7 @@ if (!__Pyx_RefNanny) { * * def encode(self, buf): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return compress(buf, self.acceleration) + * return ensure_ndarray(compress(buf, self.acceleration)) */ __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9numcodecs_3lz4_3LZ4_3encode, 0, __pyx_n_s_LZ4_encode, NULL, __pyx_n_s_numcodecs_lz4, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 220, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); @@ -4143,11 +4195,11 @@ if (!__Pyx_RefNanny) { __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "numcodecs/lz4.pyx":224 - * return compress(buf, self.acceleration) + * return ensure_ndarray(compress(buf, self.acceleration)) * * def decode(self, buf, out=None): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) */ __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9numcodecs_3lz4_3LZ4_5decode, 0, __pyx_n_s_LZ4_decode, NULL, __pyx_n_s_numcodecs_lz4, __pyx_d, ((PyObject *)__pyx_codeobj__13)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); @@ -4156,7 +4208,7 @@ if (!__Pyx_RefNanny) { __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "numcodecs/lz4.pyx":228 - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) * * def __repr__(self): # <<<<<<<<<<<<<< * r = '%s(acceleration=%r)' % \ diff --git a/numcodecs/vlen.c b/numcodecs/vlen.c index 9e54b2bd..06ec4314 100644 --- a/numcodecs/vlen.c +++ b/numcodecs/vlen.c @@ -1336,6 +1336,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); +/* PyObjectCall2Args.proto */ +static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); + /* MemviewSliceInit.proto */ #define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d #define __Pyx_MEMVIEW_DIRECT 1 @@ -1362,9 +1365,6 @@ static CYTHON_INLINE int __pyx_sub_acquisition_count_locked( static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int); static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int); -/* PyObjectCall2Args.proto */ -static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); - /* SetItemInt.proto */ #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ @@ -2097,6 +2097,7 @@ static const char __pyx_k_normed_values[] = "normed_values"; static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer"; static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; static const char __pyx_k_encoded_values[] = "encoded_values"; +static const char __pyx_k_ensure_ndarray[] = "ensure_ndarray"; static const char __pyx_k_numcodecs_vlen[] = "numcodecs.vlen"; static const char __pyx_k_VLenUTF8___init[] = "VLenUTF8.__init__"; static const char __pyx_k_VLenUTF8_decode[] = "VLenUTF8.decode"; @@ -2236,6 +2237,7 @@ static PyObject *__pyx_n_s_encoded_lengths; static PyObject *__pyx_n_s_encoded_values; static PyObject *__pyx_n_s_encv; static PyObject *__pyx_n_s_ensure_contiguous_ndarray; +static PyObject *__pyx_n_s_ensure_ndarray; static PyObject *__pyx_n_s_enumerate; static PyObject *__pyx_n_s_error; static PyObject *__pyx_kp_s_expected_byte_string_found_r; @@ -3253,7 +3255,7 @@ static PyObject *__pyx_pf_9numcodecs_4vlen_8VLenUTF8_2encode(CYTHON_UNUSED PyObj * memcpy(data, encv, l) * data += l # <<<<<<<<<<<<<< * - * return out + * return ensure_ndarray(out) */ __pyx_v_data = (__pyx_v_data + __pyx_v_l); } @@ -3261,13 +3263,30 @@ static PyObject *__pyx_pf_9numcodecs_4vlen_8VLenUTF8_2encode(CYTHON_UNUSED PyObj /* "numcodecs/vlen.pyx":133 * data += l * - * return out # <<<<<<<<<<<<<< + * return ensure_ndarray(out) # <<<<<<<<<<<<<< * * @cython.wraparound(False) */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_out); - __pyx_r = __pyx_v_out; + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_ensure_ndarray); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_6, function); + } + } + __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_3, __pyx_v_out) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_out); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; goto __pyx_L0; /* "numcodecs/vlen.pyx":79 @@ -19938,6 +19957,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_encoded_values, __pyx_k_encoded_values, sizeof(__pyx_k_encoded_values), 0, 0, 1, 1}, {&__pyx_n_s_encv, __pyx_k_encv, sizeof(__pyx_k_encv), 0, 0, 1, 1}, {&__pyx_n_s_ensure_contiguous_ndarray, __pyx_k_ensure_contiguous_ndarray, sizeof(__pyx_k_ensure_contiguous_ndarray), 0, 0, 1, 1}, + {&__pyx_n_s_ensure_ndarray, __pyx_k_ensure_ndarray, sizeof(__pyx_k_ensure_ndarray), 0, 0, 1, 1}, {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1}, {&__pyx_kp_s_expected_byte_string_found_r, __pyx_k_expected_byte_string_found_r, sizeof(__pyx_k_expected_byte_string_found_r), 0, 0, 1, 0}, @@ -21075,7 +21095,7 @@ if (!__Pyx_RefNanny) { * from .abc import Codec * from .compat_ext cimport Buffer * from .compat_ext import Buffer # <<<<<<<<<<<<<< - * from .compat import ensure_contiguous_ndarray + * from .compat import ensure_ndarray, ensure_contiguous_ndarray * from cpython cimport (PyBytes_GET_SIZE, PyBytes_AS_STRING, PyBytes_Check, */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error) @@ -21091,18 +21111,25 @@ if (!__Pyx_RefNanny) { /* "numcodecs/vlen.pyx":16 * from .compat_ext cimport Buffer * from .compat_ext import Buffer - * from .compat import ensure_contiguous_ndarray # <<<<<<<<<<<<<< + * from .compat import ensure_ndarray, ensure_contiguous_ndarray # <<<<<<<<<<<<<< * from cpython cimport (PyBytes_GET_SIZE, PyBytes_AS_STRING, PyBytes_Check, * PyBytes_FromStringAndSize, PyUnicode_AsUTF8String) */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) + __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_n_s_ensure_ndarray); + __Pyx_GIVEREF(__pyx_n_s_ensure_ndarray); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_ensure_ndarray); __Pyx_INCREF(__pyx_n_s_ensure_contiguous_ndarray); __Pyx_GIVEREF(__pyx_n_s_ensure_contiguous_ndarray); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_ensure_contiguous_ndarray); + PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_ensure_contiguous_ndarray); __pyx_t_2 = __Pyx_Import(__pyx_n_s_compat, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ensure_ndarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ensure_ndarray, __pyx_t_1) < 0) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ensure_contiguous_ndarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ensure_contiguous_ndarray, __pyx_t_1) < 0) __PYX_ERR(0, 16, __pyx_L1_error) @@ -22366,6 +22393,35 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObjec } #endif +/* PyObjectCall2Args */ +static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { + PyObject *args, *result = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(function)) { + PyObject *args[2] = {arg1, arg2}; + return __Pyx_PyFunction_FastCall(function, args, 2); + } + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(function)) { + PyObject *args[2] = {arg1, arg2}; + return __Pyx_PyCFunction_FastCall(function, args, 2); + } + #endif + args = PyTuple_New(2); + if (unlikely(!args)) goto done; + Py_INCREF(arg1); + PyTuple_SET_ITEM(args, 0, arg1); + Py_INCREF(arg2); + PyTuple_SET_ITEM(args, 1, arg2); + Py_INCREF(function); + result = __Pyx_PyObject_Call(function, args, NULL); + Py_DECREF(args); + Py_DECREF(function); +done: + return result; +} + /* MemviewSliceInit */ static int __Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview, @@ -22504,35 +22560,6 @@ static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice, } } -/* PyObjectCall2Args */ -static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { - PyObject *args, *result = NULL; - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(function)) { - PyObject *args[2] = {arg1, arg2}; - return __Pyx_PyFunction_FastCall(function, args, 2); - } - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(function)) { - PyObject *args[2] = {arg1, arg2}; - return __Pyx_PyCFunction_FastCall(function, args, 2); - } - #endif - args = PyTuple_New(2); - if (unlikely(!args)) goto done; - Py_INCREF(arg1); - PyTuple_SET_ITEM(args, 0, arg1); - Py_INCREF(arg2); - PyTuple_SET_ITEM(args, 1, arg2); - Py_INCREF(function); - result = __Pyx_PyObject_Call(function, args, NULL); - Py_DECREF(args); - Py_DECREF(function); -done: - return result; -} - /* SetItemInt */ static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { int r; diff --git a/numcodecs/zstd.c b/numcodecs/zstd.c index a04e62f0..19fe5e63 100644 --- a/numcodecs/zstd.c +++ b/numcodecs/zstd.c @@ -12,38 +12,38 @@ ], "include_dirs": [ "c-blosc/internal-complibs/zstd-1.3.4", + "c-blosc/internal-complibs/zstd-1.3.4/common", "c-blosc/internal-complibs/zstd-1.3.4/compress", - "c-blosc/internal-complibs/zstd-1.3.4/legacy", + "c-blosc/internal-complibs/zstd-1.3.4/decompress", "c-blosc/internal-complibs/zstd-1.3.4/deprecated", "c-blosc/internal-complibs/zstd-1.3.4/dictBuilder", - "c-blosc/internal-complibs/zstd-1.3.4/decompress", - "c-blosc/internal-complibs/zstd-1.3.4/common", - "c-blosc/internal-complibs/zstd-1.3.4/dll" + "c-blosc/internal-complibs/zstd-1.3.4/dll", + "c-blosc/internal-complibs/zstd-1.3.4/legacy" ], "name": "numcodecs.zstd", "sources": [ "numcodecs/zstd.pyx", - "c-blosc/internal-complibs/zstd-1.3.4/common/error_private.c", - "c-blosc/internal-complibs/zstd-1.3.4/common/xxhash.c", - "c-blosc/internal-complibs/zstd-1.3.4/common/zstd_common.c", "c-blosc/internal-complibs/zstd-1.3.4/common/entropy_common.c", + "c-blosc/internal-complibs/zstd-1.3.4/common/error_private.c", "c-blosc/internal-complibs/zstd-1.3.4/common/fse_decompress.c", - "c-blosc/internal-complibs/zstd-1.3.4/common/threading.c", "c-blosc/internal-complibs/zstd-1.3.4/common/pool.c", - "c-blosc/internal-complibs/zstd-1.3.4/compress/huf_compress.c", - "c-blosc/internal-complibs/zstd-1.3.4/compress/zstdmt_compress.c", - "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_lazy.c", - "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_fast.c", - "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_opt.c", - "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_double_fast.c", + "c-blosc/internal-complibs/zstd-1.3.4/common/threading.c", + "c-blosc/internal-complibs/zstd-1.3.4/common/xxhash.c", + "c-blosc/internal-complibs/zstd-1.3.4/common/zstd_common.c", "c-blosc/internal-complibs/zstd-1.3.4/compress/fse_compress.c", + "c-blosc/internal-complibs/zstd-1.3.4/compress/huf_compress.c", "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_compress.c", + "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_double_fast.c", + "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_fast.c", + "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_lazy.c", "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_ldm.c", + "c-blosc/internal-complibs/zstd-1.3.4/compress/zstd_opt.c", + "c-blosc/internal-complibs/zstd-1.3.4/compress/zstdmt_compress.c", "c-blosc/internal-complibs/zstd-1.3.4/decompress/huf_decompress.c", "c-blosc/internal-complibs/zstd-1.3.4/decompress/zstd_decompress.c", - "c-blosc/internal-complibs/zstd-1.3.4/dictBuilder/zdict.c", "c-blosc/internal-complibs/zstd-1.3.4/dictBuilder/cover.c", - "c-blosc/internal-complibs/zstd-1.3.4/dictBuilder/divsufsort.c" + "c-blosc/internal-complibs/zstd-1.3.4/dictBuilder/divsufsort.c", + "c-blosc/internal-complibs/zstd-1.3.4/dictBuilder/zdict.c" ] }, "module_name": "numcodecs.zstd" @@ -1394,6 +1394,7 @@ static const char __pyx_k_RuntimeError[] = "RuntimeError"; static const char __pyx_k_source_buffer[] = "source_buffer"; static const char __pyx_k_DEFAULT_CLEVEL[] = "DEFAULT_CLEVEL"; static const char __pyx_k_VERSION_NUMBER[] = "VERSION_NUMBER"; +static const char __pyx_k_ensure_ndarray[] = "ensure_ndarray"; static const char __pyx_k_numcodecs_zstd[] = "numcodecs.zstd"; static const char __pyx_k_compressed_size[] = "compressed_size"; static const char __pyx_k_decompressed_size[] = "decompressed_size"; @@ -1449,6 +1450,7 @@ static PyObject *__pyx_kp_s_destination_buffer_too_small_exp; static PyObject *__pyx_n_s_doc; static PyObject *__pyx_n_s_encode; static PyObject *__pyx_n_s_ensure_contiguous_ndarray; +static PyObject *__pyx_n_s_ensure_ndarray; static PyObject *__pyx_n_s_error; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_init; @@ -2811,7 +2813,7 @@ static PyObject *__pyx_pf_9numcodecs_4zstd_4Zstd___init__(CYTHON_UNUSED PyObject * * def encode(self, buf): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf) - * return compress(buf, self.level) + * return ensure_ndarray(compress(buf, self.level)) */ /* Python wrapper */ @@ -2884,8 +2886,10 @@ static PyObject *__pyx_pf_9numcodecs_4zstd_4Zstd_2encode(CYTHON_UNUSED PyObject PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; + PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("encode", 0); __Pyx_INCREF(__pyx_v_buf); @@ -2893,7 +2897,7 @@ static PyObject *__pyx_pf_9numcodecs_4zstd_4Zstd_2encode(CYTHON_UNUSED PyObject * * def encode(self, buf): * buf = ensure_contiguous_ndarray(buf) # <<<<<<<<<<<<<< - * return compress(buf, self.level) + * return ensure_ndarray(compress(buf, self.level)) * */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ensure_contiguous_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error) @@ -2919,61 +2923,79 @@ static PyObject *__pyx_pf_9numcodecs_4zstd_4Zstd_2encode(CYTHON_UNUSED PyObject /* "numcodecs/zstd.pyx":217 * def encode(self, buf): * buf = ensure_contiguous_ndarray(buf) - * return compress(buf, self.level) # <<<<<<<<<<<<<< + * return ensure_ndarray(compress(buf, self.level)) # <<<<<<<<<<<<<< * * def decode(self, buf, out=None): */ __Pyx_XDECREF(__pyx_r); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_compress); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 217, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ensure_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_level); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = NULL; - __pyx_t_5 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_4); + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_compress); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 217, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_level); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 217, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = NULL; + __pyx_t_7 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_5 = 1; + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_buf, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_buf, __pyx_t_5}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_buf, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_buf, __pyx_t_5}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { - __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 217, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 217, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_6) { + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_v_buf); __Pyx_GIVEREF(__pyx_v_buf); - PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_buf); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_buf); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } } + __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2984,7 +3006,7 @@ static PyObject *__pyx_pf_9numcodecs_4zstd_4Zstd_2encode(CYTHON_UNUSED PyObject * * def encode(self, buf): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf) - * return compress(buf, self.level) + * return ensure_ndarray(compress(buf, self.level)) */ /* function exit code */ @@ -2993,7 +3015,9 @@ static PyObject *__pyx_pf_9numcodecs_4zstd_4Zstd_2encode(CYTHON_UNUSED PyObject __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("numcodecs.zstd.Zstd.encode", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -3004,11 +3028,11 @@ static PyObject *__pyx_pf_9numcodecs_4zstd_4Zstd_2encode(CYTHON_UNUSED PyObject } /* "numcodecs/zstd.pyx":219 - * return compress(buf, self.level) + * return ensure_ndarray(compress(buf, self.level)) * * def decode(self, buf, out=None): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf) - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) */ /* Python wrapper */ @@ -3095,8 +3119,10 @@ static PyObject *__pyx_pf_9numcodecs_4zstd_4Zstd_4decode(CYTHON_UNUSED PyObject PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; + PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("decode", 0); __Pyx_INCREF(__pyx_v_buf); @@ -3104,7 +3130,7 @@ static PyObject *__pyx_pf_9numcodecs_4zstd_4Zstd_4decode(CYTHON_UNUSED PyObject * * def decode(self, buf, out=None): * buf = ensure_contiguous_ndarray(buf) # <<<<<<<<<<<<<< - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) * */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ensure_contiguous_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 220, __pyx_L1_error) @@ -3130,68 +3156,86 @@ static PyObject *__pyx_pf_9numcodecs_4zstd_4Zstd_4decode(CYTHON_UNUSED PyObject /* "numcodecs/zstd.pyx":221 * def decode(self, buf, out=None): * buf = ensure_contiguous_ndarray(buf) - * return decompress(buf, out) # <<<<<<<<<<<<<< + * return ensure_ndarray(decompress(buf, out)) # <<<<<<<<<<<<<< * * def __repr__(self): */ __Pyx_XDECREF(__pyx_r); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_decompress); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ensure_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - __pyx_t_4 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_decompress); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 221, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_4 = 1; + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_buf, __pyx_v_out}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_buf, __pyx_v_out}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 221, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_buf, __pyx_v_out}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_buf, __pyx_v_out}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 221, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_3); } else #endif { - __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 221, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (__pyx_t_3) { - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 221, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_buf); __Pyx_GIVEREF(__pyx_v_buf); - PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_buf); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_buf); __Pyx_INCREF(__pyx_v_out); __Pyx_GIVEREF(__pyx_v_out); - PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_out); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_out); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 221, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "numcodecs/zstd.pyx":219 - * return compress(buf, self.level) + * return ensure_ndarray(compress(buf, self.level)) * * def decode(self, buf, out=None): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf) - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) */ /* function exit code */ @@ -3199,7 +3243,9 @@ static PyObject *__pyx_pf_9numcodecs_4zstd_4Zstd_4decode(CYTHON_UNUSED PyObject __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("numcodecs.zstd.Zstd.decode", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -3210,7 +3256,7 @@ static PyObject *__pyx_pf_9numcodecs_4zstd_4Zstd_4decode(CYTHON_UNUSED PyObject } /* "numcodecs/zstd.pyx":223 - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) * * def __repr__(self): # <<<<<<<<<<<<<< * r = '%s(level=%r)' % \ @@ -3300,7 +3346,7 @@ static PyObject *__pyx_pf_9numcodecs_4zstd_4Zstd_6__repr__(CYTHON_UNUSED PyObjec goto __pyx_L0; /* "numcodecs/zstd.pyx":223 - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) * * def __repr__(self): # <<<<<<<<<<<<<< * r = '%s(level=%r)' % \ @@ -3407,6 +3453,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, {&__pyx_n_s_ensure_contiguous_ndarray, __pyx_k_ensure_contiguous_ndarray, sizeof(__pyx_k_ensure_contiguous_ndarray), 0, 0, 1, 1}, + {&__pyx_n_s_ensure_ndarray, __pyx_k_ensure_ndarray, sizeof(__pyx_k_ensure_ndarray), 0, 0, 1, 1}, {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1}, @@ -3499,7 +3546,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * * def encode(self, buf): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf) - * return compress(buf, self.level) + * return ensure_ndarray(compress(buf, self.level)) */ __pyx_tuple__9 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_buf); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); @@ -3507,11 +3554,11 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numcodecs_zstd_pyx, __pyx_n_s_encode, 215, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 215, __pyx_L1_error) /* "numcodecs/zstd.pyx":219 - * return compress(buf, self.level) + * return ensure_ndarray(compress(buf, self.level)) * * def decode(self, buf, out=None): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf) - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) */ __pyx_tuple__11 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_buf, __pyx_n_s_out); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 219, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__11); @@ -3522,7 +3569,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GIVEREF(__pyx_tuple__13); /* "numcodecs/zstd.pyx":223 - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) * * def __repr__(self): # <<<<<<<<<<<<<< * r = '%s(level=%r)' % \ @@ -3840,7 +3887,7 @@ if (!__Pyx_RefNanny) { * * from .compat_ext cimport Buffer * from .compat_ext import Buffer # <<<<<<<<<<<<<< - * from .compat import ensure_contiguous_ndarray + * from .compat import ensure_ndarray, ensure_contiguous_ndarray * from .abc import Codec */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error) @@ -3856,18 +3903,25 @@ if (!__Pyx_RefNanny) { /* "numcodecs/zstd.pyx":16 * from .compat_ext cimport Buffer * from .compat_ext import Buffer - * from .compat import ensure_contiguous_ndarray # <<<<<<<<<<<<<< + * from .compat import ensure_ndarray, ensure_contiguous_ndarray # <<<<<<<<<<<<<< * from .abc import Codec * */ - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) + __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_n_s_ensure_ndarray); + __Pyx_GIVEREF(__pyx_n_s_ensure_ndarray); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ensure_ndarray); __Pyx_INCREF(__pyx_n_s_ensure_contiguous_ndarray); __Pyx_GIVEREF(__pyx_n_s_ensure_contiguous_ndarray); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ensure_contiguous_ndarray); + PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_ensure_contiguous_ndarray); __pyx_t_1 = __Pyx_Import(__pyx_n_s_compat, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ensure_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ensure_ndarray, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ensure_contiguous_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ensure_contiguous_ndarray, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error) @@ -3876,7 +3930,7 @@ if (!__Pyx_RefNanny) { /* "numcodecs/zstd.pyx":17 * from .compat_ext import Buffer - * from .compat import ensure_contiguous_ndarray + * from .compat import ensure_ndarray, ensure_contiguous_ndarray * from .abc import Codec # <<<<<<<<<<<<<< * * @@ -4146,7 +4200,7 @@ if (!__Pyx_RefNanny) { * * def encode(self, buf): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf) - * return compress(buf, self.level) + * return ensure_ndarray(compress(buf, self.level)) */ __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9numcodecs_4zstd_4Zstd_3encode, 0, __pyx_n_s_Zstd_encode, NULL, __pyx_n_s_numcodecs_zstd, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); @@ -4154,11 +4208,11 @@ if (!__Pyx_RefNanny) { __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "numcodecs/zstd.pyx":219 - * return compress(buf, self.level) + * return ensure_ndarray(compress(buf, self.level)) * * def decode(self, buf, out=None): # <<<<<<<<<<<<<< * buf = ensure_contiguous_ndarray(buf) - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) */ __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9numcodecs_4zstd_4Zstd_5decode, 0, __pyx_n_s_Zstd_decode, NULL, __pyx_n_s_numcodecs_zstd, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); @@ -4167,7 +4221,7 @@ if (!__Pyx_RefNanny) { __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "numcodecs/zstd.pyx":223 - * return decompress(buf, out) + * return ensure_ndarray(decompress(buf, out)) * * def __repr__(self): # <<<<<<<<<<<<<< * r = '%s(level=%r)' % \ From 97c6b182cf56cdb2b72455a0fb9d84f890e82ecd Mon Sep 17 00:00:00 2001 From: Alistair Miles Date: Thu, 29 Nov 2018 18:22:51 +0000 Subject: [PATCH 4/4] release notes [ci skip] --- docs/release.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release.rst b/docs/release.rst index e4e31ef0..00819757 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -41,6 +41,10 @@ Release notes code readability and maintainability. By :user:`John Kirkham ` and :user:`Alistair Miles `; :issue:`119`, :issue:`121`, :issue:`128`. +* Return values from encode() and decode() methods are now returned as numpy + arrays for consistency across codecs. By :user:`John Kirkham `, + :issue:`136`. + * Improvements to handling of errors in the :class:`numcodecs.blosc.Blosc` and :class:`numcodecs.lz4.LZ4` codecs when the maximum allowed size of an input buffer is exceeded. By :user:`Jerome Kelleher `, :issue:`80`,