diff --git a/.gitmodules b/.gitmodules index 04c71aa1da..e69de29bb2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "c-blosc"] - path = c-blosc - url = https://github.com/Blosc/c-blosc.git diff --git a/MANIFEST.in b/MANIFEST.in index 1c2f00fe29..e69de29bb2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +0,0 @@ -recursive-include c-blosc * -recursive-include zarr *.pxd -recursive-include zarr *.pyx -recursive-include zarr *.h -recursive-include zarr *.c -include cpuinfo.py diff --git a/c-blosc b/c-blosc deleted file mode 160000 index 1fef4fe4a1..0000000000 --- a/c-blosc +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1fef4fe4a1234cd088aab8ed359f9f5bba7dc480 diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 25ba2be8e1..dedb7d9951 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -21,8 +21,8 @@ example:: >>> z = zarr.zeros((10000, 10000), chunks=(1000, 1000), dtype='i4') >>> z Array((10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 323; ratio: 1238390.1; initialized: 0/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 381.5M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: dict The code above creates a 2-dimensional array of 32-bit integers with @@ -33,7 +33,7 @@ For a complete list of array creation routines see the :mod:`zarr.creation` module documentation. .. _tutorial_array: - + Reading and writing data ------------------------ @@ -44,14 +44,13 @@ scalar value:: >>> z[:] = 42 >>> z Array((10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 1.8M; ratio: 215.1; initialized: 100/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 381.5M; nbytes_stored: ...; ratio: ...; initialized: 100/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: dict -Notice that the values of ``nbytes_stored``, ``ratio`` and -``initialized`` have changed. This is because when a Zarr array is -first created, none of the chunks are initialized. Writing data into -the array will cause the necessary chunks to be initialized. +Notice that the values of ``initialized`` has changed. This is because +when a Zarr array is first created, none of the chunks are initialized. +Writing data into the array will cause the necessary chunks to be initialized. Regions of the array can also be written to, e.g.:: @@ -80,7 +79,7 @@ the requested region into a NumPy array, e.g.:: [9999, 42, 42, ..., 42, 42, 42]], dtype=int32) .. _tutorial_persist: - + Persistent arrays ----------------- @@ -92,8 +91,8 @@ enabling persistence of data between sessions. For example:: ... chunks=(1000, 1000), dtype='i4', fill_value=0) >>> z1 Array((10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 323; ratio: 1238390.1; initialized: 0/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 381.5M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: DirectoryStore The array above will store its configuration metadata and all @@ -116,13 +115,13 @@ Check that the data have been written and can be read again:: >>> z2 = zarr.open_array('example.zarr', mode='r') >>> z2 Array((10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 1.9M; ratio: 204.5; initialized: 100/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 381.5M; nbytes_stored: ...; ratio: ...; initialized: 100/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: DirectoryStore >>> np.all(z1[:] == z2[:]) True -.. _tutorial_resize: +.. _tutorial_resize: Resizing and appending ---------------------- @@ -133,11 +132,8 @@ can be increased or decreased in length. For example:: >>> z = zarr.zeros(shape=(10000, 10000), chunks=(1000, 1000)) >>> z[:] = 42 >>> z.resize(20000, 10000) - >>> z - Array((20000, 10000), float64, chunks=(1000, 1000), order=C) - nbytes: 1.5G; nbytes_stored: 3.6M; ratio: 422.3; initialized: 100/200 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) - store: dict + >>> z.shape + (20000, 10000) Note that when an array is resized, the underlying data are not rearranged in any way. If one or more dimensions are shrunk, any @@ -149,28 +145,18 @@ which can be used to append data to any axis. E.g.:: >>> a = np.arange(10000000, dtype='i4').reshape(10000, 1000) >>> z = zarr.array(a, chunks=(1000, 100)) - >>> z - Array((10000, 1000), int32, chunks=(1000, 100), order=C) - nbytes: 38.1M; nbytes_stored: 1.9M; ratio: 20.3; initialized: 100/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) - store: dict + >>> z.shape + (10000, 1000) >>> z.append(a) (20000, 1000) - >>> z - Array((20000, 1000), int32, chunks=(1000, 100), order=C) - nbytes: 76.3M; nbytes_stored: 3.8M; ratio: 20.3; initialized: 200/200 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) - store: dict >>> z.append(np.vstack([a, a]), axis=1) (20000, 2000) >>> z Array((20000, 2000), int32, chunks=(1000, 100), order=C) - nbytes: 152.6M; nbytes_stored: 7.5M; ratio: 20.3; initialized: 400/400 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) - store: dict + ... .. _tutorial_compress: - + Compressors ----------- @@ -187,13 +173,14 @@ data. Different compressors can be provided via the ``compressor`` keyword argument accepted by all array creation functions. For example:: + >>> from numcodecs import Blosc >>> z = zarr.array(np.arange(100000000, dtype='i4').reshape(10000, 10000), ... chunks=(1000, 1000), - ... compressor=zarr.Blosc(cname='zstd', clevel=3, shuffle=2)) + ... compressor=Blosc(cname='zstd', clevel=3, shuffle=Blosc.BITSHUFFLE)) >>> z Array((10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 4.4M; ratio: 87.6; initialized: 100/100 - compressor: Blosc(cname='zstd', clevel=3, shuffle=2) + nbytes: 381.5M; nbytes_stored: ...; ratio: ...; initialized: 100/100 + compressor: Blosc(cname='zstd', clevel=3, shuffle=BITSHUFFLE, blocksize=0) store: dict The array above will use Blosc as the primary compressor, using the @@ -203,22 +190,21 @@ the bitshuffle filter applied. A list of the internal compression libraries available within Blosc can be obtained via:: - >>> from zarr import blosc + >>> from numcodecs import blosc >>> blosc.list_compressors() ['blosclz', 'lz4', 'lz4hc', 'snappy', 'zlib', 'zstd'] In addition to Blosc, other compression libraries can also be -used. Zarr comes with support for zlib, BZ2 and LZMA compression, via -the Python standard library. For example, here is an array using zlib -compression, level 1:: +used. For example, here is an array using Zstandard compression, level 1:: + >>> from numcodecs import Zstd >>> z = zarr.array(np.arange(100000000, dtype='i4').reshape(10000, 10000), ... chunks=(1000, 1000), - ... compressor=zarr.Zlib(level=1)) + ... compressor=Zstd(level=1)) >>> z Array((10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 132.2M; ratio: 2.9; initialized: 100/100 - compressor: Zlib(level=1) + nbytes: 381.5M; nbytes_stored: ...; ratio: ...; initialized: 100/100 + compressor: Zstd(level=1) store: dict Here is an example using LZMA with a custom filter pipeline including @@ -227,12 +213,13 @@ LZMA's built-in delta filter:: >>> import lzma >>> lzma_filters = [dict(id=lzma.FILTER_DELTA, dist=4), ... dict(id=lzma.FILTER_LZMA2, preset=1)] - >>> compressor = zarr.LZMA(filters=lzma_filters) + >>> from numcodecs import LZMA + >>> compressor = LZMA(filters=lzma_filters) >>> z = zarr.array(np.arange(100000000, dtype='i4').reshape(10000, 10000), ... chunks=(1000, 1000), compressor=compressor) >>> z Array((10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 248.9K; ratio: 1569.7; initialized: 100/100 + nbytes: 381.5M; nbytes_stored: ...; ratio: ...; initialized: 100/100 compressor: LZMA(format=1, check=-1, preset=None, filters=[{'dist': 4, 'id': 3}, {'id': 33, 'preset': 1}]) store: dict @@ -240,23 +227,24 @@ The default compressor can be changed by setting the value of the ``zarr.storage.default_compressor`` variable, e.g.:: >>> import zarr.storage - >>> # switch to using Zstandard via Blosc by default - ... zarr.storage.default_compressor = zarr.Blosc(cname='zstd', clevel=1, shuffle=1) + >>> from numcodecs import Zstd, Blosc + >>> # switch to using Zstandard + ... zarr.storage.default_compressor = Zstd(level=1) >>> z = zarr.zeros(100000000, chunks=1000000) >>> z Array((100000000,), float64, chunks=(1000000,), order=C) - nbytes: 762.9M; nbytes_stored: 302; ratio: 2649006.6; initialized: 0/100 - compressor: Blosc(cname='zstd', clevel=1, shuffle=1) + nbytes: 762.9M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + compressor: Zstd(level=1) store: dict >>> # switch back to Blosc defaults - ... zarr.storage.default_compressor = zarr.Blosc() + ... zarr.storage.default_compressor = Blosc() To disable compression, set ``compressor=None`` when creating an array, e.g.:: >>> z = zarr.zeros(100000000, chunks=1000000, compressor=None) >>> z Array((100000000,), float64, chunks=(1000000,), order=C) - nbytes: 762.9M; nbytes_stored: 209; ratio: 3827751.2; initialized: 0/100 + nbytes: 762.9M; nbytes_stored: ...; ratio: ...; initialized: 0/100 store: dict .. _tutorial_filters: @@ -276,22 +264,22 @@ flexibility for implementing and using filters in combination with different compressors, Zarr also provides a mechanism for configuring filters outside of the primary compressor. -Here is an example using the Zarr delta filter with the Blosc compressor: +Here is an example using the delta filter with the Blosc compressor: - >>> filters = [zarr.Delta(dtype='i4')] - >>> compressor = zarr.Blosc(cname='zstd', clevel=1, shuffle=1) + >>> from numcodecs import Blosc, Delta + >>> filters = [Delta(dtype='i4')] + >>> compressor = Blosc(cname='zstd', clevel=1, shuffle=Blosc.SHUFFLE) >>> z = zarr.array(np.arange(100000000, dtype='i4').reshape(10000, 10000), ... chunks=(1000, 1000), filters=filters, compressor=compressor) >>> z Array((10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 633.4K; ratio: 616.7; initialized: 100/100 - filters: Delta(dtype=int32) - compressor: Blosc(cname='zstd', clevel=1, shuffle=1) + nbytes: 381.5M; nbytes_stored: ...; ratio: ...; initialized: 100/100 + filters: Delta(dtype='`_ documentation. .. _tutorial_sync: @@ -335,8 +323,8 @@ array with thread synchronization:: ... synchronizer=zarr.ThreadSynchronizer()) >>> z Array((10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 323; ratio: 1238390.1; initialized: 0/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 381.5M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: dict; synchronizer: ThreadSynchronizer This array is safe to read or write within a multi-threaded program. @@ -350,8 +338,8 @@ provided that all processes have access to a shared file system. E.g.:: ... synchronizer=synchronizer) >>> z Array((10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 323; ratio: 1238390.1; initialized: 0/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 381.5M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: DirectoryStore; synchronizer: ProcessSynchronizer This array is safe to read or write from multiple processes. @@ -407,9 +395,7 @@ Groups can also contain arrays, e.g.:: ... compressor=zarr.Blosc(cname='zstd', clevel=1, shuffle=1)) >>> z1 Array(/foo/bar/baz, (10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 324; ratio: 1234567.9; initialized: 0/100 - compressor: Blosc(cname='zstd', clevel=1, shuffle=1) - store: DictStore + ... Arrays are known as "datasets" in HDF5 terminology. For compatibility with h5py, Zarr groups also implement the :func:`zarr.hierarchy.Group.create_dataset` @@ -421,9 +407,7 @@ and :func:`zarr.hierarchy.Group.require_dataset` methods, e.g.:: ... compression_opts=1) >>> z Array(/foo/bar/quux, (10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 275; ratio: 1454545.5; initialized: 0/100 - compressor: Zlib(level=1) - store: DictStore + ... Members of a group can be accessed via the suffix notation, e.g.:: @@ -441,9 +425,7 @@ e.g.:: store: DictStore >>> root_group['foo/bar/baz'] Array(/foo/bar/baz, (10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 324; ratio: 1234567.9; initialized: 0/100 - compressor: Blosc(cname='zstd', clevel=1, shuffle=1) - store: DictStore + ... The :func:`zarr.hierarchy.open_group` provides a convenient way to create or re-open a group stored in a directory on the file-system, with sub-groups @@ -458,9 +440,7 @@ stored in sub-directories, e.g.:: ... fill_value=0) >>> z Array(/foo/bar/baz, (10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 323; ratio: 1238390.1; initialized: 0/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) - store: DirectoryStore + ... For more information on groups see the :mod:`zarr.hierarchy` API docs. @@ -500,13 +480,13 @@ data. E.g.:: >>> a = np.arange(100000000, dtype='i4').reshape(10000, 10000).T >>> zarr.array(a, chunks=(1000, 1000)) Array((10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 26.3M; ratio: 14.5; initialized: 100/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 381.5M; nbytes_stored: 25.6M; ratio: 14.9; initialized: 100/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: dict >>> zarr.array(a, chunks=(1000, 1000), order='F') Array((10000, 10000), int32, chunks=(1000, 1000), order=F) - nbytes: 381.5M; nbytes_stored: 9.2M; ratio: 41.6; initialized: 100/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 381.5M; nbytes_stored: 9.2M; ratio: 41.5; initialized: 100/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: dict In the above example, Fortran order gives a better compression ratio. This @@ -529,19 +509,19 @@ Here is an example storing an array directly into a Zip file:: >>> z = zarr.zeros((1000, 1000), chunks=(100, 100), dtype='i4', store=store) >>> z Array((1000, 1000), int32, chunks=(100, 100), order=C) - nbytes: 3.8M; nbytes_stored: 319; ratio: 12539.2; initialized: 0/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 3.8M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: ZipStore >>> z[:] = 42 >>> z Array((1000, 1000), int32, chunks=(100, 100), order=C) - nbytes: 3.8M; nbytes_stored: 21.8K; ratio: 179.2; initialized: 100/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 3.8M; nbytes_stored: ...; ratio: ...; initialized: 100/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: ZipStore >>> store.close() >>> import os >>> os.path.getsize('example.zip') - 30721 + 30745 Re-open and check that data have been written:: @@ -549,8 +529,8 @@ Re-open and check that data have been written:: >>> z = zarr.Array(store) >>> z Array((1000, 1000), int32, chunks=(100, 100), order=C) - nbytes: 3.8M; nbytes_stored: 21.8K; ratio: 179.2; initialized: 100/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 3.8M; nbytes_stored: ...; ratio: ...; initialized: 100/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: ZipStore >>> z[:] array([[42, 42, 42, ..., 42, 42, 42], @@ -619,7 +599,7 @@ simple heuristics and may be far from optimal. E.g.:: (313, 313) .. _tutorial_tips_blosc: - + Configuring Blosc ~~~~~~~~~~~~~~~~~ diff --git a/requirements.txt b/requirements.txt index 5186c748c2..8427764e04 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ numpy fasteners +numcodecs diff --git a/requirements_dev.txt b/requirements_dev.txt index f3cf11e38b..24232db51d 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -8,7 +8,9 @@ fasteners==0.14.1 flake8==3.3.0 mccabe==0.6.1 monotonic==1.2 +msgpack-python==0.4.8 nose==1.3.7 +numcodecs==0.2.0 numpy==1.12.0 packaging pkginfo==1.4.1 diff --git a/setup.py b/setup.py index ac134523f1..11523fd229 100644 --- a/setup.py +++ b/setup.py @@ -1,132 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, division -from glob import glob -import os -from setuptools import setup, Extension -import cpuinfo -import sys -from distutils.command.build_ext import build_ext -from distutils.errors import CCompilerError, DistutilsExecError, \ - DistutilsPlatformError - - -PY2 = sys.version_info[0] == 2 - - -try: - from Cython.Build import cythonize -except ImportError: - have_cython = False -else: - have_cython = True - - -def blosc_extension(): - print('[zarr] Setting up Blosc extension') - - # setup blosc extension - blosc_sources = [] - extra_compile_args = [] - include_dirs = [] - define_macros = [] - - # generic setup - blosc_sources += [f for f in glob('c-blosc/blosc/*.c') - if 'avx2' not in f and 'sse2' not in f] - blosc_sources += glob('c-blosc/internal-complibs/lz4*/*.c') - blosc_sources += glob('c-blosc/internal-complibs/snappy*/*.cc') - blosc_sources += glob('c-blosc/internal-complibs/zlib*/*.c') - blosc_sources += glob('c-blosc/internal-complibs/zstd*/common/*.c') - blosc_sources += glob('c-blosc/internal-complibs/zstd*/compress/*.c') - blosc_sources += glob('c-blosc/internal-complibs/zstd*/decompress/*.c') - blosc_sources += glob('c-blosc/internal-complibs/zstd*/dictBuilder/*.c') - include_dirs += [os.path.join('c-blosc', 'blosc')] - include_dirs += [d for d in glob('c-blosc/internal-complibs/*') - if os.path.isdir(d)] - include_dirs += [d for d in glob('c-blosc/internal-complibs/*/*') - if os.path.isdir(d)] - define_macros += [('HAVE_LZ4', 1), - ('HAVE_SNAPPY', 1), - ('HAVE_ZLIB', 1), - ('HAVE_ZSTD', 1)] - # define_macros += [('CYTHON_TRACE', '1')] - - # determine CPU support for SSE2 and AVX2 - cpu_info = cpuinfo.get_cpu_info() - - # SSE2 - if 'sse2' in cpu_info['flags']: - print('[zarr] SSE2 detected') - extra_compile_args.append('-DSHUFFLE_SSE2_ENABLED') - blosc_sources += [f for f in glob('c-blosc/blosc/*.c') if 'sse2' in f] - if os.name == 'posix': - extra_compile_args.append('-msse2') - elif os.name == 'nt': - define_macros += [('__SSE2__', 1)] - - # AVX2 - if 'avx2' in cpu_info['flags']: - print('[zarr] AVX2 detected') - extra_compile_args.append('-DSHUFFLE_AVX2_ENABLED') - blosc_sources += [f for f in glob('c-blosc/blosc/*.c') if 'avx2' in f] - if os.name == 'posix': - extra_compile_args.append('-mavx2') - elif os.name == 'nt': - define_macros += [('__AVX2__', 1)] - - # workaround lack of support for "inline" in MSVC when building for Python - # 2.7 64-bit - if PY2 and os.name == 'nt': - extra_compile_args.append('-Dinline=__inline') - - if have_cython: - sources = ['zarr/blosc.pyx'] - else: - sources = ['zarr/blosc.c'] - - # define extension module - extensions = [ - Extension('zarr.blosc', - sources=sources + blosc_sources, - include_dirs=include_dirs, - define_macros=define_macros, - extra_compile_args=extra_compile_args, - ), - ] - - if have_cython: - extensions = cythonize(extensions) - - return extensions - - -if sys.platform == 'win32': - ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError, - IOError, ValueError) -else: - ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError) - - -class BuildFailed(Exception): - pass - - -class ve_build_ext(build_ext): - # This class allows C extension building to fail. - - def run(self): - try: - build_ext.run(self) - except DistutilsPlatformError as e: - print('[zarr] ERROR', e, file=sys.stderr) - raise BuildFailed() - - def build_extension(self, ext): - try: - build_ext.build_extension(self, ext) - except ext_errors as e: - print('[zarr] ERROR', e, file=sys.stderr) - raise BuildFailed() +from setuptools import setup DESCRIPTION = 'A minimal implementation of chunked, compressed, ' \ @@ -135,71 +9,46 @@ def build_extension(self, ext): with open('README.rst') as f: LONG_DESCRIPTION = f.read() - -def run_setup(with_extensions): - - if with_extensions: - ext_modules = blosc_extension() - cmdclass = dict(build_ext=ve_build_ext) - else: - ext_modules = [] - cmdclass = dict() - - setup( - name='zarr', - description=DESCRIPTION, - long_description=LONG_DESCRIPTION, - use_scm_version={ - 'version_scheme': 'guess-next-dev', - 'local_scheme': 'dirty-tag', - 'write_to': 'zarr/version.py' - }, - setup_requires=[ - 'setuptools>18.0', - 'setuptools-scm>1.5.4' - ], - install_requires=[ - 'numpy>=1.7', - 'fasteners', - ], - ext_modules=ext_modules, - cmdclass=cmdclass, - package_dir={'': '.'}, - packages=['zarr', 'zarr.tests'], - classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'Intended Audience :: Information Technology', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Operating System :: Unix', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - ], - author='Alistair Miles', - author_email='alimanfoo@googlemail.com', - maintainer='Alistair Miles', - maintainer_email='alimanfoo@googlemail.com', - url='https://github.com/alimanfoo/zarr', - license='MIT', - ) - - -if __name__ == '__main__': - is_pypy = hasattr(sys, 'pypy_translation_info') - - try: - run_setup(not is_pypy) - except BuildFailed: - print('[zarr]' + ('*' * 75), file=sys.stderr) - print('[zarr] WARNING compilation of the Blosc C extension failed.', - file=sys.stderr) - print('[zarr] Retrying installation without C extensions...', - file=sys.stderr) - print('[zarr]' + ('*' * 75), file=sys.stderr) - run_setup(False) +setup( + name='zarr', + description=DESCRIPTION, + long_description=LONG_DESCRIPTION, + use_scm_version={ + 'version_scheme': 'guess-next-dev', + 'local_scheme': 'dirty-tag', + 'write_to': 'zarr/version.py' + }, + setup_requires=[ + 'setuptools>18.0', + 'setuptools-scm>1.5.4' + ], + install_requires=[ + 'numpy>=1.7', + 'fasteners', + 'numcodecs>=0.2.0', + ], + package_dir={'': '.'}, + packages=['zarr', 'zarr.tests'], + classifiers=[ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: Information Technology', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Operating System :: Unix', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + ], + author='Alistair Miles', + author_email='alimanfoo@googlemail.com', + maintainer='Alistair Miles', + maintainer_email='alimanfoo@googlemail.com', + url='https://github.com/alimanfoo/zarr', + license='MIT', +) diff --git a/tox.ini b/tox.ini index ed7d1e415d..1bc6aca0e1 100644 --- a/tox.ini +++ b/tox.ini @@ -10,10 +10,9 @@ envlist = py27, py34, py35, py36, docs setenv = PYTHONHASHSEED = 42 commands = - py27: pip install -U backports.lzma python setup.py build_ext --inplace py27,py34,py35: nosetests -v --with-coverage --cover-erase --cover-package=zarr zarr - py36: nosetests -v --with-coverage --cover-erase --cover-package=zarr --with-doctest --doctest-options=+NORMALIZE_WHITESPACE zarr + py36: nosetests -v --with-coverage --cover-erase --cover-package=zarr --with-doctest --doctest-options=+NORMALIZE_WHITESPACE,+ELLIPSIS zarr py36: python -m doctest -o NORMALIZE_WHITESPACE -o ELLIPSIS docs/tutorial.rst docs/spec/v2.rst py36: flake8 --max-line-length=100 zarr python setup.py bdist_wheel diff --git a/zarr/blosc.c b/zarr/blosc.c deleted file mode 100644 index 3a3e331223..0000000000 --- a/zarr/blosc.c +++ /dev/null @@ -1,7398 +0,0 @@ -/* Generated by Cython 0.25.2 */ - -/* BEGIN: Cython Metadata -{ - "distutils": { - "define_macros": [ - [ - "HAVE_LZ4", - 1 - ], - [ - "HAVE_SNAPPY", - 1 - ], - [ - "HAVE_ZLIB", - 1 - ], - [ - "HAVE_ZSTD", - 1 - ] - ], - "depends": [ - "c-blosc/blosc/blosc.h" - ], - "extra_compile_args": [ - "-DSHUFFLE_SSE2_ENABLED", - "-msse2", - "-DSHUFFLE_AVX2_ENABLED", - "-mavx2" - ], - "include_dirs": [ - "c-blosc/blosc", - "c-blosc/internal-complibs/zstd-1.0.0", - "c-blosc/internal-complibs/snappy-1.1.1", - "c-blosc/internal-complibs/zlib-1.2.8", - "c-blosc/internal-complibs/lz4-1.7.2", - "c-blosc/internal-complibs/zstd-1.0.0/legacy", - "c-blosc/internal-complibs/zstd-1.0.0/compress", - "c-blosc/internal-complibs/zstd-1.0.0/dictBuilder", - "c-blosc/internal-complibs/zstd-1.0.0/common", - "c-blosc/internal-complibs/zstd-1.0.0/decompress" - ] - }, - "module_name": "zarr.blosc" -} -END: Cython Metadata */ - -#define PY_SSIZE_T_CLEAN -#include "Python.h" -#ifndef Py_PYTHON_H - #error Python headers needed to compile C extensions, please install development version of Python. -#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. -#else -#define CYTHON_ABI "0_25_2" -#include -#ifndef offsetof - #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) -#endif -#if !defined(WIN32) && !defined(MS_WINDOWS) - #ifndef __stdcall - #define __stdcall - #endif - #ifndef __cdecl - #define __cdecl - #endif - #ifndef __fastcall - #define __fastcall - #endif -#endif -#ifndef DL_IMPORT - #define DL_IMPORT(t) t -#endif -#ifndef DL_EXPORT - #define DL_EXPORT(t) t -#endif -#ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) - #define HAVE_LONG_LONG - #endif -#endif -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif -#ifndef Py_HUGE_VAL - #define Py_HUGE_VAL HUGE_VAL -#endif -#ifdef PYPY_VERSION - #define CYTHON_COMPILING_IN_PYPY 1 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #undef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #undef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #undef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 1 - #undef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 0 - #undef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 0 - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 -#elif defined(PYSTON_VERSION) - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 1 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 -#else - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 1 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #if PY_MAJOR_VERSION < 3 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #elif !defined(CYTHON_USE_PYLONG_INTERNALS) - #define CYTHON_USE_PYLONG_INTERNALS 1 - #endif - #ifndef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 1 - #endif - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #if PY_VERSION_HEX < 0x030300F0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #elif !defined(CYTHON_USE_UNICODE_WRITER) - #define CYTHON_USE_UNICODE_WRITER 1 - #endif - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #ifndef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 1 - #endif - #ifndef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 1 - #endif -#endif -#if !defined(CYTHON_FAST_PYCCALL) -#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) -#endif -#if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #undef SHIFT - #undef BASE - #undef MASK -#endif -#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) - #define Py_OptimizeFlag 0 -#endif -#define __PYX_BUILD_PY_SSIZE_T "n" -#define CYTHON_FORMAT_SSIZE_T "z" -#if PY_MAJOR_VERSION < 3 - #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) - #define __Pyx_DefaultClassType PyClass_Type -#else - #define __Pyx_BUILTIN_MODULE_NAME "builtins" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) - #define __Pyx_DefaultClassType PyType_Type -#endif -#ifndef Py_TPFLAGS_CHECKTYPES - #define Py_TPFLAGS_CHECKTYPES 0 -#endif -#ifndef Py_TPFLAGS_HAVE_INDEX - #define Py_TPFLAGS_HAVE_INDEX 0 -#endif -#ifndef Py_TPFLAGS_HAVE_NEWBUFFER - #define Py_TPFLAGS_HAVE_NEWBUFFER 0 -#endif -#ifndef Py_TPFLAGS_HAVE_FINALIZE - #define Py_TPFLAGS_HAVE_FINALIZE 0 -#endif -#ifndef METH_FASTCALL - #define METH_FASTCALL 0x80 - typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, - Py_ssize_t nargs, PyObject *kwnames); -#else - #define __Pyx_PyCFunctionFast _PyCFunctionFast -#endif -#if CYTHON_FAST_PYCCALL -#define __Pyx_PyFastCFunction_Check(func)\ - ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST))))) -#else -#define __Pyx_PyFastCFunction_Check(func) 0 -#endif -#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) - #define CYTHON_PEP393_ENABLED 1 - #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ - 0 : _PyUnicode_Ready((PyObject *)(op))) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) - #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) - #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) - #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) -#else - #define CYTHON_PEP393_ENABLED 0 - #define PyUnicode_1BYTE_KIND 1 - #define PyUnicode_2BYTE_KIND 2 - #define PyUnicode_4BYTE_KIND 4 - #define __Pyx_PyUnicode_READY(op) (0) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) - #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) - #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) - #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) -#endif -#if CYTHON_COMPILING_IN_PYPY - #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) -#else - #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ - PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) - #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) - #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) - #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) - #define PyObject_Malloc(s) PyMem_Malloc(s) - #define PyObject_Free(p) PyMem_Free(p) - #define PyObject_Realloc(p) PyMem_Realloc(p) -#endif -#if CYTHON_COMPILING_IN_PYSTON - #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) -#else - #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) -#endif -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) -#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) -#else - #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) -#endif -#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) - #define PyObject_ASCII(o) PyObject_Repr(o) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBaseString_Type PyUnicode_Type - #define PyStringObject PyUnicodeObject - #define PyString_Type PyUnicode_Type - #define PyString_Check PyUnicode_Check - #define PyString_CheckExact PyUnicode_CheckExact -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) - #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) -#else - #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) -#endif -#ifndef PySet_CheckExact - #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) -#endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) -#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) -#if PY_MAJOR_VERSION >= 3 - #define PyIntObject PyLongObject - #define PyInt_Type PyLong_Type - #define PyInt_Check(op) PyLong_Check(op) - #define PyInt_CheckExact(op) PyLong_CheckExact(op) - #define PyInt_FromString PyLong_FromString - #define PyInt_FromUnicode PyLong_FromUnicode - #define PyInt_FromLong PyLong_FromLong - #define PyInt_FromSize_t PyLong_FromSize_t - #define PyInt_FromSsize_t PyLong_FromSsize_t - #define PyInt_AsLong PyLong_AsLong - #define PyInt_AS_LONG PyLong_AS_LONG - #define PyInt_AsSsize_t PyLong_AsSsize_t - #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask - #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask - #define PyNumber_Int PyNumber_Long -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBoolObject PyLongObject -#endif -#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY - #ifndef PyUnicode_InternFromString - #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) - #endif -#endif -#if PY_VERSION_HEX < 0x030200A4 - typedef long Py_hash_t; - #define __Pyx_PyInt_FromHash_t PyInt_FromLong - #define __Pyx_PyInt_AsHash_t PyInt_AsLong -#else - #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t - #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) -#else - #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) -#endif -#if CYTHON_USE_ASYNC_SLOTS - #if PY_VERSION_HEX >= 0x030500B1 - #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods - #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) - #else - typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; - } __Pyx_PyAsyncMethodsStruct; - #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL -#endif -#ifndef CYTHON_RESTRICT - #if defined(__GNUC__) - #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) && _MSC_VER >= 1400 - #define CYTHON_RESTRICT __restrict - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_RESTRICT restrict - #else - #define CYTHON_RESTRICT - #endif -#endif -#ifndef CYTHON_UNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -#endif -#ifndef CYTHON_MAYBE_UNUSED_VAR -# if defined(__cplusplus) - template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } -# else -# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif -#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) - -#ifndef CYTHON_INLINE - #if defined(__clang__) - #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) - #elif defined(__GNUC__) - #define CYTHON_INLINE __inline__ - #elif defined(_MSC_VER) - #define CYTHON_INLINE __inline - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_INLINE inline - #else - #define CYTHON_INLINE - #endif -#endif - -#if defined(WIN32) || defined(MS_WINDOWS) - #define _USE_MATH_DEFINES -#endif -#include -#ifdef NAN -#define __PYX_NAN() ((float) NAN) -#else -static CYTHON_INLINE float __PYX_NAN() { - float value; - memset(&value, 0xFF, sizeof(value)); - return value; -} -#endif -#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) -#define __Pyx_truncl trunc -#else -#define __Pyx_truncl truncl -#endif - - -#define __PYX_ERR(f_index, lineno, Ln_error) \ -{ \ - __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ -} - -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#endif - -#ifndef __PYX_EXTERN_C - #ifdef __cplusplus - #define __PYX_EXTERN_C extern "C" - #else - #define __PYX_EXTERN_C extern - #endif -#endif - -#define __PYX_HAVE__zarr__blosc -#define __PYX_HAVE_API__zarr__blosc -#include -#include -#include "pythread.h" -#include "blosc.h" -#ifdef _OPENMP -#include -#endif /* _OPENMP */ - -#ifdef PYREX_WITHOUT_ASSERTIONS -#define CYTHON_WITHOUT_ASSERTIONS -#endif - -typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; - const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; - -#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 -#define __PYX_DEFAULT_STRING_ENCODING "" -#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString -#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#define __Pyx_uchar_cast(c) ((unsigned char)c) -#define __Pyx_long_cast(x) ((long)x) -#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ - (sizeof(type) < sizeof(Py_ssize_t)) ||\ - (sizeof(type) > sizeof(Py_ssize_t) &&\ - likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX) &&\ - (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ - v == (type)PY_SSIZE_T_MIN))) ||\ - (sizeof(type) == sizeof(Py_ssize_t) &&\ - (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX))) ) -#if defined (__cplusplus) && __cplusplus >= 201103L - #include - #define __Pyx_sst_abs(value) std::abs(value) -#elif SIZEOF_INT >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) abs(value) -#elif SIZEOF_LONG >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) labs(value) -#elif defined (_MSC_VER) && defined (_M_X64) - #define __Pyx_sst_abs(value) _abs64(value) -#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define __Pyx_sst_abs(value) llabs(value) -#elif defined (__GNUC__) - #define __Pyx_sst_abs(value) __builtin_llabs(value) -#else - #define __Pyx_sst_abs(value) ((value<0) ? -value : value) -#endif -static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); -static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); -#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) -#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) -#define __Pyx_PyBytes_FromString PyBytes_FromString -#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#else - #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize -#endif -#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) -#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) -#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) -#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) -#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -#if PY_MAJOR_VERSION < 3 -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) -{ - const Py_UNICODE *u_end = u; - while (*u_end++) ; - return (size_t)(u_end - u - 1); -} -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif -#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) -#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode -#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode -#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) -#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -#if CYTHON_ASSUME_SAFE_MACROS -#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) -#else -#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) -#endif -#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) -#else -#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) -#endif -#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII -static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - PyObject* ascii_chars_u = NULL; - PyObject* ascii_chars_b = NULL; - const char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - if (strcmp(default_encoding_c, "ascii") == 0) { - __Pyx_sys_getdefaultencoding_not_ascii = 0; - } else { - char ascii_chars[128]; - int c; - for (c = 0; c < 128; c++) { - ascii_chars[c] = c; - } - __Pyx_sys_getdefaultencoding_not_ascii = 1; - ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); - if (!ascii_chars_u) goto bad; - ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); - if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { - PyErr_Format( - PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", - default_encoding_c); - goto bad; - } - Py_DECREF(ascii_chars_u); - Py_DECREF(ascii_chars_b); - } - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - Py_XDECREF(ascii_chars_u); - Py_XDECREF(ascii_chars_b); - return -1; -} -#endif -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) -#else -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); - if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; - strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - return -1; -} -#endif -#endif - - -/* Test for GCC > 2.95 */ -#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) - #define likely(x) __builtin_expect(!!(x), 1) - #define unlikely(x) __builtin_expect(!!(x), 0) -#else /* !__GNUC__ or GCC < 2.95 */ - #define likely(x) (x) - #define unlikely(x) (x) -#endif /* __GNUC__ */ - -static PyObject *__pyx_m; -static PyObject *__pyx_d; -static PyObject *__pyx_b; -static PyObject *__pyx_empty_tuple; -static PyObject *__pyx_empty_bytes; -static PyObject *__pyx_empty_unicode; -static int __pyx_lineno; -static int __pyx_clineno = 0; -static const char * __pyx_cfilenm= __FILE__; -static const char *__pyx_filename; - - -static const char *__pyx_f[] = { - "zarr/blosc.pyx", - ".tox/py27/local/lib/python2.7/site-packages/Cython/Includes/cpython/array.pxd", - ".tox/py27/local/lib/python2.7/site-packages/Cython/Includes/cpython/type.pxd", - ".tox/py27/local/lib/python2.7/site-packages/Cython/Includes/cpython/bool.pxd", - ".tox/py27/local/lib/python2.7/site-packages/Cython/Includes/cpython/complex.pxd", -}; - -/*--- Type declarations ---*/ -#ifndef _ARRAYARRAY_H -struct arrayobject; -typedef struct arrayobject arrayobject; -#endif - -/* --- Runtime support code (head) --- */ -/* Refnanny.proto */ -#ifndef CYTHON_REFNANNY - #define CYTHON_REFNANNY 0 -#endif -#if CYTHON_REFNANNY - typedef struct { - void (*INCREF)(void*, PyObject*, int); - void (*DECREF)(void*, PyObject*, int); - void (*GOTREF)(void*, PyObject*, int); - void (*GIVEREF)(void*, PyObject*, int); - void* (*SetupContext)(const char*, int, const char*); - void (*FinishContext)(void**); - } __Pyx_RefNannyAPIStruct; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); - #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; -#ifdef WITH_THREAD - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - if (acquire_gil) {\ - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - PyGILState_Release(__pyx_gilstate_save);\ - } else {\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - } -#else - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) -#endif - #define __Pyx_RefNannyFinishContext()\ - __Pyx_RefNanny->FinishContext(&__pyx_refnanny) - #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) - #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) - #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) - #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) -#else - #define __Pyx_RefNannyDeclarations - #define __Pyx_RefNannySetupContext(name, acquire_gil) - #define __Pyx_RefNannyFinishContext() - #define __Pyx_INCREF(r) Py_INCREF(r) - #define __Pyx_DECREF(r) Py_DECREF(r) - #define __Pyx_GOTREF(r) - #define __Pyx_GIVEREF(r) - #define __Pyx_XINCREF(r) Py_XINCREF(r) - #define __Pyx_XDECREF(r) Py_XDECREF(r) - #define __Pyx_XGOTREF(r) - #define __Pyx_XGIVEREF(r) -#endif -#define __Pyx_XDECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_XDECREF(tmp);\ - } while (0) -#define __Pyx_DECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_DECREF(tmp);\ - } while (0) -#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) -#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) - -/* PyObjectGetAttrStr.proto */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_getattro)) - return tp->tp_getattro(obj, attr_name); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} -#else -#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) -#endif - -/* GetBuiltinName.proto */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name); - -/* GetModuleGlobalName.proto */ -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); - -/* PyObjectCall.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); -#else -#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) -#endif - -/* PyFunctionFastCall.proto */ -#if CYTHON_FAST_PYCALL -#define __Pyx_PyFunction_FastCall(func, args, nargs)\ - __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); -#else -#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) -#endif -#endif - -/* PyCFunctionFastCall.proto */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); -#else -#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) -#endif - -/* ExtTypeTest.proto */ -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); - -/* RaiseDoubleKeywords.proto */ -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); - -/* ParseKeywords.proto */ -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ - const char* function_name); - -/* RaiseArgTupleInvalid.proto */ -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); - -/* PyObjectCallMethO.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); -#endif - -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - -/* PyObjectCallNoArg.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); -#else -#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) -#endif - -/* GetItemInt.proto */ -#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ - (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ - __Pyx_GetItemInt_Generic(o, to_py_func(i)))) -#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, - int is_list, int wraparound, int boundscheck); - -/* PyThreadStateGet.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); -#else -#define __Pyx_PyThreadState_declare -#define __Pyx_PyThreadState_assign -#endif - -/* PyErrFetchRestore.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) -#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) -#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) -#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#else -#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) -#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) -#endif - -/* RaiseException.proto */ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); - -/* GetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); -#endif - -/* SwapException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#else -static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); -#endif - -/* SaveResetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -#else -#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) -#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) -#endif - -/* Import.proto */ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); - -/* ImportFrom.proto */ -static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); - -/* CodeObjectCache.proto */ -typedef struct { - PyCodeObject* code_object; - int code_line; -} __Pyx_CodeObjectCacheEntry; -struct __Pyx_CodeObjectCache { - int count; - int max_count; - __Pyx_CodeObjectCacheEntry* entries; -}; -static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); -static PyCodeObject *__pyx_find_code_object(int code_line); -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); - -/* AddTraceback.proto */ -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename); - -/* ArrayAPI.proto */ -#ifndef _ARRAYARRAY_H -#define _ARRAYARRAY_H -typedef struct arraydescr { - int typecode; - int itemsize; - PyObject * (*getitem)(struct arrayobject *, Py_ssize_t); - int (*setitem)(struct arrayobject *, Py_ssize_t, PyObject *); -#if PY_MAJOR_VERSION >= 3 - char *formats; -#endif -} arraydescr; -struct arrayobject { - PyObject_HEAD - Py_ssize_t ob_size; - union { - char *ob_item; - float *as_floats; - double *as_doubles; - int *as_ints; - unsigned int *as_uints; - unsigned char *as_uchars; - signed char *as_schars; - char *as_chars; - unsigned long *as_ulongs; - long *as_longs; - short *as_shorts; - unsigned short *as_ushorts; - Py_UNICODE *as_pyunicodes; - void *as_voidptr; - } data; - Py_ssize_t allocated; - struct arraydescr *ob_descr; - PyObject *weakreflist; -#if PY_MAJOR_VERSION >= 3 - int ob_exports; -#endif -}; -#ifndef NO_NEWARRAY_INLINE -static CYTHON_INLINE PyObject * newarrayobject(PyTypeObject *type, Py_ssize_t size, - struct arraydescr *descr) { - arrayobject *op; - size_t nbytes; - if (size < 0) { - PyErr_BadInternalCall(); - return NULL; - } - nbytes = size * descr->itemsize; - if (nbytes / descr->itemsize != (size_t)size) { - return PyErr_NoMemory(); - } - op = (arrayobject *) type->tp_alloc(type, 0); - if (op == NULL) { - return NULL; - } - op->ob_descr = descr; - op->allocated = size; - op->weakreflist = NULL; - op->ob_size = size; - if (size <= 0) { - op->data.ob_item = NULL; - } - else { - op->data.ob_item = PyMem_NEW(char, nbytes); - if (op->data.ob_item == NULL) { - Py_DECREF(op); - return PyErr_NoMemory(); - } - } - return (PyObject *) op; -} -#else -PyObject* newarrayobject(PyTypeObject *type, Py_ssize_t size, - struct arraydescr *descr); -#endif -static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) { - void *items = (void*) self->data.ob_item; - PyMem_Resize(items, char, (size_t)(n * self->ob_descr->itemsize)); - if (items == NULL) { - PyErr_NoMemory(); - return -1; - } - self->data.ob_item = (char*) items; - self->ob_size = n; - self->allocated = n; - return 0; -} -static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) { - void *items = (void*) self->data.ob_item; - Py_ssize_t newsize; - if (n < self->allocated && n*4 > self->allocated) { - self->ob_size = n; - return 0; - } - newsize = n + (n / 2) + 1; - if (newsize <= n) { - PyErr_NoMemory(); - return -1; - } - PyMem_Resize(items, char, (size_t)(newsize * self->ob_descr->itemsize)); - if (items == NULL) { - PyErr_NoMemory(); - return -1; - } - self->data.ob_item = (char*) items; - self->ob_size = n; - self->allocated = newsize; - return 0; -} -#endif - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - -/* ForceInitThreads.proto */ -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif - -/* CIntFromPy.proto */ -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); - -/* CIntFromPy.proto */ -static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *); - -/* CIntFromPy.proto */ -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); - -/* CheckBinaryVersion.proto */ -static int __Pyx_check_binary_version(void); - -/* PyIdentifierFromString.proto */ -#if !defined(__Pyx_PyIdentifier_FromString) -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) -#else - #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) -#endif -#endif - -/* ModuleImport.proto */ -static PyObject *__Pyx_ImportModule(const char *name); - -/* TypeImport.proto */ -static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); - -/* InitStrings.proto */ -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); - - -/* Module declarations from 'cpython.version' */ - -/* Module declarations from '__builtin__' */ - -/* Module declarations from 'cpython.type' */ -static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; - -/* Module declarations from 'libc.string' */ - -/* Module declarations from 'libc.stdio' */ - -/* Module declarations from 'cpython.object' */ - -/* Module declarations from 'cpython.ref' */ - -/* Module declarations from 'cpython.exc' */ - -/* Module declarations from 'cpython.module' */ - -/* Module declarations from 'cpython.mem' */ - -/* Module declarations from 'cpython.tuple' */ - -/* Module declarations from 'cpython.list' */ - -/* Module declarations from 'cpython.sequence' */ - -/* Module declarations from 'cpython.mapping' */ - -/* Module declarations from 'cpython.iterator' */ - -/* Module declarations from 'cpython.number' */ - -/* Module declarations from 'cpython.int' */ - -/* Module declarations from '__builtin__' */ - -/* Module declarations from 'cpython.bool' */ -static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0; - -/* Module declarations from 'cpython.long' */ - -/* Module declarations from 'cpython.float' */ - -/* Module declarations from '__builtin__' */ - -/* Module declarations from 'cpython.complex' */ -static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0; - -/* Module declarations from 'cpython.string' */ - -/* Module declarations from 'cpython.unicode' */ - -/* Module declarations from 'cpython.dict' */ - -/* Module declarations from 'cpython.instance' */ - -/* Module declarations from 'cpython.function' */ - -/* Module declarations from 'cpython.method' */ - -/* Module declarations from 'cpython.weakref' */ - -/* Module declarations from 'cpython.getargs' */ - -/* Module declarations from 'cpython.pythread' */ - -/* Module declarations from 'cpython.pystate' */ - -/* Module declarations from 'cpython.cobject' */ - -/* Module declarations from 'cpython.oldbuffer' */ - -/* Module declarations from 'cpython.set' */ - -/* Module declarations from 'cpython.buffer' */ - -/* Module declarations from 'cpython.bytes' */ - -/* Module declarations from 'cpython.pycapsule' */ - -/* Module declarations from 'cpython' */ - -/* Module declarations from 'array' */ - -/* Module declarations from 'cpython.array' */ -static PyTypeObject *__pyx_ptype_7cpython_5array_array = 0; -static CYTHON_INLINE int __pyx_f_7cpython_5array_extend_buffer(arrayobject *, char *, Py_ssize_t); /*proto*/ - -/* Module declarations from 'zarr.blosc' */ -#define __Pyx_MODULE_NAME "zarr.blosc" -int __pyx_module_is_main_zarr__blosc = 0; - -/* Implementation of 'zarr.blosc' */ -static PyObject *__pyx_builtin_ValueError; -static PyObject *__pyx_builtin_RuntimeError; -static PyObject *__pyx_builtin_MemoryError; -static const char __pyx_k__2[] = ","; -static const char __pyx_k_PY2[] = "PY2"; -static const char __pyx_k_ret[] = "ret"; -static const char __pyx_k_data[] = "data"; -static const char __pyx_k_dest[] = "dest"; -static const char __pyx_k_init[] = "init"; -static const char __pyx_k_main[] = "__main__"; -static const char __pyx_k_name[] = "name"; -static const char __pyx_k_test[] = "__test__"; -static const char __pyx_k_array[] = "array"; -static const char __pyx_k_ascii[] = "ascii"; -static const char __pyx_k_cname[] = "cname"; -static const char __pyx_k_split[] = "split"; -static const char __pyx_k_cbytes[] = "cbytes"; -static const char __pyx_k_clevel[] = "clevel"; -static const char __pyx_k_decode[] = "decode"; -static const char __pyx_k_encode[] = "encode"; -static const char __pyx_k_import[] = "__import__"; -static const char __pyx_k_nbytes[] = "nbytes"; -static const char __pyx_k_source[] = "source"; -static const char __pyx_k_SHUFFLE[] = "SHUFFLE"; -static const char __pyx_k_destroy[] = "destroy"; -static const char __pyx_k_shuffle[] = "shuffle"; -static const char __pyx_k_version[] = "__version__"; -static const char __pyx_k_compress[] = "compress"; -static const char __pyx_k_dest_ptr[] = "dest_ptr"; -static const char __pyx_k_itemsize[] = "itemsize"; -static const char __pyx_k_nthreads[] = "nthreads"; -static const char __pyx_k_NOSHUFFLE[] = "NOSHUFFLE"; -static const char __pyx_k_blocksize[] = "blocksize"; -static const char __pyx_k_text_type[] = "text_type"; -static const char __pyx_k_threading[] = "threading"; -static const char __pyx_k_version_2[] = "version"; -static const char __pyx_k_BITSHUFFLE[] = "BITSHUFFLE"; -static const char __pyx_k_MainThread[] = "MainThread"; -static const char __pyx_k_ValueError[] = "ValueError"; -static const char __pyx_k_as_voidptr[] = "as_voidptr"; -static const char __pyx_k_decompress[] = "decompress"; -static const char __pyx_k_dest_array[] = "dest_array"; -static const char __pyx_k_source_ptr[] = "source_ptr"; -static const char __pyx_k_zarr_blosc[] = "zarr.blosc"; -static const char __pyx_k_MAX_THREADS[] = "MAX_THREADS"; -static const char __pyx_k_MemoryError[] = "MemoryError"; -static const char __pyx_k_buffer_info[] = "buffer_info"; -static const char __pyx_k_dest_buffer[] = "dest_buffer"; -static const char __pyx_k_dest_nbytes[] = "dest_nbytes"; -static const char __pyx_k_main_thread[] = "main_thread"; -static const char __pyx_k_use_threads[] = "use_threads"; -static const char __pyx_k_zarr_compat[] = "zarr.compat"; -static const char __pyx_k_MAX_OVERHEAD[] = "MAX_OVERHEAD"; -static const char __pyx_k_MAX_TYPESIZE[] = "MAX_TYPESIZE"; -static const char __pyx_k_RuntimeError[] = "RuntimeError"; -static const char __pyx_k_VERSION_DATE[] = "VERSION_DATE"; -static const char __pyx_k_get_nthreads[] = "get_nthreads"; -static const char __pyx_k_set_nthreads[] = "set_nthreads"; -static const char __pyx_k_source_array[] = "source_array"; -static const char __pyx_k_cbuffer_sizes[] = "cbuffer_sizes"; -static const char __pyx_k_source_buffer[] = "source_buffer"; -static const char __pyx_k_use_threads_2[] = "_use_threads"; -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_get_use_threads[] = "_get_use_threads"; -static const char __pyx_k_list_compressors[] = "list_compressors"; -static const char __pyx_k_release_dest_buffer[] = "release_dest_buffer"; -static const char __pyx_k_compname_to_compcode[] = "compname_to_compcode"; -static const char __pyx_k_release_source_buffer[] = "release_source_buffer"; -static const char __pyx_k_compressor_not_supported_r[] = "compressor not supported: %r"; -static const char __pyx_k_home_aliman_src_github_alimanfo[] = "/home/aliman/src/github/alimanfoo/zarr/zarr/blosc.pyx"; -static const char __pyx_k_destination_buffer_has_wrong_siz[] = "destination buffer has wrong size; expected %s, got %s"; -static const char __pyx_k_error_during_blosc_compression_d[] = "error during blosc compression: %d"; -static const char __pyx_k_error_during_blosc_decompression[] = "error during blosc decompression: %d"; -static PyObject *__pyx_n_s_BITSHUFFLE; -static PyObject *__pyx_n_s_MAX_BUFFERSIZE; -static PyObject *__pyx_n_s_MAX_OVERHEAD; -static PyObject *__pyx_n_s_MAX_THREADS; -static PyObject *__pyx_n_s_MAX_TYPESIZE; -static PyObject *__pyx_n_s_MainThread; -static PyObject *__pyx_n_s_MemoryError; -static PyObject *__pyx_n_s_NOSHUFFLE; -static PyObject *__pyx_n_s_PY2; -static PyObject *__pyx_n_s_RuntimeError; -static PyObject *__pyx_n_s_SHUFFLE; -static PyObject *__pyx_n_s_VERSION_DATE; -static PyObject *__pyx_n_s_VERSION_STRING; -static PyObject *__pyx_n_s_ValueError; -static PyObject *__pyx_kp_s__2; -static PyObject *__pyx_n_s_array; -static PyObject *__pyx_n_s_as_voidptr; -static PyObject *__pyx_n_s_ascii; -static PyObject *__pyx_n_s_blocksize; -static PyObject *__pyx_n_s_buffer_info; -static PyObject *__pyx_n_s_cbuffer_sizes; -static PyObject *__pyx_n_s_cbytes; -static PyObject *__pyx_n_s_clevel; -static PyObject *__pyx_n_s_cname; -static PyObject *__pyx_n_s_compname_to_compcode; -static PyObject *__pyx_n_s_compress; -static PyObject *__pyx_kp_s_compressor_not_supported_r; -static PyObject *__pyx_n_s_compressor_set; -static PyObject *__pyx_n_s_current_thread; -static PyObject *__pyx_n_s_data; -static PyObject *__pyx_n_s_decode; -static PyObject *__pyx_n_s_decompress; -static PyObject *__pyx_n_s_dest; -static PyObject *__pyx_n_s_dest_array; -static PyObject *__pyx_n_s_dest_buffer; -static PyObject *__pyx_n_s_dest_nbytes; -static PyObject *__pyx_n_s_dest_ptr; -static PyObject *__pyx_kp_s_destination_buffer_has_wrong_siz; -static PyObject *__pyx_n_s_destroy; -static PyObject *__pyx_n_s_encode; -static PyObject *__pyx_kp_s_error_during_blosc_compression_d; -static PyObject *__pyx_kp_s_error_during_blosc_decompression; -static PyObject *__pyx_n_s_get_nthreads; -static PyObject *__pyx_n_s_get_use_threads; -static PyObject *__pyx_kp_s_home_aliman_src_github_alimanfo; -static PyObject *__pyx_n_s_import; -static PyObject *__pyx_n_s_init; -static PyObject *__pyx_n_s_itemsize; -static PyObject *__pyx_n_s_list_compressors; -static PyObject *__pyx_n_s_main; -static PyObject *__pyx_n_s_main_thread; -static PyObject *__pyx_n_s_name; -static PyObject *__pyx_n_s_nbytes; -static PyObject *__pyx_n_s_nthreads; -static PyObject *__pyx_n_s_release_dest_buffer; -static PyObject *__pyx_n_s_release_source_buffer; -static PyObject *__pyx_n_s_ret; -static PyObject *__pyx_n_s_set_nthreads; -static PyObject *__pyx_n_s_shuffle; -static PyObject *__pyx_n_s_source; -static PyObject *__pyx_n_s_source_array; -static PyObject *__pyx_n_s_source_buffer; -static PyObject *__pyx_n_s_source_ptr; -static PyObject *__pyx_n_s_split; -static PyObject *__pyx_n_s_test; -static PyObject *__pyx_n_s_text_type; -static PyObject *__pyx_n_s_threading; -static PyObject *__pyx_n_s_use_threads; -static PyObject *__pyx_n_s_use_threads_2; -static PyObject *__pyx_n_s_version; -static PyObject *__pyx_n_s_version_2; -static PyObject *__pyx_n_s_zarr_blosc; -static PyObject *__pyx_n_s_zarr_compat; -static PyObject *__pyx_pf_4zarr_5blosc_version(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_4zarr_5blosc_2init(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_4zarr_5blosc_4destroy(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_4zarr_5blosc_6compname_to_compcode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cname); /* proto */ -static PyObject *__pyx_pf_4zarr_5blosc_8list_compressors(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_4zarr_5blosc_10get_nthreads(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_4zarr_5blosc_12set_nthreads(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_nthreads); /* proto */ -static PyObject *__pyx_pf_4zarr_5blosc_14cbuffer_sizes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_source); /* proto */ -static PyObject *__pyx_pf_4zarr_5blosc_16decompress(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_source, PyObject *__pyx_v_dest); /* proto */ -static PyObject *__pyx_pf_4zarr_5blosc_18compress(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_source, char *__pyx_v_cname, int __pyx_v_clevel, int __pyx_v_shuffle); /* proto */ -static PyObject *__pyx_pf_4zarr_5blosc_20_get_use_threads(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static int __pyx_pf_7cpython_5array_5array___getbuffer__(arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info, CYTHON_UNUSED int __pyx_v_flags); /* proto */ -static void __pyx_pf_7cpython_5array_5array_2__releasebuffer__(CYTHON_UNUSED arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ -static PyObject *__pyx_tuple_; -static PyObject *__pyx_tuple__3; -static PyObject *__pyx_tuple__7; -static PyObject *__pyx_tuple__11; -static PyObject *__pyx_tuple__13; -static PyObject *__pyx_tuple__15; -static PyObject *__pyx_tuple__17; -static PyObject *__pyx_tuple__19; -static PyObject *__pyx_codeobj__4; -static PyObject *__pyx_codeobj__5; -static PyObject *__pyx_codeobj__6; -static PyObject *__pyx_codeobj__8; -static PyObject *__pyx_codeobj__9; -static PyObject *__pyx_codeobj__10; -static PyObject *__pyx_codeobj__12; -static PyObject *__pyx_codeobj__14; -static PyObject *__pyx_codeobj__16; -static PyObject *__pyx_codeobj__18; -static PyObject *__pyx_codeobj__20; - -/* "zarr/blosc.pyx":70 - * - * - * def version(): # <<<<<<<<<<<<<< - * return VERSION_STRING, VERSION_DATE - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_4zarr_5blosc_1version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4zarr_5blosc_version[] = "version()"; -static PyMethodDef __pyx_mdef_4zarr_5blosc_1version = {"version", (PyCFunction)__pyx_pw_4zarr_5blosc_1version, METH_NOARGS, __pyx_doc_4zarr_5blosc_version}; -static PyObject *__pyx_pw_4zarr_5blosc_1version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("version (wrapper)", 0); - __pyx_r = __pyx_pf_4zarr_5blosc_version(__pyx_self); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_4zarr_5blosc_version(CYTHON_UNUSED PyObject *__pyx_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - __Pyx_RefNannySetupContext("version", 0); - - /* "zarr/blosc.pyx":71 - * - * def version(): - * return VERSION_STRING, VERSION_DATE # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_VERSION_STRING); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_VERSION_DATE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); - __pyx_t_1 = 0; - __pyx_t_2 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; - - /* "zarr/blosc.pyx":70 - * - * - * def version(): # <<<<<<<<<<<<<< - * return VERSION_STRING, VERSION_DATE - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("zarr.blosc.version", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "zarr/blosc.pyx":74 - * - * - * def init(): # <<<<<<<<<<<<<< - * blosc_init() - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_4zarr_5blosc_3init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4zarr_5blosc_2init[] = "init()"; -static PyMethodDef __pyx_mdef_4zarr_5blosc_3init = {"init", (PyCFunction)__pyx_pw_4zarr_5blosc_3init, METH_NOARGS, __pyx_doc_4zarr_5blosc_2init}; -static PyObject *__pyx_pw_4zarr_5blosc_3init(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("init (wrapper)", 0); - __pyx_r = __pyx_pf_4zarr_5blosc_2init(__pyx_self); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_4zarr_5blosc_2init(CYTHON_UNUSED PyObject *__pyx_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("init", 0); - - /* "zarr/blosc.pyx":75 - * - * def init(): - * blosc_init() # <<<<<<<<<<<<<< - * - * - */ - blosc_init(); - - /* "zarr/blosc.pyx":74 - * - * - * def init(): # <<<<<<<<<<<<<< - * blosc_init() - * - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "zarr/blosc.pyx":78 - * - * - * def destroy(): # <<<<<<<<<<<<<< - * blosc_destroy() - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_4zarr_5blosc_5destroy(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4zarr_5blosc_4destroy[] = "destroy()"; -static PyMethodDef __pyx_mdef_4zarr_5blosc_5destroy = {"destroy", (PyCFunction)__pyx_pw_4zarr_5blosc_5destroy, METH_NOARGS, __pyx_doc_4zarr_5blosc_4destroy}; -static PyObject *__pyx_pw_4zarr_5blosc_5destroy(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("destroy (wrapper)", 0); - __pyx_r = __pyx_pf_4zarr_5blosc_4destroy(__pyx_self); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_4zarr_5blosc_4destroy(CYTHON_UNUSED PyObject *__pyx_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("destroy", 0); - - /* "zarr/blosc.pyx":79 - * - * def destroy(): - * blosc_destroy() # <<<<<<<<<<<<<< - * - * - */ - blosc_destroy(); - - /* "zarr/blosc.pyx":78 - * - * - * def destroy(): # <<<<<<<<<<<<<< - * blosc_destroy() - * - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "zarr/blosc.pyx":82 - * - * - * def compname_to_compcode(cname): # <<<<<<<<<<<<<< - * if isinstance(cname, text_type): - * cname = cname.encode('ascii') - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_4zarr_5blosc_7compname_to_compcode(PyObject *__pyx_self, PyObject *__pyx_v_cname); /*proto*/ -static char __pyx_doc_4zarr_5blosc_6compname_to_compcode[] = "compname_to_compcode(cname)"; -static PyMethodDef __pyx_mdef_4zarr_5blosc_7compname_to_compcode = {"compname_to_compcode", (PyCFunction)__pyx_pw_4zarr_5blosc_7compname_to_compcode, METH_O, __pyx_doc_4zarr_5blosc_6compname_to_compcode}; -static PyObject *__pyx_pw_4zarr_5blosc_7compname_to_compcode(PyObject *__pyx_self, PyObject *__pyx_v_cname) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("compname_to_compcode (wrapper)", 0); - __pyx_r = __pyx_pf_4zarr_5blosc_6compname_to_compcode(__pyx_self, ((PyObject *)__pyx_v_cname)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_4zarr_5blosc_6compname_to_compcode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cname) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - char const *__pyx_t_5; - __Pyx_RefNannySetupContext("compname_to_compcode", 0); - __Pyx_INCREF(__pyx_v_cname); - - /* "zarr/blosc.pyx":83 - * - * def compname_to_compcode(cname): - * if isinstance(cname, text_type): # <<<<<<<<<<<<<< - * cname = cname.encode('ascii') - * return blosc_compname_to_compcode(cname) - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_text_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_IsInstance(__pyx_v_cname, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 83, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = (__pyx_t_2 != 0); - if (__pyx_t_3) { - - /* "zarr/blosc.pyx":84 - * def compname_to_compcode(cname): - * if isinstance(cname, text_type): - * cname = cname.encode('ascii') # <<<<<<<<<<<<<< - * return blosc_compname_to_compcode(cname) - * - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_cname, __pyx_n_s_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 84, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF_SET(__pyx_v_cname, __pyx_t_4); - __pyx_t_4 = 0; - - /* "zarr/blosc.pyx":83 - * - * def compname_to_compcode(cname): - * if isinstance(cname, text_type): # <<<<<<<<<<<<<< - * cname = cname.encode('ascii') - * return blosc_compname_to_compcode(cname) - */ - } - - /* "zarr/blosc.pyx":85 - * if isinstance(cname, text_type): - * cname = cname.encode('ascii') - * return blosc_compname_to_compcode(cname) # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = __Pyx_PyObject_AsString(__pyx_v_cname); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyInt_From_int(blosc_compname_to_compcode(__pyx_t_5)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L0; - - /* "zarr/blosc.pyx":82 - * - * - * def compname_to_compcode(cname): # <<<<<<<<<<<<<< - * if isinstance(cname, text_type): - * cname = cname.encode('ascii') - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("zarr.blosc.compname_to_compcode", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_cname); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "zarr/blosc.pyx":88 - * - * - * def list_compressors(): # <<<<<<<<<<<<<< - * return text_type(blosc_list_compressors(), 'ascii').split(',') - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_4zarr_5blosc_9list_compressors(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4zarr_5blosc_8list_compressors[] = "list_compressors()"; -static PyMethodDef __pyx_mdef_4zarr_5blosc_9list_compressors = {"list_compressors", (PyCFunction)__pyx_pw_4zarr_5blosc_9list_compressors, METH_NOARGS, __pyx_doc_4zarr_5blosc_8list_compressors}; -static PyObject *__pyx_pw_4zarr_5blosc_9list_compressors(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("list_compressors (wrapper)", 0); - __pyx_r = __pyx_pf_4zarr_5blosc_8list_compressors(__pyx_self); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_4zarr_5blosc_8list_compressors(CYTHON_UNUSED PyObject *__pyx_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - __Pyx_RefNannySetupContext("list_compressors", 0); - - /* "zarr/blosc.pyx":89 - * - * def list_compressors(): - * return text_type(blosc_list_compressors(), 'ascii').split(',') # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_text_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyBytes_FromString(blosc_list_compressors()); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __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_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_5 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_3, __pyx_n_s_ascii}; - __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, 89, __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 - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_3, __pyx_n_s_ascii}; - __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, 89, __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, 89, __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_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_3); - __Pyx_INCREF(__pyx_n_s_ascii); - __Pyx_GIVEREF(__pyx_n_s_ascii); - PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_n_s_ascii); - __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, 89, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __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; - - /* "zarr/blosc.pyx":88 - * - * - * def list_compressors(): # <<<<<<<<<<<<<< - * return text_type(blosc_list_compressors(), 'ascii').split(',') - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("zarr.blosc.list_compressors", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "zarr/blosc.pyx":92 - * - * - * def get_nthreads(): # <<<<<<<<<<<<<< - * """Get the number of threads that Blosc uses internally for compression - * and decompression. - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_4zarr_5blosc_11get_nthreads(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4zarr_5blosc_10get_nthreads[] = "get_nthreads()\nGet the number of threads that Blosc uses internally for compression\n and decompression.\n ."; -static PyMethodDef __pyx_mdef_4zarr_5blosc_11get_nthreads = {"get_nthreads", (PyCFunction)__pyx_pw_4zarr_5blosc_11get_nthreads, METH_NOARGS, __pyx_doc_4zarr_5blosc_10get_nthreads}; -static PyObject *__pyx_pw_4zarr_5blosc_11get_nthreads(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_nthreads (wrapper)", 0); - __pyx_r = __pyx_pf_4zarr_5blosc_10get_nthreads(__pyx_self); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_4zarr_5blosc_10get_nthreads(CYTHON_UNUSED PyObject *__pyx_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("get_nthreads", 0); - - /* "zarr/blosc.pyx":96 - * and decompression. - * .""" - * return blosc_get_nthreads() # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(blosc_get_nthreads()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "zarr/blosc.pyx":92 - * - * - * def get_nthreads(): # <<<<<<<<<<<<<< - * """Get the number of threads that Blosc uses internally for compression - * and decompression. - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("zarr.blosc.get_nthreads", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "zarr/blosc.pyx":99 - * - * - * def set_nthreads(int nthreads): # <<<<<<<<<<<<<< - * """Set the number of threads that Blosc uses internally for compression - * and decompression. - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_4zarr_5blosc_13set_nthreads(PyObject *__pyx_self, PyObject *__pyx_arg_nthreads); /*proto*/ -static char __pyx_doc_4zarr_5blosc_12set_nthreads[] = "set_nthreads(int nthreads)\nSet the number of threads that Blosc uses internally for compression\n and decompression.\n ."; -static PyMethodDef __pyx_mdef_4zarr_5blosc_13set_nthreads = {"set_nthreads", (PyCFunction)__pyx_pw_4zarr_5blosc_13set_nthreads, METH_O, __pyx_doc_4zarr_5blosc_12set_nthreads}; -static PyObject *__pyx_pw_4zarr_5blosc_13set_nthreads(PyObject *__pyx_self, PyObject *__pyx_arg_nthreads) { - int __pyx_v_nthreads; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("set_nthreads (wrapper)", 0); - assert(__pyx_arg_nthreads); { - __pyx_v_nthreads = __Pyx_PyInt_As_int(__pyx_arg_nthreads); if (unlikely((__pyx_v_nthreads == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 99, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L3_error:; - __Pyx_AddTraceback("zarr.blosc.set_nthreads", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_4zarr_5blosc_12set_nthreads(__pyx_self, ((int)__pyx_v_nthreads)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_4zarr_5blosc_12set_nthreads(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_nthreads) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("set_nthreads", 0); - - /* "zarr/blosc.pyx":103 - * and decompression. - * .""" - * return blosc_set_nthreads(nthreads) # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(blosc_set_nthreads(__pyx_v_nthreads)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "zarr/blosc.pyx":99 - * - * - * def set_nthreads(int nthreads): # <<<<<<<<<<<<<< - * """Set the number of threads that Blosc uses internally for compression - * and decompression. - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("zarr.blosc.set_nthreads", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "zarr/blosc.pyx":106 - * - * - * def cbuffer_sizes(source): # <<<<<<<<<<<<<< - * """Return information from the blosc header of some compressed data.""" - * cdef: - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_4zarr_5blosc_15cbuffer_sizes(PyObject *__pyx_self, PyObject *__pyx_v_source); /*proto*/ -static char __pyx_doc_4zarr_5blosc_14cbuffer_sizes[] = "cbuffer_sizes(source)\nReturn information from the blosc header of some compressed data."; -static PyMethodDef __pyx_mdef_4zarr_5blosc_15cbuffer_sizes = {"cbuffer_sizes", (PyCFunction)__pyx_pw_4zarr_5blosc_15cbuffer_sizes, METH_O, __pyx_doc_4zarr_5blosc_14cbuffer_sizes}; -static PyObject *__pyx_pw_4zarr_5blosc_15cbuffer_sizes(PyObject *__pyx_self, PyObject *__pyx_v_source) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("cbuffer_sizes (wrapper)", 0); - __pyx_r = __pyx_pf_4zarr_5blosc_14cbuffer_sizes(__pyx_self, ((PyObject *)__pyx_v_source)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_4zarr_5blosc_14cbuffer_sizes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_source) { - char *__pyx_v_source_ptr; - Py_buffer __pyx_v_source_buffer; - arrayobject *__pyx_v_source_array = 0; - size_t __pyx_v_nbytes; - size_t __pyx_v_cbytes; - size_t __pyx_v_blocksize; - int __pyx_v_release_source_buffer; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - int __pyx_t_4; - int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("cbuffer_sizes", 0); - - /* "zarr/blosc.pyx":115 - * - * # setup source buffer - * if PY2 and isinstance(source, array.array): # <<<<<<<<<<<<<< - * # workaround fact that array.array does not support new-style buffer - * # interface in PY2 - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PY2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__pyx_t_3) { - } else { - __pyx_t_1 = __pyx_t_3; - goto __pyx_L4_bool_binop_done; - } - __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_source, __pyx_ptype_7cpython_5array_array); - __pyx_t_4 = (__pyx_t_3 != 0); - __pyx_t_1 = __pyx_t_4; - __pyx_L4_bool_binop_done:; - if (__pyx_t_1) { - - /* "zarr/blosc.pyx":118 - * # workaround fact that array.array does not support new-style buffer - * # interface in PY2 - * release_source_buffer = False # <<<<<<<<<<<<<< - * source_array = source - * source_ptr = source_array.data.as_voidptr - */ - __pyx_v_release_source_buffer = 0; - - /* "zarr/blosc.pyx":119 - * # interface in PY2 - * release_source_buffer = False - * source_array = source # <<<<<<<<<<<<<< - * source_ptr = source_array.data.as_voidptr - * else: - */ - if (!(likely(((__pyx_v_source) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_source, __pyx_ptype_7cpython_5array_array))))) __PYX_ERR(0, 119, __pyx_L1_error) - __pyx_t_2 = __pyx_v_source; - __Pyx_INCREF(__pyx_t_2); - __pyx_v_source_array = ((arrayobject *)__pyx_t_2); - __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":120 - * release_source_buffer = False - * source_array = source - * source_ptr = source_array.data.as_voidptr # <<<<<<<<<<<<<< - * else: - * release_source_buffer = True - */ - __pyx_v_source_ptr = ((char *)__pyx_v_source_array->data.as_voidptr); - - /* "zarr/blosc.pyx":115 - * - * # setup source buffer - * if PY2 and isinstance(source, array.array): # <<<<<<<<<<<<<< - * # workaround fact that array.array does not support new-style buffer - * # interface in PY2 - */ - goto __pyx_L3; - } - - /* "zarr/blosc.pyx":122 - * source_ptr = source_array.data.as_voidptr - * else: - * release_source_buffer = True # <<<<<<<<<<<<<< - * PyObject_GetBuffer(source, &source_buffer, PyBUF_ANY_CONTIGUOUS) - * source_ptr = source_buffer.buf - */ - /*else*/ { - __pyx_v_release_source_buffer = 1; - - /* "zarr/blosc.pyx":123 - * else: - * release_source_buffer = True - * PyObject_GetBuffer(source, &source_buffer, PyBUF_ANY_CONTIGUOUS) # <<<<<<<<<<<<<< - * source_ptr = source_buffer.buf - * - */ - __pyx_t_5 = PyObject_GetBuffer(__pyx_v_source, (&__pyx_v_source_buffer), PyBUF_ANY_CONTIGUOUS); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 123, __pyx_L1_error) - - /* "zarr/blosc.pyx":124 - * release_source_buffer = True - * PyObject_GetBuffer(source, &source_buffer, PyBUF_ANY_CONTIGUOUS) - * source_ptr = source_buffer.buf # <<<<<<<<<<<<<< - * - * # determine buffer size - */ - __pyx_v_source_ptr = ((char *)__pyx_v_source_buffer.buf); - } - __pyx_L3:; - - /* "zarr/blosc.pyx":127 - * - * # determine buffer size - * blosc_cbuffer_sizes(source_ptr, &nbytes, &cbytes, &blocksize) # <<<<<<<<<<<<<< - * - * # release buffers - */ - blosc_cbuffer_sizes(__pyx_v_source_ptr, (&__pyx_v_nbytes), (&__pyx_v_cbytes), (&__pyx_v_blocksize)); - - /* "zarr/blosc.pyx":130 - * - * # release buffers - * if release_source_buffer: # <<<<<<<<<<<<<< - * PyBuffer_Release(&source_buffer) - * - */ - __pyx_t_1 = (__pyx_v_release_source_buffer != 0); - if (__pyx_t_1) { - - /* "zarr/blosc.pyx":131 - * # release buffers - * if release_source_buffer: - * PyBuffer_Release(&source_buffer) # <<<<<<<<<<<<<< - * - * return nbytes, cbytes, blocksize - */ - PyBuffer_Release((&__pyx_v_source_buffer)); - - /* "zarr/blosc.pyx":130 - * - * # release buffers - * if release_source_buffer: # <<<<<<<<<<<<<< - * PyBuffer_Release(&source_buffer) - * - */ - } - - /* "zarr/blosc.pyx":133 - * PyBuffer_Release(&source_buffer) - * - * return nbytes, cbytes, blocksize # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_nbytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = __Pyx_PyInt_FromSize_t(__pyx_v_cbytes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 133, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = __Pyx_PyInt_FromSize_t(__pyx_v_blocksize); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 133, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 133, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7); - __pyx_t_2 = 0; - __pyx_t_6 = 0; - __pyx_t_7 = 0; - __pyx_r = __pyx_t_8; - __pyx_t_8 = 0; - goto __pyx_L0; - - /* "zarr/blosc.pyx":106 - * - * - * def cbuffer_sizes(source): # <<<<<<<<<<<<<< - * """Return information from the blosc header of some compressed data.""" - * cdef: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("zarr.blosc.cbuffer_sizes", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_source_array); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "zarr/blosc.pyx":136 - * - * - * def decompress(source, dest=None): # <<<<<<<<<<<<<< - * """Decompress data. - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_4zarr_5blosc_17decompress(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_4zarr_5blosc_16decompress[] = "decompress(source, dest=None)\nDecompress data.\n\n Parameters\n ----------\n source : bytes-like\n Compressed data, including blosc header. Can be any object\n supporting the buffer protocol.\n dest : array-like, optional\n Object to decompress into.\n\n Returns\n -------\n dest : array-like\n Object containing decompressed data.\n\n "; -static PyMethodDef __pyx_mdef_4zarr_5blosc_17decompress = {"decompress", (PyCFunction)__pyx_pw_4zarr_5blosc_17decompress, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4zarr_5blosc_16decompress}; -static PyObject *__pyx_pw_4zarr_5blosc_17decompress(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_source = 0; - PyObject *__pyx_v_dest = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("decompress (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,&__pyx_n_s_dest,0}; - PyObject* values[2] = {0,0}; - values[1] = ((PyObject *)Py_None); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_source)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dest); - if (value) { values[1] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "decompress") < 0)) __PYX_ERR(0, 136, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_source = values[0]; - __pyx_v_dest = values[1]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("decompress", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 136, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("zarr.blosc.decompress", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_4zarr_5blosc_16decompress(__pyx_self, __pyx_v_source, __pyx_v_dest); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_4zarr_5blosc_16decompress(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_source, PyObject *__pyx_v_dest) { - int __pyx_v_ret; - char *__pyx_v_source_ptr; - char *__pyx_v_dest_ptr; - Py_buffer __pyx_v_source_buffer; - arrayobject *__pyx_v_source_array = 0; - Py_buffer __pyx_v_dest_buffer; - size_t __pyx_v_nbytes; - size_t __pyx_v_cbytes; - size_t __pyx_v_blocksize; - int __pyx_v_release_source_buffer; - int __pyx_v_release_dest_buffer; - PyObject *__pyx_v_dest_nbytes = NULL; - PyObject *__pyx_v_dest_array = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - int __pyx_t_4; - int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - char *__pyx_t_7; - PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; - char const *__pyx_t_10; - PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; - PyObject *__pyx_t_13 = NULL; - PyObject *__pyx_t_14 = NULL; - PyObject *__pyx_t_15 = NULL; - PyObject *__pyx_t_16 = NULL; - __Pyx_RefNannySetupContext("decompress", 0); - __Pyx_INCREF(__pyx_v_dest); - - /* "zarr/blosc.pyx":163 - * - * # setup source buffer - * if PY2 and isinstance(source, array.array): # <<<<<<<<<<<<<< - * # workaround fact that array.array does not support new-style buffer - * # interface in PY2 - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PY2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__pyx_t_3) { - } else { - __pyx_t_1 = __pyx_t_3; - goto __pyx_L4_bool_binop_done; - } - __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_source, __pyx_ptype_7cpython_5array_array); - __pyx_t_4 = (__pyx_t_3 != 0); - __pyx_t_1 = __pyx_t_4; - __pyx_L4_bool_binop_done:; - if (__pyx_t_1) { - - /* "zarr/blosc.pyx":166 - * # workaround fact that array.array does not support new-style buffer - * # interface in PY2 - * release_source_buffer = False # <<<<<<<<<<<<<< - * source_array = source - * source_ptr = source_array.data.as_voidptr - */ - __pyx_v_release_source_buffer = 0; - - /* "zarr/blosc.pyx":167 - * # interface in PY2 - * release_source_buffer = False - * source_array = source # <<<<<<<<<<<<<< - * source_ptr = source_array.data.as_voidptr - * else: - */ - if (!(likely(((__pyx_v_source) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_source, __pyx_ptype_7cpython_5array_array))))) __PYX_ERR(0, 167, __pyx_L1_error) - __pyx_t_2 = __pyx_v_source; - __Pyx_INCREF(__pyx_t_2); - __pyx_v_source_array = ((arrayobject *)__pyx_t_2); - __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":168 - * release_source_buffer = False - * source_array = source - * source_ptr = source_array.data.as_voidptr # <<<<<<<<<<<<<< - * else: - * release_source_buffer = True - */ - __pyx_v_source_ptr = ((char *)__pyx_v_source_array->data.as_voidptr); - - /* "zarr/blosc.pyx":163 - * - * # setup source buffer - * if PY2 and isinstance(source, array.array): # <<<<<<<<<<<<<< - * # workaround fact that array.array does not support new-style buffer - * # interface in PY2 - */ - goto __pyx_L3; - } - - /* "zarr/blosc.pyx":170 - * source_ptr = source_array.data.as_voidptr - * else: - * release_source_buffer = True # <<<<<<<<<<<<<< - * PyObject_GetBuffer(source, &source_buffer, PyBUF_ANY_CONTIGUOUS) - * source_ptr = source_buffer.buf - */ - /*else*/ { - __pyx_v_release_source_buffer = 1; - - /* "zarr/blosc.pyx":171 - * else: - * release_source_buffer = True - * PyObject_GetBuffer(source, &source_buffer, PyBUF_ANY_CONTIGUOUS) # <<<<<<<<<<<<<< - * source_ptr = source_buffer.buf - * - */ - __pyx_t_5 = PyObject_GetBuffer(__pyx_v_source, (&__pyx_v_source_buffer), PyBUF_ANY_CONTIGUOUS); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 171, __pyx_L1_error) - - /* "zarr/blosc.pyx":172 - * release_source_buffer = True - * PyObject_GetBuffer(source, &source_buffer, PyBUF_ANY_CONTIGUOUS) - * source_ptr = source_buffer.buf # <<<<<<<<<<<<<< - * - * # determine buffer size - */ - __pyx_v_source_ptr = ((char *)__pyx_v_source_buffer.buf); - } - __pyx_L3:; - - /* "zarr/blosc.pyx":175 - * - * # determine buffer size - * blosc_cbuffer_sizes(source_ptr, &nbytes, &cbytes, &blocksize) # <<<<<<<<<<<<<< - * - * # setup destination buffer - */ - blosc_cbuffer_sizes(__pyx_v_source_ptr, (&__pyx_v_nbytes), (&__pyx_v_cbytes), (&__pyx_v_blocksize)); - - /* "zarr/blosc.pyx":178 - * - * # setup destination buffer - * release_dest_buffer = False # <<<<<<<<<<<<<< - * if dest is None: - * # allocate memory - */ - __pyx_v_release_dest_buffer = 0; - - /* "zarr/blosc.pyx":179 - * # setup destination buffer - * release_dest_buffer = False - * if dest is None: # <<<<<<<<<<<<<< - * # allocate memory - * dest = PyBytes_FromStringAndSize(NULL, nbytes) - */ - __pyx_t_1 = (__pyx_v_dest == Py_None); - __pyx_t_4 = (__pyx_t_1 != 0); - if (__pyx_t_4) { - - /* "zarr/blosc.pyx":181 - * if dest is None: - * # allocate memory - * dest = PyBytes_FromStringAndSize(NULL, nbytes) # <<<<<<<<<<<<<< - * dest_ptr = PyBytes_AS_STRING(dest) - * dest_nbytes = nbytes - */ - __pyx_t_2 = PyBytes_FromStringAndSize(NULL, __pyx_v_nbytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF_SET(__pyx_v_dest, __pyx_t_2); - __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":182 - * # allocate memory - * dest = PyBytes_FromStringAndSize(NULL, nbytes) - * dest_ptr = PyBytes_AS_STRING(dest) # <<<<<<<<<<<<<< - * dest_nbytes = nbytes - * elif PY2 and isinstance(dest, array.array): - */ - __pyx_v_dest_ptr = PyBytes_AS_STRING(__pyx_v_dest); - - /* "zarr/blosc.pyx":183 - * dest = PyBytes_FromStringAndSize(NULL, nbytes) - * dest_ptr = PyBytes_AS_STRING(dest) - * dest_nbytes = nbytes # <<<<<<<<<<<<<< - * elif PY2 and isinstance(dest, array.array): - * # workaround fact that array.array does not support new-style buffer - */ - __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_nbytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_dest_nbytes = __pyx_t_2; - __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":179 - * # setup destination buffer - * release_dest_buffer = False - * if dest is None: # <<<<<<<<<<<<<< - * # allocate memory - * dest = PyBytes_FromStringAndSize(NULL, nbytes) - */ - goto __pyx_L6; - } - - /* "zarr/blosc.pyx":184 - * dest_ptr = PyBytes_AS_STRING(dest) - * dest_nbytes = nbytes - * elif PY2 and isinstance(dest, array.array): # <<<<<<<<<<<<<< - * # workaround fact that array.array does not support new-style buffer - * # interface in PY2 - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PY2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__pyx_t_1) { - } else { - __pyx_t_4 = __pyx_t_1; - goto __pyx_L7_bool_binop_done; - } - __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_dest, __pyx_ptype_7cpython_5array_array); - __pyx_t_3 = (__pyx_t_1 != 0); - __pyx_t_4 = __pyx_t_3; - __pyx_L7_bool_binop_done:; - if (__pyx_t_4) { - - /* "zarr/blosc.pyx":187 - * # workaround fact that array.array does not support new-style buffer - * # interface in PY2 - * dest_array = dest # <<<<<<<<<<<<<< - * dest_ptr = dest_array.data.as_voidptr - * dest_nbytes = dest_array.buffer_info()[1] * dest_array.itemsize - */ - __Pyx_INCREF(__pyx_v_dest); - __pyx_v_dest_array = __pyx_v_dest; - - /* "zarr/blosc.pyx":188 - * # interface in PY2 - * dest_array = dest - * dest_ptr = dest_array.data.as_voidptr # <<<<<<<<<<<<<< - * dest_nbytes = dest_array.buffer_info()[1] * dest_array.itemsize - * else: - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_dest_array, __pyx_n_s_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_as_voidptr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 188, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_7 = __Pyx_PyObject_AsString(__pyx_t_6); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 188, __pyx_L1_error) - __pyx_v_dest_ptr = ((char *)__pyx_t_7); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "zarr/blosc.pyx":189 - * dest_array = dest - * dest_ptr = dest_array.data.as_voidptr - * dest_nbytes = dest_array.buffer_info()[1] * dest_array.itemsize # <<<<<<<<<<<<<< - * else: - * release_dest_buffer = True - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_dest_array, __pyx_n_s_buffer_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_8 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (__pyx_t_8) { - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } else { - __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 189, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_6, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dest_array, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = PyNumber_Multiply(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_v_dest_nbytes = __pyx_t_8; - __pyx_t_8 = 0; - - /* "zarr/blosc.pyx":184 - * dest_ptr = PyBytes_AS_STRING(dest) - * dest_nbytes = nbytes - * elif PY2 and isinstance(dest, array.array): # <<<<<<<<<<<<<< - * # workaround fact that array.array does not support new-style buffer - * # interface in PY2 - */ - goto __pyx_L6; - } - - /* "zarr/blosc.pyx":191 - * dest_nbytes = dest_array.buffer_info()[1] * dest_array.itemsize - * else: - * release_dest_buffer = True # <<<<<<<<<<<<<< - * PyObject_GetBuffer(dest, &dest_buffer, - * PyBUF_ANY_CONTIGUOUS | PyBUF_WRITEABLE) - */ - /*else*/ { - __pyx_v_release_dest_buffer = 1; - - /* "zarr/blosc.pyx":192 - * else: - * release_dest_buffer = True - * PyObject_GetBuffer(dest, &dest_buffer, # <<<<<<<<<<<<<< - * PyBUF_ANY_CONTIGUOUS | PyBUF_WRITEABLE) - * dest_ptr = dest_buffer.buf - */ - __pyx_t_5 = PyObject_GetBuffer(__pyx_v_dest, (&__pyx_v_dest_buffer), (PyBUF_ANY_CONTIGUOUS | PyBUF_WRITEABLE)); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 192, __pyx_L1_error) - - /* "zarr/blosc.pyx":194 - * PyObject_GetBuffer(dest, &dest_buffer, - * PyBUF_ANY_CONTIGUOUS | PyBUF_WRITEABLE) - * dest_ptr = dest_buffer.buf # <<<<<<<<<<<<<< - * dest_nbytes = dest_buffer.len - * - */ - __pyx_v_dest_ptr = ((char *)__pyx_v_dest_buffer.buf); - - /* "zarr/blosc.pyx":195 - * PyBUF_ANY_CONTIGUOUS | PyBUF_WRITEABLE) - * dest_ptr = dest_buffer.buf - * dest_nbytes = dest_buffer.len # <<<<<<<<<<<<<< - * - * try: - */ - __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_dest_buffer.len); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_v_dest_nbytes = __pyx_t_8; - __pyx_t_8 = 0; - } - __pyx_L6:; - - /* "zarr/blosc.pyx":197 - * dest_nbytes = dest_buffer.len - * - * try: # <<<<<<<<<<<<<< - * - * # guard condition - */ - /*try:*/ { - - /* "zarr/blosc.pyx":200 - * - * # guard condition - * if dest_nbytes != nbytes: # <<<<<<<<<<<<<< - * raise ValueError('destination buffer has wrong size; expected %s, ' - * 'got %s' % (nbytes, dest_nbytes)) - */ - __pyx_t_8 = __Pyx_PyInt_FromSize_t(__pyx_v_nbytes); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 200, __pyx_L10_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyObject_RichCompare(__pyx_v_dest_nbytes, __pyx_t_8, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 200, __pyx_L10_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 200, __pyx_L10_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (__pyx_t_4) { - - /* "zarr/blosc.pyx":202 - * if dest_nbytes != nbytes: - * raise ValueError('destination buffer has wrong size; expected %s, ' - * 'got %s' % (nbytes, dest_nbytes)) # <<<<<<<<<<<<<< - * - * # perform decompression - */ - __pyx_t_6 = __Pyx_PyInt_FromSize_t(__pyx_v_nbytes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 202, __pyx_L10_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 202, __pyx_L10_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); - __Pyx_INCREF(__pyx_v_dest_nbytes); - __Pyx_GIVEREF(__pyx_v_dest_nbytes); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_dest_nbytes); - __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_destination_buffer_has_wrong_siz, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 202, __pyx_L10_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - - /* "zarr/blosc.pyx":201 - * # guard condition - * if dest_nbytes != nbytes: - * raise ValueError('destination buffer has wrong size; expected %s, ' # <<<<<<<<<<<<<< - * 'got %s' % (nbytes, dest_nbytes)) - * - */ - __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 201, __pyx_L10_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 201, __pyx_L10_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_Raise(__pyx_t_6, 0, 0, 0); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(0, 201, __pyx_L10_error) - - /* "zarr/blosc.pyx":200 - * - * # guard condition - * if dest_nbytes != nbytes: # <<<<<<<<<<<<<< - * raise ValueError('destination buffer has wrong size; expected %s, ' - * 'got %s' % (nbytes, dest_nbytes)) - */ - } - - /* "zarr/blosc.pyx":205 - * - * # perform decompression - * if _get_use_threads(): # <<<<<<<<<<<<<< - * # allow blosc to use threads internally - * with nogil: - */ - __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_use_threads); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 205, __pyx_L10_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_8, function); - } - } - if (__pyx_t_2) { - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 205, __pyx_L10_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 205, __pyx_L10_error) - } - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 205, __pyx_L10_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (__pyx_t_4) { - - /* "zarr/blosc.pyx":207 - * if _get_use_threads(): - * # allow blosc to use threads internally - * with nogil: # <<<<<<<<<<<<<< - * ret = blosc_decompress(source_ptr, dest_ptr, nbytes) - * else: - */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - #endif - /*try:*/ { - - /* "zarr/blosc.pyx":208 - * # allow blosc to use threads internally - * with nogil: - * ret = blosc_decompress(source_ptr, dest_ptr, nbytes) # <<<<<<<<<<<<<< - * else: - * with nogil: - */ - __pyx_v_ret = blosc_decompress(__pyx_v_source_ptr, __pyx_v_dest_ptr, __pyx_v_nbytes); - } - - /* "zarr/blosc.pyx":207 - * if _get_use_threads(): - * # allow blosc to use threads internally - * with nogil: # <<<<<<<<<<<<<< - * ret = blosc_decompress(source_ptr, dest_ptr, nbytes) - * else: - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L16; - } - __pyx_L16:; - } - } - - /* "zarr/blosc.pyx":205 - * - * # perform decompression - * if _get_use_threads(): # <<<<<<<<<<<<<< - * # allow blosc to use threads internally - * with nogil: - */ - goto __pyx_L13; - } - - /* "zarr/blosc.pyx":210 - * ret = blosc_decompress(source_ptr, dest_ptr, nbytes) - * else: - * with nogil: # <<<<<<<<<<<<<< - * ret = blosc_decompress_ctx(source_ptr, dest_ptr, nbytes, 1) - * - */ - /*else*/ { - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - #endif - /*try:*/ { - - /* "zarr/blosc.pyx":211 - * else: - * with nogil: - * ret = blosc_decompress_ctx(source_ptr, dest_ptr, nbytes, 1) # <<<<<<<<<<<<<< - * - * finally: - */ - __pyx_v_ret = blosc_decompress_ctx(__pyx_v_source_ptr, __pyx_v_dest_ptr, __pyx_v_nbytes, 1); - } - - /* "zarr/blosc.pyx":210 - * ret = blosc_decompress(source_ptr, dest_ptr, nbytes) - * else: - * with nogil: # <<<<<<<<<<<<<< - * ret = blosc_decompress_ctx(source_ptr, dest_ptr, nbytes, 1) - * - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L19; - } - __pyx_L19:; - } - } - } - __pyx_L13:; - } - - /* "zarr/blosc.pyx":216 - * - * # release buffers - * if release_source_buffer: # <<<<<<<<<<<<<< - * PyBuffer_Release(&source_buffer) - * if release_dest_buffer: - */ - /*finally:*/ { - /*normal exit:*/{ - __pyx_t_4 = (__pyx_v_release_source_buffer != 0); - if (__pyx_t_4) { - - /* "zarr/blosc.pyx":217 - * # release buffers - * if release_source_buffer: - * PyBuffer_Release(&source_buffer) # <<<<<<<<<<<<<< - * if release_dest_buffer: - * PyBuffer_Release(&dest_buffer) - */ - PyBuffer_Release((&__pyx_v_source_buffer)); - - /* "zarr/blosc.pyx":216 - * - * # release buffers - * if release_source_buffer: # <<<<<<<<<<<<<< - * PyBuffer_Release(&source_buffer) - * if release_dest_buffer: - */ - } - - /* "zarr/blosc.pyx":218 - * if release_source_buffer: - * PyBuffer_Release(&source_buffer) - * if release_dest_buffer: # <<<<<<<<<<<<<< - * PyBuffer_Release(&dest_buffer) - * - */ - __pyx_t_4 = (__pyx_v_release_dest_buffer != 0); - if (__pyx_t_4) { - - /* "zarr/blosc.pyx":219 - * PyBuffer_Release(&source_buffer) - * if release_dest_buffer: - * PyBuffer_Release(&dest_buffer) # <<<<<<<<<<<<<< - * - * # handle errors - */ - PyBuffer_Release((&__pyx_v_dest_buffer)); - - /* "zarr/blosc.pyx":218 - * if release_source_buffer: - * PyBuffer_Release(&source_buffer) - * if release_dest_buffer: # <<<<<<<<<<<<<< - * PyBuffer_Release(&dest_buffer) - * - */ - } - goto __pyx_L11; - } - /*exception exit:*/{ - __Pyx_PyThreadState_declare - __pyx_L10_error:; - __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; - __Pyx_PyThreadState_assign - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); - if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); - __Pyx_XGOTREF(__pyx_t_11); - __Pyx_XGOTREF(__pyx_t_12); - __Pyx_XGOTREF(__pyx_t_13); - __Pyx_XGOTREF(__pyx_t_14); - __Pyx_XGOTREF(__pyx_t_15); - __Pyx_XGOTREF(__pyx_t_16); - __pyx_t_5 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename; - { - - /* "zarr/blosc.pyx":216 - * - * # release buffers - * if release_source_buffer: # <<<<<<<<<<<<<< - * PyBuffer_Release(&source_buffer) - * if release_dest_buffer: - */ - __pyx_t_4 = (__pyx_v_release_source_buffer != 0); - if (__pyx_t_4) { - - /* "zarr/blosc.pyx":217 - * # release buffers - * if release_source_buffer: - * PyBuffer_Release(&source_buffer) # <<<<<<<<<<<<<< - * if release_dest_buffer: - * PyBuffer_Release(&dest_buffer) - */ - PyBuffer_Release((&__pyx_v_source_buffer)); - - /* "zarr/blosc.pyx":216 - * - * # release buffers - * if release_source_buffer: # <<<<<<<<<<<<<< - * PyBuffer_Release(&source_buffer) - * if release_dest_buffer: - */ - } - - /* "zarr/blosc.pyx":218 - * if release_source_buffer: - * PyBuffer_Release(&source_buffer) - * if release_dest_buffer: # <<<<<<<<<<<<<< - * PyBuffer_Release(&dest_buffer) - * - */ - __pyx_t_4 = (__pyx_v_release_dest_buffer != 0); - if (__pyx_t_4) { - - /* "zarr/blosc.pyx":219 - * PyBuffer_Release(&source_buffer) - * if release_dest_buffer: - * PyBuffer_Release(&dest_buffer) # <<<<<<<<<<<<<< - * - * # handle errors - */ - PyBuffer_Release((&__pyx_v_dest_buffer)); - - /* "zarr/blosc.pyx":218 - * if release_source_buffer: - * PyBuffer_Release(&source_buffer) - * if release_dest_buffer: # <<<<<<<<<<<<<< - * PyBuffer_Release(&dest_buffer) - * - */ - } - } - __Pyx_PyThreadState_assign - if (PY_MAJOR_VERSION >= 3) { - __Pyx_XGIVEREF(__pyx_t_14); - __Pyx_XGIVEREF(__pyx_t_15); - __Pyx_XGIVEREF(__pyx_t_16); - __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); - } - __Pyx_XGIVEREF(__pyx_t_11); - __Pyx_XGIVEREF(__pyx_t_12); - __Pyx_XGIVEREF(__pyx_t_13); - __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13); - __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; - __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10; - goto __pyx_L1_error; - } - __pyx_L11:; - } - - /* "zarr/blosc.pyx":222 - * - * # handle errors - * if ret <= 0: # <<<<<<<<<<<<<< - * raise RuntimeError('error during blosc decompression: %d' % ret) - * - */ - __pyx_t_4 = ((__pyx_v_ret <= 0) != 0); - if (__pyx_t_4) { - - /* "zarr/blosc.pyx":223 - * # handle errors - * if ret <= 0: - * raise RuntimeError('error during blosc decompression: %d' % ret) # <<<<<<<<<<<<<< - * - * return dest - */ - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_ret); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_error_during_blosc_decompression, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(0, 223, __pyx_L1_error) - - /* "zarr/blosc.pyx":222 - * - * # handle errors - * if ret <= 0: # <<<<<<<<<<<<<< - * raise RuntimeError('error during blosc decompression: %d' % ret) - * - */ - } - - /* "zarr/blosc.pyx":225 - * raise RuntimeError('error during blosc decompression: %d' % ret) - * - * return dest # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_dest); - __pyx_r = __pyx_v_dest; - goto __pyx_L0; - - /* "zarr/blosc.pyx":136 - * - * - * def decompress(source, dest=None): # <<<<<<<<<<<<<< - * """Decompress data. - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("zarr.blosc.decompress", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_source_array); - __Pyx_XDECREF(__pyx_v_dest_nbytes); - __Pyx_XDECREF(__pyx_v_dest_array); - __Pyx_XDECREF(__pyx_v_dest); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "zarr/blosc.pyx":228 - * - * - * def compress(source, char* cname, int clevel, int shuffle): # <<<<<<<<<<<<<< - * """Compression. - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_4zarr_5blosc_19compress(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_4zarr_5blosc_18compress[] = "compress(source, char *cname, int clevel, int shuffle)\nCompression.\n\n Parameters\n ----------\n source : bytes-like\n Data to be compressed. Can be any object supporting the buffer\n protocol.\n cname : bytes\n Name of compression library to use.\n clevel : int\n Compression level.\n shuffle : int\n Shuffle filter.\n\n Returns\n -------\n dest : array\n Compressed data.\n\n "; -static PyMethodDef __pyx_mdef_4zarr_5blosc_19compress = {"compress", (PyCFunction)__pyx_pw_4zarr_5blosc_19compress, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4zarr_5blosc_18compress}; -static PyObject *__pyx_pw_4zarr_5blosc_19compress(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_source = 0; - char *__pyx_v_cname; - int __pyx_v_clevel; - int __pyx_v_shuffle; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("compress (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,&__pyx_n_s_cname,&__pyx_n_s_clevel,&__pyx_n_s_shuffle,0}; - PyObject* values[4] = {0,0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_source)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cname)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("compress", 1, 4, 4, 1); __PYX_ERR(0, 228, __pyx_L3_error) - } - case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_clevel)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("compress", 1, 4, 4, 2); __PYX_ERR(0, 228, __pyx_L3_error) - } - case 3: - if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shuffle)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("compress", 1, 4, 4, 3); __PYX_ERR(0, 228, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compress") < 0)) __PYX_ERR(0, 228, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - } - __pyx_v_source = values[0]; - __pyx_v_cname = __Pyx_PyObject_AsString(values[1]); if (unlikely((!__pyx_v_cname) && PyErr_Occurred())) __PYX_ERR(0, 228, __pyx_L3_error) - __pyx_v_clevel = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_clevel == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 228, __pyx_L3_error) - __pyx_v_shuffle = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_shuffle == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 228, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("compress", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 228, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("zarr.blosc.compress", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_4zarr_5blosc_18compress(__pyx_self, __pyx_v_source, __pyx_v_cname, __pyx_v_clevel, __pyx_v_shuffle); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_4zarr_5blosc_18compress(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_source, char *__pyx_v_cname, int __pyx_v_clevel, int __pyx_v_shuffle) { - char *__pyx_v_source_ptr; - char *__pyx_v_dest_ptr; - Py_buffer __pyx_v_source_buffer; - size_t __pyx_v_nbytes; - size_t __pyx_v_cbytes; - size_t __pyx_v_itemsize; - arrayobject *__pyx_v_source_array = 0; - PyObject *__pyx_v_dest = 0; - int __pyx_v_release_source_buffer; - int __pyx_v_compressor_set; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - int __pyx_t_4; - size_t __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - int __pyx_t_8; - Py_ssize_t __pyx_t_9; - int __pyx_t_10; - char const *__pyx_t_11; - PyObject *__pyx_t_12 = NULL; - PyObject *__pyx_t_13 = NULL; - PyObject *__pyx_t_14 = NULL; - PyObject *__pyx_t_15 = NULL; - PyObject *__pyx_t_16 = NULL; - PyObject *__pyx_t_17 = NULL; - __Pyx_RefNannySetupContext("compress", 0); - - /* "zarr/blosc.pyx":259 - * - * # setup source buffer - * if PY2 and isinstance(source, array.array): # <<<<<<<<<<<<<< - * # workaround fact that array.array does not support new-style buffer - * # interface in PY2 - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PY2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 259, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__pyx_t_3) { - } else { - __pyx_t_1 = __pyx_t_3; - goto __pyx_L4_bool_binop_done; - } - __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_source, __pyx_ptype_7cpython_5array_array); - __pyx_t_4 = (__pyx_t_3 != 0); - __pyx_t_1 = __pyx_t_4; - __pyx_L4_bool_binop_done:; - if (__pyx_t_1) { - - /* "zarr/blosc.pyx":262 - * # workaround fact that array.array does not support new-style buffer - * # interface in PY2 - * release_source_buffer = False # <<<<<<<<<<<<<< - * source_array = source - * source_ptr = source_array.data.as_voidptr - */ - __pyx_v_release_source_buffer = 0; - - /* "zarr/blosc.pyx":263 - * # interface in PY2 - * release_source_buffer = False - * source_array = source # <<<<<<<<<<<<<< - * source_ptr = source_array.data.as_voidptr - * itemsize = source_array.itemsize - */ - if (!(likely(((__pyx_v_source) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_source, __pyx_ptype_7cpython_5array_array))))) __PYX_ERR(0, 263, __pyx_L1_error) - __pyx_t_2 = __pyx_v_source; - __Pyx_INCREF(__pyx_t_2); - __pyx_v_source_array = ((arrayobject *)__pyx_t_2); - __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":264 - * release_source_buffer = False - * source_array = source - * source_ptr = source_array.data.as_voidptr # <<<<<<<<<<<<<< - * itemsize = source_array.itemsize - * nbytes = source_array.buffer_info()[1] * itemsize - */ - __pyx_v_source_ptr = ((char *)__pyx_v_source_array->data.as_voidptr); - - /* "zarr/blosc.pyx":265 - * source_array = source - * source_ptr = source_array.data.as_voidptr - * itemsize = source_array.itemsize # <<<<<<<<<<<<<< - * nbytes = source_array.buffer_info()[1] * itemsize - * else: - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_source_array), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_5 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 265, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_itemsize = __pyx_t_5; - - /* "zarr/blosc.pyx":266 - * source_ptr = source_array.data.as_voidptr - * itemsize = source_array.itemsize - * nbytes = source_array.buffer_info()[1] * itemsize # <<<<<<<<<<<<<< - * else: - * release_source_buffer = True - */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_source_array), __pyx_n_s_buffer_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 266, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_7)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); - } - } - if (__pyx_t_7) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 266, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 266, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 266, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 266, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7 = PyNumber_Multiply(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 266, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_5 = __Pyx_PyInt_As_size_t(__pyx_t_7); if (unlikely((__pyx_t_5 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 266, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_v_nbytes = __pyx_t_5; - - /* "zarr/blosc.pyx":259 - * - * # setup source buffer - * if PY2 and isinstance(source, array.array): # <<<<<<<<<<<<<< - * # workaround fact that array.array does not support new-style buffer - * # interface in PY2 - */ - goto __pyx_L3; - } - - /* "zarr/blosc.pyx":268 - * nbytes = source_array.buffer_info()[1] * itemsize - * else: - * release_source_buffer = True # <<<<<<<<<<<<<< - * PyObject_GetBuffer(source, &source_buffer, PyBUF_ANY_CONTIGUOUS) - * source_ptr = source_buffer.buf - */ - /*else*/ { - __pyx_v_release_source_buffer = 1; - - /* "zarr/blosc.pyx":269 - * else: - * release_source_buffer = True - * PyObject_GetBuffer(source, &source_buffer, PyBUF_ANY_CONTIGUOUS) # <<<<<<<<<<<<<< - * source_ptr = source_buffer.buf - * itemsize = source_buffer.itemsize - */ - __pyx_t_8 = PyObject_GetBuffer(__pyx_v_source, (&__pyx_v_source_buffer), PyBUF_ANY_CONTIGUOUS); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 269, __pyx_L1_error) - - /* "zarr/blosc.pyx":270 - * release_source_buffer = True - * PyObject_GetBuffer(source, &source_buffer, PyBUF_ANY_CONTIGUOUS) - * source_ptr = source_buffer.buf # <<<<<<<<<<<<<< - * itemsize = source_buffer.itemsize - * nbytes = source_buffer.len - */ - __pyx_v_source_ptr = ((char *)__pyx_v_source_buffer.buf); - - /* "zarr/blosc.pyx":271 - * PyObject_GetBuffer(source, &source_buffer, PyBUF_ANY_CONTIGUOUS) - * source_ptr = source_buffer.buf - * itemsize = source_buffer.itemsize # <<<<<<<<<<<<<< - * nbytes = source_buffer.len - * - */ - __pyx_t_9 = __pyx_v_source_buffer.itemsize; - __pyx_v_itemsize = __pyx_t_9; - - /* "zarr/blosc.pyx":272 - * source_ptr = source_buffer.buf - * itemsize = source_buffer.itemsize - * nbytes = source_buffer.len # <<<<<<<<<<<<<< - * - * try: - */ - __pyx_t_9 = __pyx_v_source_buffer.len; - __pyx_v_nbytes = __pyx_t_9; - } - __pyx_L3:; - - /* "zarr/blosc.pyx":274 - * nbytes = source_buffer.len - * - * try: # <<<<<<<<<<<<<< - * - * # setup destination - */ - /*try:*/ { - - /* "zarr/blosc.pyx":277 - * - * # setup destination - * dest = PyBytes_FromStringAndSize(NULL, nbytes + BLOSC_MAX_OVERHEAD) # <<<<<<<<<<<<<< - * dest_ptr = PyBytes_AS_STRING(dest) - * - */ - __pyx_t_7 = PyBytes_FromStringAndSize(NULL, (__pyx_v_nbytes + BLOSC_MAX_OVERHEAD)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 277, __pyx_L7_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_v_dest = ((PyObject*)__pyx_t_7); - __pyx_t_7 = 0; - - /* "zarr/blosc.pyx":278 - * # setup destination - * dest = PyBytes_FromStringAndSize(NULL, nbytes + BLOSC_MAX_OVERHEAD) - * dest_ptr = PyBytes_AS_STRING(dest) # <<<<<<<<<<<<<< - * - * # perform compression - */ - __pyx_v_dest_ptr = PyBytes_AS_STRING(__pyx_v_dest); - - /* "zarr/blosc.pyx":281 - * - * # perform compression - * if _get_use_threads(): # <<<<<<<<<<<<<< - * # allow blosc to use threads internally - * compressor_set = blosc_set_compressor(cname) - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_use_threads); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L7_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = NULL; - 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); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (__pyx_t_6) { - __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 281, __pyx_L7_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else { - __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 281, __pyx_L7_error) - } - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 281, __pyx_L7_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (__pyx_t_1) { - - /* "zarr/blosc.pyx":283 - * if _get_use_threads(): - * # allow blosc to use threads internally - * compressor_set = blosc_set_compressor(cname) # <<<<<<<<<<<<<< - * if compressor_set < 0: - * raise ValueError('compressor not supported: %r' % cname) - */ - __pyx_v_compressor_set = blosc_set_compressor(__pyx_v_cname); - - /* "zarr/blosc.pyx":284 - * # allow blosc to use threads internally - * compressor_set = blosc_set_compressor(cname) - * if compressor_set < 0: # <<<<<<<<<<<<<< - * raise ValueError('compressor not supported: %r' % cname) - * with nogil: - */ - __pyx_t_1 = ((__pyx_v_compressor_set < 0) != 0); - if (__pyx_t_1) { - - /* "zarr/blosc.pyx":285 - * compressor_set = blosc_set_compressor(cname) - * if compressor_set < 0: - * raise ValueError('compressor not supported: %r' % cname) # <<<<<<<<<<<<<< - * with nogil: - * cbytes = blosc_compress(clevel, shuffle, itemsize, nbytes, - */ - __pyx_t_7 = __Pyx_PyBytes_FromString(__pyx_v_cname); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 285, __pyx_L7_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_compressor_not_supported_r, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L7_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 285, __pyx_L7_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L7_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 285, __pyx_L7_error) - - /* "zarr/blosc.pyx":284 - * # allow blosc to use threads internally - * compressor_set = blosc_set_compressor(cname) - * if compressor_set < 0: # <<<<<<<<<<<<<< - * raise ValueError('compressor not supported: %r' % cname) - * with nogil: - */ - } - - /* "zarr/blosc.pyx":286 - * if compressor_set < 0: - * raise ValueError('compressor not supported: %r' % cname) - * with nogil: # <<<<<<<<<<<<<< - * cbytes = blosc_compress(clevel, shuffle, itemsize, nbytes, - * source_ptr, dest_ptr, - */ - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - #endif - /*try:*/ { - - /* "zarr/blosc.pyx":287 - * raise ValueError('compressor not supported: %r' % cname) - * with nogil: - * cbytes = blosc_compress(clevel, shuffle, itemsize, nbytes, # <<<<<<<<<<<<<< - * source_ptr, dest_ptr, - * nbytes + BLOSC_MAX_OVERHEAD) - */ - __pyx_v_cbytes = blosc_compress(__pyx_v_clevel, __pyx_v_shuffle, __pyx_v_itemsize, __pyx_v_nbytes, __pyx_v_source_ptr, __pyx_v_dest_ptr, (__pyx_v_nbytes + BLOSC_MAX_OVERHEAD)); - } - - /* "zarr/blosc.pyx":286 - * if compressor_set < 0: - * raise ValueError('compressor not supported: %r' % cname) - * with nogil: # <<<<<<<<<<<<<< - * cbytes = blosc_compress(clevel, shuffle, itemsize, nbytes, - * source_ptr, dest_ptr, - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L13; - } - __pyx_L13:; - } - } - - /* "zarr/blosc.pyx":281 - * - * # perform compression - * if _get_use_threads(): # <<<<<<<<<<<<<< - * # allow blosc to use threads internally - * compressor_set = blosc_set_compressor(cname) - */ - goto __pyx_L9; - } - - /* "zarr/blosc.pyx":292 - * - * else: - * with nogil: # <<<<<<<<<<<<<< - * cbytes = blosc_compress_ctx(clevel, shuffle, itemsize, nbytes, - * source_ptr, dest_ptr, - */ - /*else*/ { - { - #ifdef WITH_THREAD - PyThreadState *_save; - Py_UNBLOCK_THREADS - #endif - /*try:*/ { - - /* "zarr/blosc.pyx":293 - * else: - * with nogil: - * cbytes = blosc_compress_ctx(clevel, shuffle, itemsize, nbytes, # <<<<<<<<<<<<<< - * source_ptr, dest_ptr, - * nbytes + BLOSC_MAX_OVERHEAD, cname, - */ - __pyx_v_cbytes = blosc_compress_ctx(__pyx_v_clevel, __pyx_v_shuffle, __pyx_v_itemsize, __pyx_v_nbytes, __pyx_v_source_ptr, __pyx_v_dest_ptr, (__pyx_v_nbytes + BLOSC_MAX_OVERHEAD), __pyx_v_cname, 0, 1); - } - - /* "zarr/blosc.pyx":292 - * - * else: - * with nogil: # <<<<<<<<<<<<<< - * cbytes = blosc_compress_ctx(clevel, shuffle, itemsize, nbytes, - * source_ptr, dest_ptr, - */ - /*finally:*/ { - /*normal exit:*/{ - #ifdef WITH_THREAD - Py_BLOCK_THREADS - #endif - goto __pyx_L16; - } - __pyx_L16:; - } - } - } - __pyx_L9:; - } - - /* "zarr/blosc.pyx":301 - * - * # release buffers - * if release_source_buffer: # <<<<<<<<<<<<<< - * PyBuffer_Release(&source_buffer) - * - */ - /*finally:*/ { - /*normal exit:*/{ - __pyx_t_1 = (__pyx_v_release_source_buffer != 0); - if (__pyx_t_1) { - - /* "zarr/blosc.pyx":302 - * # release buffers - * if release_source_buffer: - * PyBuffer_Release(&source_buffer) # <<<<<<<<<<<<<< - * - * # check compression was successful - */ - PyBuffer_Release((&__pyx_v_source_buffer)); - - /* "zarr/blosc.pyx":301 - * - * # release buffers - * if release_source_buffer: # <<<<<<<<<<<<<< - * PyBuffer_Release(&source_buffer) - * - */ - } - goto __pyx_L8; - } - /*exception exit:*/{ - __Pyx_PyThreadState_declare - __pyx_L7_error:; - __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; - __Pyx_PyThreadState_assign - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); - if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); - __Pyx_XGOTREF(__pyx_t_12); - __Pyx_XGOTREF(__pyx_t_13); - __Pyx_XGOTREF(__pyx_t_14); - __Pyx_XGOTREF(__pyx_t_15); - __Pyx_XGOTREF(__pyx_t_16); - __Pyx_XGOTREF(__pyx_t_17); - __pyx_t_8 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename; - { - __pyx_t_1 = (__pyx_v_release_source_buffer != 0); - if (__pyx_t_1) { - - /* "zarr/blosc.pyx":302 - * # release buffers - * if release_source_buffer: - * PyBuffer_Release(&source_buffer) # <<<<<<<<<<<<<< - * - * # check compression was successful - */ - PyBuffer_Release((&__pyx_v_source_buffer)); - - /* "zarr/blosc.pyx":301 - * - * # release buffers - * if release_source_buffer: # <<<<<<<<<<<<<< - * PyBuffer_Release(&source_buffer) - * - */ - } - } - __Pyx_PyThreadState_assign - if (PY_MAJOR_VERSION >= 3) { - __Pyx_XGIVEREF(__pyx_t_15); - __Pyx_XGIVEREF(__pyx_t_16); - __Pyx_XGIVEREF(__pyx_t_17); - __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); - } - __Pyx_XGIVEREF(__pyx_t_12); - __Pyx_XGIVEREF(__pyx_t_13); - __Pyx_XGIVEREF(__pyx_t_14); - __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14); - __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; - __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11; - goto __pyx_L1_error; - } - __pyx_L8:; - } - - /* "zarr/blosc.pyx":305 - * - * # check compression was successful - * if cbytes <= 0: # <<<<<<<<<<<<<< - * raise RuntimeError('error during blosc compression: %d' % cbytes) - * - */ - __pyx_t_1 = ((__pyx_v_cbytes <= 0) != 0); - if (__pyx_t_1) { - - /* "zarr/blosc.pyx":306 - * # check compression was successful - * if cbytes <= 0: - * raise RuntimeError('error during blosc compression: %d' % cbytes) # <<<<<<<<<<<<<< - * - * # resize after compression - */ - __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_cbytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_error_during_blosc_compression_d, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7); - __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_Raise(__pyx_t_7, 0, 0, 0); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __PYX_ERR(0, 306, __pyx_L1_error) - - /* "zarr/blosc.pyx":305 - * - * # check compression was successful - * if cbytes <= 0: # <<<<<<<<<<<<<< - * raise RuntimeError('error during blosc compression: %d' % cbytes) - * - */ - } - - /* "zarr/blosc.pyx":309 - * - * # resize after compression - * dest = dest[:cbytes] # <<<<<<<<<<<<<< - * - * return dest - */ - if (unlikely(__pyx_v_dest == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 309, __pyx_L1_error) - } - __pyx_t_7 = PySequence_GetSlice(__pyx_v_dest, 0, __pyx_v_cbytes); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 309, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF_SET(__pyx_v_dest, ((PyObject*)__pyx_t_7)); - __pyx_t_7 = 0; - - /* "zarr/blosc.pyx":311 - * dest = dest[:cbytes] - * - * return dest # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_dest); - __pyx_r = __pyx_v_dest; - goto __pyx_L0; - - /* "zarr/blosc.pyx":228 - * - * - * def compress(source, char* cname, int clevel, int shuffle): # <<<<<<<<<<<<<< - * """Compression. - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_AddTraceback("zarr.blosc.compress", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_source_array); - __Pyx_XDECREF(__pyx_v_dest); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "zarr/blosc.pyx":319 - * - * - * def _get_use_threads(): # <<<<<<<<<<<<<< - * global use_threads - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_4zarr_5blosc_21_get_use_threads(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_4zarr_5blosc_20_get_use_threads[] = "_get_use_threads()"; -static PyMethodDef __pyx_mdef_4zarr_5blosc_21_get_use_threads = {"_get_use_threads", (PyCFunction)__pyx_pw_4zarr_5blosc_21_get_use_threads, METH_NOARGS, __pyx_doc_4zarr_5blosc_20_get_use_threads}; -static PyObject *__pyx_pw_4zarr_5blosc_21_get_use_threads(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_get_use_threads (wrapper)", 0); - __pyx_r = __pyx_pf_4zarr_5blosc_20_get_use_threads(__pyx_self); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_4zarr_5blosc_20_get_use_threads(CYTHON_UNUSED PyObject *__pyx_self) { - PyObject *__pyx_v__use_threads = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - __Pyx_RefNannySetupContext("_get_use_threads", 0); - - /* "zarr/blosc.pyx":322 - * global use_threads - * - * if use_threads in [True, False]: # <<<<<<<<<<<<<< - * # user has manually overridden the default behaviour - * _use_threads = use_threads - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_use_threads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 322, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 322, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 322, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (!__pyx_t_4) { - } else { - __pyx_t_2 = __pyx_t_4; - goto __pyx_L4_bool_binop_done; - } - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 322, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 322, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_2 = __pyx_t_4; - __pyx_L4_bool_binop_done:; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_4 = (__pyx_t_2 != 0); - if (__pyx_t_4) { - - /* "zarr/blosc.pyx":324 - * if use_threads in [True, False]: - * # user has manually overridden the default behaviour - * _use_threads = use_threads # <<<<<<<<<<<<<< - * - * else: - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_use_threads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v__use_threads = __pyx_t_1; - __pyx_t_1 = 0; - - /* "zarr/blosc.pyx":322 - * global use_threads - * - * if use_threads in [True, False]: # <<<<<<<<<<<<<< - * # user has manually overridden the default behaviour - * _use_threads = use_threads - */ - goto __pyx_L3; - } - - /* "zarr/blosc.pyx":332 - * # blosc to use threads, inferring it is being run from within a - * # multi-threaded program - * if hasattr(threading, 'main_thread'): # <<<<<<<<<<<<<< - * _use_threads = (threading.main_thread() == - * threading.current_thread()) - */ - /*else*/ { - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyObject_HasAttr(__pyx_t_1, __pyx_n_s_main_thread); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 332, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_2 = (__pyx_t_4 != 0); - if (__pyx_t_2) { - - /* "zarr/blosc.pyx":333 - * # multi-threaded program - * if hasattr(threading, 'main_thread'): - * _use_threads = (threading.main_thread() == # <<<<<<<<<<<<<< - * threading.current_thread()) - * else: - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_main_thread); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - - /* "zarr/blosc.pyx":334 - * if hasattr(threading, 'main_thread'): - * _use_threads = (threading.main_thread() == - * threading.current_thread()) # <<<<<<<<<<<<<< - * else: - * _use_threads = threading.current_thread().name == 'MainThread' - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 334, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_current_thread); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 334, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __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); - } - } - if (__pyx_t_3) { - __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 334, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else { - __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 334, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v__use_threads = __pyx_t_6; - __pyx_t_6 = 0; - - /* "zarr/blosc.pyx":332 - * # blosc to use threads, inferring it is being run from within a - * # multi-threaded program - * if hasattr(threading, 'main_thread'): # <<<<<<<<<<<<<< - * _use_threads = (threading.main_thread() == - * threading.current_thread()) - */ - goto __pyx_L6; - } - - /* "zarr/blosc.pyx":336 - * threading.current_thread()) - * else: - * _use_threads = threading.current_thread().name == 'MainThread' # <<<<<<<<<<<<<< - * - * return _use_threads - */ - /*else*/ { - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 336, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_current_thread); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - if (__pyx_t_5) { - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else { - __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_n_s_MainThread, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v__use_threads = __pyx_t_6; - __pyx_t_6 = 0; - } - __pyx_L6:; - } - __pyx_L3:; - - /* "zarr/blosc.pyx":338 - * _use_threads = threading.current_thread().name == 'MainThread' - * - * return _use_threads # <<<<<<<<<<<<<< - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v__use_threads); - __pyx_r = __pyx_v__use_threads; - goto __pyx_L0; - - /* "zarr/blosc.pyx":319 - * - * - * def _get_use_threads(): # <<<<<<<<<<<<<< - * global use_threads - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("zarr.blosc._get_use_threads", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v__use_threads); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "array.pxd":91 - * __data_union data - * - * def __getbuffer__(self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< - * # This implementation of getbuffer is geared towards Cython - * # requirements, and does not yet fullfill the PEP. - */ - -/* Python wrapper */ -static CYTHON_UNUSED int __pyx_pw_7cpython_5array_5array_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ -static CYTHON_UNUSED int __pyx_pw_7cpython_5array_5array_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); - __pyx_r = __pyx_pf_7cpython_5array_5array___getbuffer__(((arrayobject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_7cpython_5array_5array___getbuffer__(arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info, CYTHON_UNUSED int __pyx_v_flags) { - PyObject *__pyx_v_item_count = NULL; - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - char *__pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - Py_ssize_t __pyx_t_5; - int __pyx_t_6; - __Pyx_RefNannySetupContext("__getbuffer__", 0); - if (__pyx_v_info != NULL) { - __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(__pyx_v_info->obj); - } - - /* "array.pxd":96 - * # In particular strided access is always provided regardless - * # of flags - * item_count = Py_SIZE(self) # <<<<<<<<<<<<<< - * - * info.suboffsets = NULL - */ - __pyx_t_1 = PyInt_FromSsize_t(Py_SIZE(((PyObject *)__pyx_v_self))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 96, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_item_count = __pyx_t_1; - __pyx_t_1 = 0; - - /* "array.pxd":98 - * item_count = Py_SIZE(self) - * - * info.suboffsets = NULL # <<<<<<<<<<<<<< - * info.buf = self.data.as_chars - * info.readonly = 0 - */ - __pyx_v_info->suboffsets = NULL; - - /* "array.pxd":99 - * - * info.suboffsets = NULL - * info.buf = self.data.as_chars # <<<<<<<<<<<<<< - * info.readonly = 0 - * info.ndim = 1 - */ - __pyx_t_2 = __pyx_v_self->data.as_chars; - __pyx_v_info->buf = __pyx_t_2; - - /* "array.pxd":100 - * info.suboffsets = NULL - * info.buf = self.data.as_chars - * info.readonly = 0 # <<<<<<<<<<<<<< - * info.ndim = 1 - * info.itemsize = self.ob_descr.itemsize # e.g. sizeof(float) - */ - __pyx_v_info->readonly = 0; - - /* "array.pxd":101 - * info.buf = self.data.as_chars - * info.readonly = 0 - * info.ndim = 1 # <<<<<<<<<<<<<< - * info.itemsize = self.ob_descr.itemsize # e.g. sizeof(float) - * info.len = info.itemsize * item_count - */ - __pyx_v_info->ndim = 1; - - /* "array.pxd":102 - * info.readonly = 0 - * info.ndim = 1 - * info.itemsize = self.ob_descr.itemsize # e.g. sizeof(float) # <<<<<<<<<<<<<< - * info.len = info.itemsize * item_count - * - */ - __pyx_t_3 = __pyx_v_self->ob_descr->itemsize; - __pyx_v_info->itemsize = __pyx_t_3; - - /* "array.pxd":103 - * info.ndim = 1 - * info.itemsize = self.ob_descr.itemsize # e.g. sizeof(float) - * info.len = info.itemsize * item_count # <<<<<<<<<<<<<< - * - * info.shape = PyObject_Malloc(sizeof(Py_ssize_t) + 2) - */ - __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_info->itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 103, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyNumber_Multiply(__pyx_t_1, __pyx_v_item_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 103, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 103, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_info->len = __pyx_t_5; - - /* "array.pxd":105 - * info.len = info.itemsize * item_count - * - * info.shape = PyObject_Malloc(sizeof(Py_ssize_t) + 2) # <<<<<<<<<<<<<< - * if not info.shape: - * raise MemoryError() - */ - __pyx_v_info->shape = ((Py_ssize_t *)PyObject_Malloc(((sizeof(Py_ssize_t)) + 2))); - - /* "array.pxd":106 - * - * info.shape = PyObject_Malloc(sizeof(Py_ssize_t) + 2) - * if not info.shape: # <<<<<<<<<<<<<< - * raise MemoryError() - * info.shape[0] = item_count # constant regardless of resizing - */ - __pyx_t_6 = ((!(__pyx_v_info->shape != 0)) != 0); - if (__pyx_t_6) { - - /* "array.pxd":107 - * info.shape = PyObject_Malloc(sizeof(Py_ssize_t) + 2) - * if not info.shape: - * raise MemoryError() # <<<<<<<<<<<<<< - * info.shape[0] = item_count # constant regardless of resizing - * info.strides = &info.itemsize - */ - PyErr_NoMemory(); __PYX_ERR(1, 107, __pyx_L1_error) - - /* "array.pxd":106 - * - * info.shape = PyObject_Malloc(sizeof(Py_ssize_t) + 2) - * if not info.shape: # <<<<<<<<<<<<<< - * raise MemoryError() - * info.shape[0] = item_count # constant regardless of resizing - */ - } - - /* "array.pxd":108 - * if not info.shape: - * raise MemoryError() - * info.shape[0] = item_count # constant regardless of resizing # <<<<<<<<<<<<<< - * info.strides = &info.itemsize - * - */ - __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_item_count); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 108, __pyx_L1_error) - (__pyx_v_info->shape[0]) = __pyx_t_5; - - /* "array.pxd":109 - * raise MemoryError() - * info.shape[0] = item_count # constant regardless of resizing - * info.strides = &info.itemsize # <<<<<<<<<<<<<< - * - * info.format = (info.shape + 1) - */ - __pyx_v_info->strides = (&__pyx_v_info->itemsize); - - /* "array.pxd":111 - * info.strides = &info.itemsize - * - * info.format = (info.shape + 1) # <<<<<<<<<<<<<< - * info.format[0] = self.ob_descr.typecode - * info.format[1] = 0 - */ - __pyx_v_info->format = ((char *)(__pyx_v_info->shape + 1)); - - /* "array.pxd":112 - * - * info.format = (info.shape + 1) - * info.format[0] = self.ob_descr.typecode # <<<<<<<<<<<<<< - * info.format[1] = 0 - * info.obj = self - */ - __pyx_t_3 = __pyx_v_self->ob_descr->typecode; - (__pyx_v_info->format[0]) = __pyx_t_3; - - /* "array.pxd":113 - * info.format = (info.shape + 1) - * info.format[0] = self.ob_descr.typecode - * info.format[1] = 0 # <<<<<<<<<<<<<< - * info.obj = self - * - */ - (__pyx_v_info->format[1]) = 0; - - /* "array.pxd":114 - * info.format[0] = self.ob_descr.typecode - * info.format[1] = 0 - * info.obj = self # <<<<<<<<<<<<<< - * - * def __releasebuffer__(self, Py_buffer* info): - */ - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = ((PyObject *)__pyx_v_self); - - /* "array.pxd":91 - * __data_union data - * - * def __getbuffer__(self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< - * # This implementation of getbuffer is geared towards Cython - * # requirements, and does not yet fullfill the PEP. - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("cpython.array.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; - } - goto __pyx_L2; - __pyx_L0:; - if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { - __Pyx_GOTREF(Py_None); - __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; - } - __pyx_L2:; - __Pyx_XDECREF(__pyx_v_item_count); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "array.pxd":116 - * info.obj = self - * - * def __releasebuffer__(self, Py_buffer* info): # <<<<<<<<<<<<<< - * PyObject_Free(info.shape) - * - */ - -/* Python wrapper */ -static CYTHON_UNUSED void __pyx_pw_7cpython_5array_5array_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ -static CYTHON_UNUSED void __pyx_pw_7cpython_5array_5array_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); - __pyx_pf_7cpython_5array_5array_2__releasebuffer__(((arrayobject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -static void __pyx_pf_7cpython_5array_5array_2__releasebuffer__(CYTHON_UNUSED arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__releasebuffer__", 0); - - /* "array.pxd":117 - * - * def __releasebuffer__(self, Py_buffer* info): - * PyObject_Free(info.shape) # <<<<<<<<<<<<<< - * - * array newarrayobject(PyTypeObject* type, Py_ssize_t size, arraydescr *descr) - */ - PyObject_Free(__pyx_v_info->shape); - - /* "array.pxd":116 - * info.obj = self - * - * def __releasebuffer__(self, Py_buffer* info): # <<<<<<<<<<<<<< - * PyObject_Free(info.shape) - * - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "array.pxd":128 - * - * - * cdef inline array clone(array template, Py_ssize_t length, bint zero): # <<<<<<<<<<<<<< - * """ fast creation of a new array, given a template array. - * type will be same as template. - */ - -static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_clone(arrayobject *__pyx_v_template, Py_ssize_t __pyx_v_length, int __pyx_v_zero) { - arrayobject *__pyx_v_op = NULL; - arrayobject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - __Pyx_RefNannySetupContext("clone", 0); - - /* "array.pxd":132 - * type will be same as template. - * if zero is true, new array will be initialized with zeroes.""" - * op = newarrayobject(Py_TYPE(template), length, template.ob_descr) # <<<<<<<<<<<<<< - * if zero and op is not None: - * memset(op.data.as_chars, 0, length * op.ob_descr.itemsize) - */ - __pyx_t_1 = ((PyObject *)newarrayobject(Py_TYPE(((PyObject *)__pyx_v_template)), __pyx_v_length, __pyx_v_template->ob_descr)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 132, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_op = ((arrayobject *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "array.pxd":133 - * if zero is true, new array will be initialized with zeroes.""" - * op = newarrayobject(Py_TYPE(template), length, template.ob_descr) - * if zero and op is not None: # <<<<<<<<<<<<<< - * memset(op.data.as_chars, 0, length * op.ob_descr.itemsize) - * return op - */ - __pyx_t_3 = (__pyx_v_zero != 0); - if (__pyx_t_3) { - } else { - __pyx_t_2 = __pyx_t_3; - goto __pyx_L4_bool_binop_done; - } - __pyx_t_3 = (((PyObject *)__pyx_v_op) != Py_None); - __pyx_t_4 = (__pyx_t_3 != 0); - __pyx_t_2 = __pyx_t_4; - __pyx_L4_bool_binop_done:; - if (__pyx_t_2) { - - /* "array.pxd":134 - * op = newarrayobject(Py_TYPE(template), length, template.ob_descr) - * if zero and op is not None: - * memset(op.data.as_chars, 0, length * op.ob_descr.itemsize) # <<<<<<<<<<<<<< - * return op - * - */ - memset(__pyx_v_op->data.as_chars, 0, (__pyx_v_length * __pyx_v_op->ob_descr->itemsize)); - - /* "array.pxd":133 - * if zero is true, new array will be initialized with zeroes.""" - * op = newarrayobject(Py_TYPE(template), length, template.ob_descr) - * if zero and op is not None: # <<<<<<<<<<<<<< - * memset(op.data.as_chars, 0, length * op.ob_descr.itemsize) - * return op - */ - } - - /* "array.pxd":135 - * if zero and op is not None: - * memset(op.data.as_chars, 0, length * op.ob_descr.itemsize) - * return op # <<<<<<<<<<<<<< - * - * cdef inline array copy(array self): - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __Pyx_INCREF(((PyObject *)__pyx_v_op)); - __pyx_r = __pyx_v_op; - goto __pyx_L0; - - /* "array.pxd":128 - * - * - * cdef inline array clone(array template, Py_ssize_t length, bint zero): # <<<<<<<<<<<<<< - * """ fast creation of a new array, given a template array. - * type will be same as template. - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("cpython.array.clone", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_op); - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "array.pxd":137 - * return op - * - * cdef inline array copy(array self): # <<<<<<<<<<<<<< - * """ make a copy of an array. """ - * op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr) - */ - -static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_copy(arrayobject *__pyx_v_self) { - arrayobject *__pyx_v_op = NULL; - arrayobject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("copy", 0); - - /* "array.pxd":139 - * cdef inline array copy(array self): - * """ make a copy of an array. """ - * op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr) # <<<<<<<<<<<<<< - * memcpy(op.data.as_chars, self.data.as_chars, Py_SIZE(op) * op.ob_descr.itemsize) - * return op - */ - __pyx_t_1 = ((PyObject *)newarrayobject(Py_TYPE(((PyObject *)__pyx_v_self)), Py_SIZE(((PyObject *)__pyx_v_self)), __pyx_v_self->ob_descr)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 139, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_op = ((arrayobject *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "array.pxd":140 - * """ make a copy of an array. """ - * op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr) - * memcpy(op.data.as_chars, self.data.as_chars, Py_SIZE(op) * op.ob_descr.itemsize) # <<<<<<<<<<<<<< - * return op - * - */ - memcpy(__pyx_v_op->data.as_chars, __pyx_v_self->data.as_chars, (Py_SIZE(((PyObject *)__pyx_v_op)) * __pyx_v_op->ob_descr->itemsize)); - - /* "array.pxd":141 - * op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr) - * memcpy(op.data.as_chars, self.data.as_chars, Py_SIZE(op) * op.ob_descr.itemsize) - * return op # <<<<<<<<<<<<<< - * - * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1: - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __Pyx_INCREF(((PyObject *)__pyx_v_op)); - __pyx_r = __pyx_v_op; - goto __pyx_L0; - - /* "array.pxd":137 - * return op - * - * cdef inline array copy(array self): # <<<<<<<<<<<<<< - * """ make a copy of an array. """ - * op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("cpython.array.copy", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_op); - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "array.pxd":143 - * return op - * - * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1: # <<<<<<<<<<<<<< - * """ efficent appending of new stuff of same type - * (e.g. of same array type) - */ - -static CYTHON_INLINE int __pyx_f_7cpython_5array_extend_buffer(arrayobject *__pyx_v_self, char *__pyx_v_stuff, Py_ssize_t __pyx_v_n) { - Py_ssize_t __pyx_v_itemsize; - Py_ssize_t __pyx_v_origsize; - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("extend_buffer", 0); - - /* "array.pxd":147 - * (e.g. of same array type) - * n: number of elements (not number of bytes!) """ - * cdef Py_ssize_t itemsize = self.ob_descr.itemsize # <<<<<<<<<<<<<< - * cdef Py_ssize_t origsize = Py_SIZE(self) - * resize_smart(self, origsize + n) - */ - __pyx_t_1 = __pyx_v_self->ob_descr->itemsize; - __pyx_v_itemsize = __pyx_t_1; - - /* "array.pxd":148 - * n: number of elements (not number of bytes!) """ - * cdef Py_ssize_t itemsize = self.ob_descr.itemsize - * cdef Py_ssize_t origsize = Py_SIZE(self) # <<<<<<<<<<<<<< - * resize_smart(self, origsize + n) - * memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize) - */ - __pyx_v_origsize = Py_SIZE(((PyObject *)__pyx_v_self)); - - /* "array.pxd":149 - * cdef Py_ssize_t itemsize = self.ob_descr.itemsize - * cdef Py_ssize_t origsize = Py_SIZE(self) - * resize_smart(self, origsize + n) # <<<<<<<<<<<<<< - * memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize) - * return 0 - */ - __pyx_t_1 = resize_smart(__pyx_v_self, (__pyx_v_origsize + __pyx_v_n)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 149, __pyx_L1_error) - - /* "array.pxd":150 - * cdef Py_ssize_t origsize = Py_SIZE(self) - * resize_smart(self, origsize + n) - * memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize) # <<<<<<<<<<<<<< - * return 0 - * - */ - memcpy((__pyx_v_self->data.as_chars + (__pyx_v_origsize * __pyx_v_itemsize)), __pyx_v_stuff, (__pyx_v_n * __pyx_v_itemsize)); - - /* "array.pxd":151 - * resize_smart(self, origsize + n) - * memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize) - * return 0 # <<<<<<<<<<<<<< - * - * cdef inline int extend(array self, array other) except -1: - */ - __pyx_r = 0; - goto __pyx_L0; - - /* "array.pxd":143 - * return op - * - * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1: # <<<<<<<<<<<<<< - * """ efficent appending of new stuff of same type - * (e.g. of same array type) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_AddTraceback("cpython.array.extend_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "array.pxd":153 - * return 0 - * - * cdef inline int extend(array self, array other) except -1: # <<<<<<<<<<<<<< - * """ extend array with data from another array; types must match. """ - * if self.ob_descr.typecode != other.ob_descr.typecode: - */ - -static CYTHON_INLINE int __pyx_f_7cpython_5array_extend(arrayobject *__pyx_v_self, arrayobject *__pyx_v_other) { - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - __Pyx_RefNannySetupContext("extend", 0); - - /* "array.pxd":155 - * cdef inline int extend(array self, array other) except -1: - * """ extend array with data from another array; types must match. """ - * if self.ob_descr.typecode != other.ob_descr.typecode: # <<<<<<<<<<<<<< - * PyErr_BadArgument() - * return extend_buffer(self, other.data.as_chars, Py_SIZE(other)) - */ - __pyx_t_1 = ((__pyx_v_self->ob_descr->typecode != __pyx_v_other->ob_descr->typecode) != 0); - if (__pyx_t_1) { - - /* "array.pxd":156 - * """ extend array with data from another array; types must match. """ - * if self.ob_descr.typecode != other.ob_descr.typecode: - * PyErr_BadArgument() # <<<<<<<<<<<<<< - * return extend_buffer(self, other.data.as_chars, Py_SIZE(other)) - * - */ - __pyx_t_2 = PyErr_BadArgument(); if (unlikely(__pyx_t_2 == 0)) __PYX_ERR(1, 156, __pyx_L1_error) - - /* "array.pxd":155 - * cdef inline int extend(array self, array other) except -1: - * """ extend array with data from another array; types must match. """ - * if self.ob_descr.typecode != other.ob_descr.typecode: # <<<<<<<<<<<<<< - * PyErr_BadArgument() - * return extend_buffer(self, other.data.as_chars, Py_SIZE(other)) - */ - } - - /* "array.pxd":157 - * if self.ob_descr.typecode != other.ob_descr.typecode: - * PyErr_BadArgument() - * return extend_buffer(self, other.data.as_chars, Py_SIZE(other)) # <<<<<<<<<<<<<< - * - * cdef inline void zero(array self): - */ - __pyx_t_2 = __pyx_f_7cpython_5array_extend_buffer(__pyx_v_self, __pyx_v_other->data.as_chars, Py_SIZE(((PyObject *)__pyx_v_other))); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(1, 157, __pyx_L1_error) - __pyx_r = __pyx_t_2; - goto __pyx_L0; - - /* "array.pxd":153 - * return 0 - * - * cdef inline int extend(array self, array other) except -1: # <<<<<<<<<<<<<< - * """ extend array with data from another array; types must match. """ - * if self.ob_descr.typecode != other.ob_descr.typecode: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_AddTraceback("cpython.array.extend", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "array.pxd":159 - * return extend_buffer(self, other.data.as_chars, Py_SIZE(other)) - * - * cdef inline void zero(array self): # <<<<<<<<<<<<<< - * """ set all elements of array to zero. """ - * memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize) - */ - -static CYTHON_INLINE void __pyx_f_7cpython_5array_zero(arrayobject *__pyx_v_self) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("zero", 0); - - /* "array.pxd":161 - * cdef inline void zero(array self): - * """ set all elements of array to zero. """ - * memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize) # <<<<<<<<<<<<<< - */ - memset(__pyx_v_self->data.as_chars, 0, (Py_SIZE(((PyObject *)__pyx_v_self)) * __pyx_v_self->ob_descr->itemsize)); - - /* "array.pxd":159 - * return extend_buffer(self, other.data.as_chars, Py_SIZE(other)) - * - * cdef inline void zero(array self): # <<<<<<<<<<<<<< - * """ set all elements of array to zero. """ - * memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize) - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -static PyMethodDef __pyx_methods[] = { - {0, 0, 0, 0} -}; - -#if PY_MAJOR_VERSION >= 3 -static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else - PyModuleDef_HEAD_INIT, - #endif - "blosc", - 0, /* m_doc */ - -1, /* m_size */ - __pyx_methods /* m_methods */, - NULL, /* m_reload */ - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ -}; -#endif - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_n_s_BITSHUFFLE, __pyx_k_BITSHUFFLE, sizeof(__pyx_k_BITSHUFFLE), 0, 0, 1, 1}, - {&__pyx_n_s_MAX_BUFFERSIZE, __pyx_k_MAX_BUFFERSIZE, sizeof(__pyx_k_MAX_BUFFERSIZE), 0, 0, 1, 1}, - {&__pyx_n_s_MAX_OVERHEAD, __pyx_k_MAX_OVERHEAD, sizeof(__pyx_k_MAX_OVERHEAD), 0, 0, 1, 1}, - {&__pyx_n_s_MAX_THREADS, __pyx_k_MAX_THREADS, sizeof(__pyx_k_MAX_THREADS), 0, 0, 1, 1}, - {&__pyx_n_s_MAX_TYPESIZE, __pyx_k_MAX_TYPESIZE, sizeof(__pyx_k_MAX_TYPESIZE), 0, 0, 1, 1}, - {&__pyx_n_s_MainThread, __pyx_k_MainThread, sizeof(__pyx_k_MainThread), 0, 0, 1, 1}, - {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1}, - {&__pyx_n_s_NOSHUFFLE, __pyx_k_NOSHUFFLE, sizeof(__pyx_k_NOSHUFFLE), 0, 0, 1, 1}, - {&__pyx_n_s_PY2, __pyx_k_PY2, sizeof(__pyx_k_PY2), 0, 0, 1, 1}, - {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, - {&__pyx_n_s_SHUFFLE, __pyx_k_SHUFFLE, sizeof(__pyx_k_SHUFFLE), 0, 0, 1, 1}, - {&__pyx_n_s_VERSION_DATE, __pyx_k_VERSION_DATE, sizeof(__pyx_k_VERSION_DATE), 0, 0, 1, 1}, - {&__pyx_n_s_VERSION_STRING, __pyx_k_VERSION_STRING, sizeof(__pyx_k_VERSION_STRING), 0, 0, 1, 1}, - {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, - {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0}, - {&__pyx_n_s_array, __pyx_k_array, sizeof(__pyx_k_array), 0, 0, 1, 1}, - {&__pyx_n_s_as_voidptr, __pyx_k_as_voidptr, sizeof(__pyx_k_as_voidptr), 0, 0, 1, 1}, - {&__pyx_n_s_ascii, __pyx_k_ascii, sizeof(__pyx_k_ascii), 0, 0, 1, 1}, - {&__pyx_n_s_blocksize, __pyx_k_blocksize, sizeof(__pyx_k_blocksize), 0, 0, 1, 1}, - {&__pyx_n_s_buffer_info, __pyx_k_buffer_info, sizeof(__pyx_k_buffer_info), 0, 0, 1, 1}, - {&__pyx_n_s_cbuffer_sizes, __pyx_k_cbuffer_sizes, sizeof(__pyx_k_cbuffer_sizes), 0, 0, 1, 1}, - {&__pyx_n_s_cbytes, __pyx_k_cbytes, sizeof(__pyx_k_cbytes), 0, 0, 1, 1}, - {&__pyx_n_s_clevel, __pyx_k_clevel, sizeof(__pyx_k_clevel), 0, 0, 1, 1}, - {&__pyx_n_s_cname, __pyx_k_cname, sizeof(__pyx_k_cname), 0, 0, 1, 1}, - {&__pyx_n_s_compname_to_compcode, __pyx_k_compname_to_compcode, sizeof(__pyx_k_compname_to_compcode), 0, 0, 1, 1}, - {&__pyx_n_s_compress, __pyx_k_compress, sizeof(__pyx_k_compress), 0, 0, 1, 1}, - {&__pyx_kp_s_compressor_not_supported_r, __pyx_k_compressor_not_supported_r, sizeof(__pyx_k_compressor_not_supported_r), 0, 0, 1, 0}, - {&__pyx_n_s_compressor_set, __pyx_k_compressor_set, sizeof(__pyx_k_compressor_set), 0, 0, 1, 1}, - {&__pyx_n_s_current_thread, __pyx_k_current_thread, sizeof(__pyx_k_current_thread), 0, 0, 1, 1}, - {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1}, - {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1}, - {&__pyx_n_s_decompress, __pyx_k_decompress, sizeof(__pyx_k_decompress), 0, 0, 1, 1}, - {&__pyx_n_s_dest, __pyx_k_dest, sizeof(__pyx_k_dest), 0, 0, 1, 1}, - {&__pyx_n_s_dest_array, __pyx_k_dest_array, sizeof(__pyx_k_dest_array), 0, 0, 1, 1}, - {&__pyx_n_s_dest_buffer, __pyx_k_dest_buffer, sizeof(__pyx_k_dest_buffer), 0, 0, 1, 1}, - {&__pyx_n_s_dest_nbytes, __pyx_k_dest_nbytes, sizeof(__pyx_k_dest_nbytes), 0, 0, 1, 1}, - {&__pyx_n_s_dest_ptr, __pyx_k_dest_ptr, sizeof(__pyx_k_dest_ptr), 0, 0, 1, 1}, - {&__pyx_kp_s_destination_buffer_has_wrong_siz, __pyx_k_destination_buffer_has_wrong_siz, sizeof(__pyx_k_destination_buffer_has_wrong_siz), 0, 0, 1, 0}, - {&__pyx_n_s_destroy, __pyx_k_destroy, sizeof(__pyx_k_destroy), 0, 0, 1, 1}, - {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 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}, - {&__pyx_kp_s_error_during_blosc_decompression, __pyx_k_error_during_blosc_decompression, sizeof(__pyx_k_error_during_blosc_decompression), 0, 0, 1, 0}, - {&__pyx_n_s_get_nthreads, __pyx_k_get_nthreads, sizeof(__pyx_k_get_nthreads), 0, 0, 1, 1}, - {&__pyx_n_s_get_use_threads, __pyx_k_get_use_threads, sizeof(__pyx_k_get_use_threads), 0, 0, 1, 1}, - {&__pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_k_home_aliman_src_github_alimanfo, sizeof(__pyx_k_home_aliman_src_github_alimanfo), 0, 0, 1, 0}, - {&__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_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1}, - {&__pyx_n_s_list_compressors, __pyx_k_list_compressors, sizeof(__pyx_k_list_compressors), 0, 0, 1, 1}, - {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, - {&__pyx_n_s_main_thread, __pyx_k_main_thread, sizeof(__pyx_k_main_thread), 0, 0, 1, 1}, - {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, - {&__pyx_n_s_nbytes, __pyx_k_nbytes, sizeof(__pyx_k_nbytes), 0, 0, 1, 1}, - {&__pyx_n_s_nthreads, __pyx_k_nthreads, sizeof(__pyx_k_nthreads), 0, 0, 1, 1}, - {&__pyx_n_s_release_dest_buffer, __pyx_k_release_dest_buffer, sizeof(__pyx_k_release_dest_buffer), 0, 0, 1, 1}, - {&__pyx_n_s_release_source_buffer, __pyx_k_release_source_buffer, sizeof(__pyx_k_release_source_buffer), 0, 0, 1, 1}, - {&__pyx_n_s_ret, __pyx_k_ret, sizeof(__pyx_k_ret), 0, 0, 1, 1}, - {&__pyx_n_s_set_nthreads, __pyx_k_set_nthreads, sizeof(__pyx_k_set_nthreads), 0, 0, 1, 1}, - {&__pyx_n_s_shuffle, __pyx_k_shuffle, sizeof(__pyx_k_shuffle), 0, 0, 1, 1}, - {&__pyx_n_s_source, __pyx_k_source, sizeof(__pyx_k_source), 0, 0, 1, 1}, - {&__pyx_n_s_source_array, __pyx_k_source_array, sizeof(__pyx_k_source_array), 0, 0, 1, 1}, - {&__pyx_n_s_source_buffer, __pyx_k_source_buffer, sizeof(__pyx_k_source_buffer), 0, 0, 1, 1}, - {&__pyx_n_s_source_ptr, __pyx_k_source_ptr, sizeof(__pyx_k_source_ptr), 0, 0, 1, 1}, - {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1}, - {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, - {&__pyx_n_s_text_type, __pyx_k_text_type, sizeof(__pyx_k_text_type), 0, 0, 1, 1}, - {&__pyx_n_s_threading, __pyx_k_threading, sizeof(__pyx_k_threading), 0, 0, 1, 1}, - {&__pyx_n_s_use_threads, __pyx_k_use_threads, sizeof(__pyx_k_use_threads), 0, 0, 1, 1}, - {&__pyx_n_s_use_threads_2, __pyx_k_use_threads_2, sizeof(__pyx_k_use_threads_2), 0, 0, 1, 1}, - {&__pyx_n_s_version, __pyx_k_version, sizeof(__pyx_k_version), 0, 0, 1, 1}, - {&__pyx_n_s_version_2, __pyx_k_version_2, sizeof(__pyx_k_version_2), 0, 0, 1, 1}, - {&__pyx_n_s_zarr_blosc, __pyx_k_zarr_blosc, sizeof(__pyx_k_zarr_blosc), 0, 0, 1, 1}, - {&__pyx_n_s_zarr_compat, __pyx_k_zarr_compat, sizeof(__pyx_k_zarr_compat), 0, 0, 1, 1}, - {0, 0, 0, 0, 0, 0, 0} -}; -static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 201, __pyx_L1_error) - __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 223, __pyx_L1_error) - __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(1, 107, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static int __Pyx_InitCachedConstants(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - - /* "zarr/blosc.pyx":84 - * def compname_to_compcode(cname): - * if isinstance(cname, text_type): - * cname = cname.encode('ascii') # <<<<<<<<<<<<<< - * return blosc_compname_to_compcode(cname) - * - */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_s_ascii); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 84, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple_); - __Pyx_GIVEREF(__pyx_tuple_); - - /* "zarr/blosc.pyx":89 - * - * def list_compressors(): - * return text_type(blosc_list_compressors(), 'ascii').split(',') # <<<<<<<<<<<<<< - * - * - */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s__2); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 89, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__3); - __Pyx_GIVEREF(__pyx_tuple__3); - - /* "zarr/blosc.pyx":70 - * - * - * def version(): # <<<<<<<<<<<<<< - * return VERSION_STRING, VERSION_DATE - * - */ - __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_version_2, 70, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 70, __pyx_L1_error) - - /* "zarr/blosc.pyx":74 - * - * - * def init(): # <<<<<<<<<<<<<< - * blosc_init() - * - */ - __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_init, 74, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 74, __pyx_L1_error) - - /* "zarr/blosc.pyx":78 - * - * - * def destroy(): # <<<<<<<<<<<<<< - * blosc_destroy() - * - */ - __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_destroy, 78, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 78, __pyx_L1_error) - - /* "zarr/blosc.pyx":82 - * - * - * def compname_to_compcode(cname): # <<<<<<<<<<<<<< - * if isinstance(cname, text_type): - * cname = cname.encode('ascii') - */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_n_s_cname); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); - __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_compname_to_compcode, 82, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 82, __pyx_L1_error) - - /* "zarr/blosc.pyx":88 - * - * - * def list_compressors(): # <<<<<<<<<<<<<< - * return text_type(blosc_list_compressors(), 'ascii').split(',') - * - */ - __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_list_compressors, 88, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 88, __pyx_L1_error) - - /* "zarr/blosc.pyx":92 - * - * - * def get_nthreads(): # <<<<<<<<<<<<<< - * """Get the number of threads that Blosc uses internally for compression - * and decompression. - */ - __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_get_nthreads, 92, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 92, __pyx_L1_error) - - /* "zarr/blosc.pyx":99 - * - * - * def set_nthreads(int nthreads): # <<<<<<<<<<<<<< - * """Set the number of threads that Blosc uses internally for compression - * and decompression. - */ - __pyx_tuple__11 = PyTuple_Pack(2, __pyx_n_s_nthreads, __pyx_n_s_nthreads); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__11); - __Pyx_GIVEREF(__pyx_tuple__11); - __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_set_nthreads, 99, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 99, __pyx_L1_error) - - /* "zarr/blosc.pyx":106 - * - * - * def cbuffer_sizes(source): # <<<<<<<<<<<<<< - * """Return information from the blosc header of some compressed data.""" - * cdef: - */ - __pyx_tuple__13 = PyTuple_Pack(8, __pyx_n_s_source, __pyx_n_s_source_ptr, __pyx_n_s_source_buffer, __pyx_n_s_source_array, __pyx_n_s_nbytes, __pyx_n_s_cbytes, __pyx_n_s_blocksize, __pyx_n_s_release_source_buffer); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__13); - __Pyx_GIVEREF(__pyx_tuple__13); - __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(1, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_cbuffer_sizes, 106, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 106, __pyx_L1_error) - - /* "zarr/blosc.pyx":136 - * - * - * def decompress(source, dest=None): # <<<<<<<<<<<<<< - * """Decompress data. - * - */ - __pyx_tuple__15 = PyTuple_Pack(15, __pyx_n_s_source, __pyx_n_s_dest, __pyx_n_s_ret, __pyx_n_s_source_ptr, __pyx_n_s_dest_ptr, __pyx_n_s_source_buffer, __pyx_n_s_source_array, __pyx_n_s_dest_buffer, __pyx_n_s_nbytes, __pyx_n_s_cbytes, __pyx_n_s_blocksize, __pyx_n_s_release_source_buffer, __pyx_n_s_release_dest_buffer, __pyx_n_s_dest_nbytes, __pyx_n_s_dest_array); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__15); - __Pyx_GIVEREF(__pyx_tuple__15); - __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(2, 0, 15, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_decompress, 136, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 136, __pyx_L1_error) - - /* "zarr/blosc.pyx":228 - * - * - * def compress(source, char* cname, int clevel, int shuffle): # <<<<<<<<<<<<<< - * """Compression. - * - */ - __pyx_tuple__17 = PyTuple_Pack(14, __pyx_n_s_source, __pyx_n_s_cname, __pyx_n_s_clevel, __pyx_n_s_shuffle, __pyx_n_s_source_ptr, __pyx_n_s_dest_ptr, __pyx_n_s_source_buffer, __pyx_n_s_nbytes, __pyx_n_s_cbytes, __pyx_n_s_itemsize, __pyx_n_s_source_array, __pyx_n_s_dest, __pyx_n_s_release_source_buffer, __pyx_n_s_compressor_set); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 228, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__17); - __Pyx_GIVEREF(__pyx_tuple__17); - __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(4, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_compress, 228, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 228, __pyx_L1_error) - - /* "zarr/blosc.pyx":319 - * - * - * def _get_use_threads(): # <<<<<<<<<<<<<< - * global use_threads - * - */ - __pyx_tuple__19 = PyTuple_Pack(1, __pyx_n_s_use_threads_2); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 319, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__19); - __Pyx_GIVEREF(__pyx_tuple__19); - __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_get_use_threads, 319, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 319, __pyx_L1_error) - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - return 0; - __pyx_L1_error:; - return -1; -} - -#if PY_MAJOR_VERSION < 3 -PyMODINIT_FUNC initblosc(void); /*proto*/ -PyMODINIT_FUNC initblosc(void) -#else -PyMODINIT_FUNC PyInit_blosc(void); /*proto*/ -PyMODINIT_FUNC PyInit_blosc(void) -#endif -{ - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - __Pyx_RefNannyDeclarations - #if CYTHON_REFNANNY - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); - if (!__Pyx_RefNanny) { - PyErr_Clear(); - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); - if (!__Pyx_RefNanny) - Py_FatalError("failed to import 'refnanny' module"); - } - #endif - __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_blosc(void)", 0); - if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pyx_CyFunction_USED - if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Coroutine_USED - if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_StopAsyncIteration_USED - if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - #ifdef WITH_THREAD /* Python build with threading support? */ - PyEval_InitThreads(); - #endif - #endif - /*--- Module creation code ---*/ - #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4("blosc", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); - #else - __pyx_m = PyModule_Create(&__pyx_moduledef); - #endif - if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_d); - __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) - #if CYTHON_COMPILING_IN_PYPY - Py_INCREF(__pyx_b); - #endif - if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - /*--- Initialize various global constants etc. ---*/ - if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - if (__pyx_module_is_main_zarr__blosc) { - if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - } - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) - if (!PyDict_GetItemString(modules, "zarr.blosc")) { - if (unlikely(PyDict_SetItemString(modules, "zarr.blosc", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - } - } - #endif - /*--- Builtin init code ---*/ - if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Constants init code ---*/ - if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global init code ---*/ - /*--- Variable export code ---*/ - /*--- Function export code ---*/ - /*--- Type init code ---*/ - /*--- Type import code ---*/ - __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", - #if CYTHON_COMPILING_IN_PYPY - sizeof(PyTypeObject), - #else - sizeof(PyHeapTypeObject), - #endif - 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(2, 9, __pyx_L1_error) - __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) __PYX_ERR(3, 8, __pyx_L1_error) - __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) __PYX_ERR(4, 15, __pyx_L1_error) - __pyx_ptype_7cpython_5array_array = __Pyx_ImportType("array", "array", sizeof(arrayobject), 0); if (unlikely(!__pyx_ptype_7cpython_5array_array)) __PYX_ERR(1, 58, __pyx_L1_error) - /*--- Variable import code ---*/ - /*--- Function import code ---*/ - /*--- Execution code ---*/ - #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) - if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - - /* "zarr/blosc.pyx":7 - * # cython: binding=False - * from __future__ import absolute_import, print_function, division - * import threading # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_threading, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_threading, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "zarr/blosc.pyx":12 - * # noinspection PyUnresolvedReferences - * from cpython cimport array, PyObject - * import array # <<<<<<<<<<<<<< - * from cpython.buffer cimport PyObject_GetBuffer, PyBuffer_Release, \ - * PyBUF_ANY_CONTIGUOUS, PyBUF_WRITEABLE - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_array, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_array, __pyx_t_1) < 0) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "zarr/blosc.pyx":19 - * - * - * from zarr.compat import PY2, text_type # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_PY2); - __Pyx_GIVEREF(__pyx_n_s_PY2); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PY2); - __Pyx_INCREF(__pyx_n_s_text_type); - __Pyx_GIVEREF(__pyx_n_s_text_type); - PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_text_type); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_zarr_compat, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __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_PY2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_PY2, __pyx_t_1) < 0) __PYX_ERR(0, 19, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_text_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_text_type, __pyx_t_1) < 0) __PYX_ERR(0, 19, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":55 - * - * - * MAX_OVERHEAD = BLOSC_MAX_OVERHEAD # <<<<<<<<<<<<<< - * MAX_BUFFERSIZE = BLOSC_MAX_BUFFERSIZE - * MAX_THREADS = BLOSC_MAX_THREADS - */ - __pyx_t_2 = __Pyx_PyInt_From_int(BLOSC_MAX_OVERHEAD); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_MAX_OVERHEAD, __pyx_t_2) < 0) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":56 - * - * MAX_OVERHEAD = BLOSC_MAX_OVERHEAD - * MAX_BUFFERSIZE = BLOSC_MAX_BUFFERSIZE # <<<<<<<<<<<<<< - * MAX_THREADS = BLOSC_MAX_THREADS - * MAX_TYPESIZE = BLOSC_MAX_TYPESIZE - */ - __pyx_t_2 = __Pyx_PyInt_From_int(BLOSC_MAX_BUFFERSIZE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_MAX_BUFFERSIZE, __pyx_t_2) < 0) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":57 - * MAX_OVERHEAD = BLOSC_MAX_OVERHEAD - * MAX_BUFFERSIZE = BLOSC_MAX_BUFFERSIZE - * MAX_THREADS = BLOSC_MAX_THREADS # <<<<<<<<<<<<<< - * MAX_TYPESIZE = BLOSC_MAX_TYPESIZE - * VERSION_STRING = BLOSC_VERSION_STRING - */ - __pyx_t_2 = __Pyx_PyInt_From_int(BLOSC_MAX_THREADS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_MAX_THREADS, __pyx_t_2) < 0) __PYX_ERR(0, 57, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":58 - * MAX_BUFFERSIZE = BLOSC_MAX_BUFFERSIZE - * MAX_THREADS = BLOSC_MAX_THREADS - * MAX_TYPESIZE = BLOSC_MAX_TYPESIZE # <<<<<<<<<<<<<< - * VERSION_STRING = BLOSC_VERSION_STRING - * VERSION_DATE = BLOSC_VERSION_DATE - */ - __pyx_t_2 = __Pyx_PyInt_From_int(BLOSC_MAX_TYPESIZE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_MAX_TYPESIZE, __pyx_t_2) < 0) __PYX_ERR(0, 58, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":59 - * MAX_THREADS = BLOSC_MAX_THREADS - * MAX_TYPESIZE = BLOSC_MAX_TYPESIZE - * VERSION_STRING = BLOSC_VERSION_STRING # <<<<<<<<<<<<<< - * VERSION_DATE = BLOSC_VERSION_DATE - * if not PY2: - */ - __pyx_t_2 = __Pyx_PyBytes_FromString(((char *)BLOSC_VERSION_STRING)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_VERSION_STRING, __pyx_t_2) < 0) __PYX_ERR(0, 59, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":60 - * MAX_TYPESIZE = BLOSC_MAX_TYPESIZE - * VERSION_STRING = BLOSC_VERSION_STRING - * VERSION_DATE = BLOSC_VERSION_DATE # <<<<<<<<<<<<<< - * if not PY2: - * VERSION_STRING = VERSION_STRING.decode() - */ - __pyx_t_2 = __Pyx_PyBytes_FromString(((char *)BLOSC_VERSION_DATE)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_VERSION_DATE, __pyx_t_2) < 0) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":61 - * VERSION_STRING = BLOSC_VERSION_STRING - * VERSION_DATE = BLOSC_VERSION_DATE - * if not PY2: # <<<<<<<<<<<<<< - * VERSION_STRING = VERSION_STRING.decode() - * VERSION_DATE = VERSION_DATE.decode() - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PY2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 61, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = ((!__pyx_t_3) != 0); - if (__pyx_t_4) { - - /* "zarr/blosc.pyx":62 - * VERSION_DATE = BLOSC_VERSION_DATE - * if not PY2: - * VERSION_STRING = VERSION_STRING.decode() # <<<<<<<<<<<<<< - * VERSION_DATE = VERSION_DATE.decode() - * __version__ = VERSION_STRING - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_VERSION_STRING); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_decode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 62, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_1)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_1); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (__pyx_t_1) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (PyDict_SetItem(__pyx_d, __pyx_n_s_VERSION_STRING, __pyx_t_2) < 0) __PYX_ERR(0, 62, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":63 - * if not PY2: - * VERSION_STRING = VERSION_STRING.decode() - * VERSION_DATE = VERSION_DATE.decode() # <<<<<<<<<<<<<< - * __version__ = VERSION_STRING - * NOSHUFFLE = BLOSC_NOSHUFFLE - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_VERSION_DATE); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 63, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - if (__pyx_t_5) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (PyDict_SetItem(__pyx_d, __pyx_n_s_VERSION_DATE, __pyx_t_2) < 0) __PYX_ERR(0, 63, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":61 - * VERSION_STRING = BLOSC_VERSION_STRING - * VERSION_DATE = BLOSC_VERSION_DATE - * if not PY2: # <<<<<<<<<<<<<< - * VERSION_STRING = VERSION_STRING.decode() - * VERSION_DATE = VERSION_DATE.decode() - */ - } - - /* "zarr/blosc.pyx":64 - * VERSION_STRING = VERSION_STRING.decode() - * VERSION_DATE = VERSION_DATE.decode() - * __version__ = VERSION_STRING # <<<<<<<<<<<<<< - * NOSHUFFLE = BLOSC_NOSHUFFLE - * SHUFFLE = BLOSC_SHUFFLE - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_VERSION_STRING); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_version, __pyx_t_2) < 0) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":65 - * VERSION_DATE = VERSION_DATE.decode() - * __version__ = VERSION_STRING - * NOSHUFFLE = BLOSC_NOSHUFFLE # <<<<<<<<<<<<<< - * SHUFFLE = BLOSC_SHUFFLE - * BITSHUFFLE = BLOSC_BITSHUFFLE - */ - __pyx_t_2 = __Pyx_PyInt_From_int(BLOSC_NOSHUFFLE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_NOSHUFFLE, __pyx_t_2) < 0) __PYX_ERR(0, 65, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":66 - * __version__ = VERSION_STRING - * NOSHUFFLE = BLOSC_NOSHUFFLE - * SHUFFLE = BLOSC_SHUFFLE # <<<<<<<<<<<<<< - * BITSHUFFLE = BLOSC_BITSHUFFLE - * - */ - __pyx_t_2 = __Pyx_PyInt_From_int(BLOSC_SHUFFLE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_SHUFFLE, __pyx_t_2) < 0) __PYX_ERR(0, 66, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":67 - * NOSHUFFLE = BLOSC_NOSHUFFLE - * SHUFFLE = BLOSC_SHUFFLE - * BITSHUFFLE = BLOSC_BITSHUFFLE # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_2 = __Pyx_PyInt_From_int(BLOSC_BITSHUFFLE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_BITSHUFFLE, __pyx_t_2) < 0) __PYX_ERR(0, 67, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":70 - * - * - * def version(): # <<<<<<<<<<<<<< - * return VERSION_STRING, VERSION_DATE - * - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4zarr_5blosc_1version, NULL, __pyx_n_s_zarr_blosc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_version_2, __pyx_t_2) < 0) __PYX_ERR(0, 70, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":74 - * - * - * def init(): # <<<<<<<<<<<<<< - * blosc_init() - * - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4zarr_5blosc_3init, NULL, __pyx_n_s_zarr_blosc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_init, __pyx_t_2) < 0) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":78 - * - * - * def destroy(): # <<<<<<<<<<<<<< - * blosc_destroy() - * - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4zarr_5blosc_5destroy, NULL, __pyx_n_s_zarr_blosc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_destroy, __pyx_t_2) < 0) __PYX_ERR(0, 78, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":82 - * - * - * def compname_to_compcode(cname): # <<<<<<<<<<<<<< - * if isinstance(cname, text_type): - * cname = cname.encode('ascii') - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4zarr_5blosc_7compname_to_compcode, NULL, __pyx_n_s_zarr_blosc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_compname_to_compcode, __pyx_t_2) < 0) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":88 - * - * - * def list_compressors(): # <<<<<<<<<<<<<< - * return text_type(blosc_list_compressors(), 'ascii').split(',') - * - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4zarr_5blosc_9list_compressors, NULL, __pyx_n_s_zarr_blosc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_list_compressors, __pyx_t_2) < 0) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":92 - * - * - * def get_nthreads(): # <<<<<<<<<<<<<< - * """Get the number of threads that Blosc uses internally for compression - * and decompression. - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4zarr_5blosc_11get_nthreads, NULL, __pyx_n_s_zarr_blosc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_nthreads, __pyx_t_2) < 0) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":99 - * - * - * def set_nthreads(int nthreads): # <<<<<<<<<<<<<< - * """Set the number of threads that Blosc uses internally for compression - * and decompression. - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4zarr_5blosc_13set_nthreads, NULL, __pyx_n_s_zarr_blosc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_nthreads, __pyx_t_2) < 0) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":106 - * - * - * def cbuffer_sizes(source): # <<<<<<<<<<<<<< - * """Return information from the blosc header of some compressed data.""" - * cdef: - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4zarr_5blosc_15cbuffer_sizes, NULL, __pyx_n_s_zarr_blosc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_cbuffer_sizes, __pyx_t_2) < 0) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":136 - * - * - * def decompress(source, dest=None): # <<<<<<<<<<<<<< - * """Decompress data. - * - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4zarr_5blosc_17decompress, NULL, __pyx_n_s_zarr_blosc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_decompress, __pyx_t_2) < 0) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":228 - * - * - * def compress(source, char* cname, int clevel, int shuffle): # <<<<<<<<<<<<<< - * """Compression. - * - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4zarr_5blosc_19compress, NULL, __pyx_n_s_zarr_blosc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 228, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_compress, __pyx_t_2) < 0) __PYX_ERR(0, 228, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":316 - * # set the value of this variable to True or False to override the - * # default adaptive behaviour - * use_threads = None # <<<<<<<<<<<<<< - * - * - */ - if (PyDict_SetItem(__pyx_d, __pyx_n_s_use_threads, Py_None) < 0) __PYX_ERR(0, 316, __pyx_L1_error) - - /* "zarr/blosc.pyx":319 - * - * - * def _get_use_threads(): # <<<<<<<<<<<<<< - * global use_threads - * - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4zarr_5blosc_21_get_use_threads, NULL, __pyx_n_s_zarr_blosc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 319, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_use_threads, __pyx_t_2) < 0) __PYX_ERR(0, 319, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "zarr/blosc.pyx":1 - * # -*- coding: utf-8 -*- # <<<<<<<<<<<<<< - * # cython: embedsignature=True - * # cython: profile=False - */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "array.pxd":159 - * return extend_buffer(self, other.data.as_chars, Py_SIZE(other)) - * - * cdef inline void zero(array self): # <<<<<<<<<<<<<< - * """ set all elements of array to zero. """ - * memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize) - */ - - /*--- Wrapped vars code ---*/ - - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_5); - if (__pyx_m) { - if (__pyx_d) { - __Pyx_AddTraceback("init zarr.blosc", __pyx_clineno, __pyx_lineno, __pyx_filename); - } - Py_DECREF(__pyx_m); __pyx_m = 0; - } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init zarr.blosc"); - } - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else - return __pyx_m; - #endif -} - -/* --- Runtime support code --- */ -/* Refnanny */ -#if CYTHON_REFNANNY -static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { - PyObject *m = NULL, *p = NULL; - void *r = NULL; - m = PyImport_ImportModule((char *)modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); -end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; -} -#endif - -/* GetBuiltinName */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name) { - PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); - if (unlikely(!result)) { - PyErr_Format(PyExc_NameError, -#if PY_MAJOR_VERSION >= 3 - "name '%U' is not defined", name); -#else - "name '%.200s' is not defined", PyString_AS_STRING(name)); -#endif - } - return result; -} - -/* GetModuleGlobalName */ -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { - PyObject *result; -#if !CYTHON_AVOID_BORROWED_REFS - result = PyDict_GetItem(__pyx_d, name); - if (likely(result)) { - Py_INCREF(result); - } else { -#else - result = PyObject_GetItem(__pyx_d, name); - if (!result) { - PyErr_Clear(); -#endif - result = __Pyx_GetBuiltinName(name); - } - return result; -} - -/* PyObjectCall */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - ternaryfunc call = func->ob_type->tp_call; - if (unlikely(!call)) - return PyObject_Call(func, arg, kw); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = (*call)(func, arg, kw); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyFunctionFastCall */ - #if CYTHON_FAST_PYCALL -#include "frameobject.h" -static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, - PyObject *globals) { - PyFrameObject *f; - PyThreadState *tstate = PyThreadState_GET(); - PyObject **fastlocals; - Py_ssize_t i; - PyObject *result; - assert(globals != NULL); - /* XXX Perhaps we should create a specialized - PyFrame_New() that doesn't take locals, but does - take builtins without sanity checking them. - */ - assert(tstate != NULL); - f = PyFrame_New(tstate, co, globals, NULL); - if (f == NULL) { - return NULL; - } - fastlocals = f->f_localsplus; - for (i = 0; i < na; i++) { - Py_INCREF(*args); - fastlocals[i] = *args++; - } - result = PyEval_EvalFrameEx(f,0); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; - return result; -} -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { - PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); - PyObject *globals = PyFunction_GET_GLOBALS(func); - PyObject *argdefs = PyFunction_GET_DEFAULTS(func); - PyObject *closure; -#if PY_MAJOR_VERSION >= 3 - PyObject *kwdefs; -#endif - PyObject *kwtuple, **k; - PyObject **d; - Py_ssize_t nd; - Py_ssize_t nk; - PyObject *result; - assert(kwargs == NULL || PyDict_Check(kwargs)); - nk = kwargs ? PyDict_Size(kwargs) : 0; - if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { - return NULL; - } - if ( -#if PY_MAJOR_VERSION >= 3 - co->co_kwonlyargcount == 0 && -#endif - likely(kwargs == NULL || nk == 0) && - co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { - if (argdefs == NULL && co->co_argcount == nargs) { - result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); - goto done; - } - else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { - /* function called with no arguments, but all parameters have - a default value: use default values as arguments .*/ - args = &PyTuple_GET_ITEM(argdefs, 0); - result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); - goto done; - } - } - if (kwargs != NULL) { - Py_ssize_t pos, i; - kwtuple = PyTuple_New(2 * nk); - if (kwtuple == NULL) { - result = NULL; - goto done; - } - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; - } - nk = i / 2; - } - else { - kwtuple = NULL; - k = NULL; - } - closure = PyFunction_GET_CLOSURE(func); -#if PY_MAJOR_VERSION >= 3 - kwdefs = PyFunction_GET_KW_DEFAULTS(func); -#endif - if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); - } - else { - d = NULL; - nd = 0; - } -#if PY_MAJOR_VERSION >= 3 - result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, nargs, - k, (int)nk, - d, (int)nd, kwdefs, closure); -#else - result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, nargs, - k, (int)nk, - d, (int)nd, closure); -#endif - Py_XDECREF(kwtuple); -done: - Py_LeaveRecursiveCall(); - return result; -} -#endif // CPython < 3.6 -#endif // CYTHON_FAST_PYCALL - -/* PyCFunctionFastCall */ - #if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { - PyCFunctionObject *func = (PyCFunctionObject*)func_obj; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - assert(PyCFunction_Check(func)); - assert(METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST))); - assert(nargs >= 0); - assert(nargs == 0 || args != NULL); - /* _PyCFunction_FastCallDict() must not be called with an exception set, - because it may clear it (directly or indirectly) and so the - caller loses its exception */ - assert(!PyErr_Occurred()); - return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL); -} -#endif // CYTHON_FAST_PYCCALL - -/* ExtTypeTest */ - static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - if (likely(PyObject_TypeCheck(obj, type))) - return 1; - PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", - Py_TYPE(obj)->tp_name, type->tp_name); - return 0; -} - -/* RaiseDoubleKeywords */ - static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AsString(kw_name)); - #endif -} - -/* ParseKeywords */ - static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - continue; - } - name = first_kw_arg; - #if PY_MAJOR_VERSION < 3 - if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { - while (*name) { - if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) - && _PyString_Eq(**name, key)) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - if ((**argname == key) || ( - (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) - && _PyString_Eq(**argname, key))) { - goto arg_passed_twice; - } - argname++; - } - } - } else - #endif - if (likely(PyUnicode_Check(key))) { - while (*name) { - int cmp = (**name == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**name, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - int cmp = (**argname == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**argname, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) goto arg_passed_twice; - argname++; - } - } - } else - goto invalid_keyword_type; - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - return 0; -arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, key); - goto bad; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - goto bad; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -/* RaiseArgTupleInvalid */ - static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) -{ - Py_ssize_t num_expected; - const char *more_or_less; - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; - } else { - num_expected = num_max; - more_or_less = "at most"; - } - if (exact) { - more_or_less = "exactly"; - } - PyErr_Format(PyExc_TypeError, - "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", - func_name, more_or_less, num_expected, - (num_expected == 1) ? "" : "s", num_found); -} - -/* PyObjectCallMethO */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { - PyObject *self, *result; - PyCFunction cfunc; - cfunc = PyCFunction_GET_FUNCTION(func); - self = PyCFunction_GET_SELF(func); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = cfunc(self, arg); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCallOneArg */ - #if CYTHON_COMPILING_IN_CPYTHON -static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_New(1); - if (unlikely(!args)) return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, arg); - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, &arg, 1); - } -#endif -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { -#else - if (likely(PyCFunction_Check(func))) { -#endif - if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { - return __Pyx_PyObject_CallMethO(func, arg); -#if CYTHON_FAST_PYCCALL - } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { - return __Pyx_PyCFunction_FastCall(func, &arg, 1); -#endif - } - } - return __Pyx__PyObject_CallOneArg(func, arg); -} -#else -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_Pack(1, arg); - if (unlikely(!args)) return NULL; - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -#endif - -/* PyObjectCallNoArg */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, NULL, 0); - } -#endif -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { -#else - if (likely(PyCFunction_Check(func))) { -#endif - if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { - return __Pyx_PyObject_CallMethO(func, NULL); - } - } - return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); -} -#endif - -/* GetItemInt */ - static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { - PyObject *r; - if (!j) return NULL; - r = PyObject_GetItem(o, j); - Py_DECREF(j); - return r; -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); - if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); - if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { - PyObject *r = PyList_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } - else if (PyTuple_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - PyErr_Clear(); - } - } - return m->sq_item(o, i); - } - } -#else - if (is_list || PySequence_Check(o)) { - return PySequence_GetItem(o, i); - } -#endif - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -} - -/* PyErrFetchRestore */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - tmp_type = tstate->curexc_type; - tmp_value = tstate->curexc_value; - tmp_tb = tstate->curexc_traceback; - tstate->curexc_type = type; - tstate->curexc_value = value; - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - *type = tstate->curexc_type; - *value = tstate->curexc_value; - *tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -} -#endif - -/* RaiseException */ - #if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, - CYTHON_UNUSED PyObject *cause) { - __Pyx_PyThreadState_declare - Py_XINCREF(type); - if (!value || value == Py_None) - value = NULL; - else - Py_INCREF(value); - if (!tb || tb == Py_None) - tb = NULL; - else { - Py_INCREF(tb); - if (!PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - } - if (PyType_Check(type)) { -#if CYTHON_COMPILING_IN_PYPY - if (!value) { - Py_INCREF(Py_None); - value = Py_None; - } -#endif - PyErr_NormalizeException(&type, &value, &tb); - } else { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; - } - value = type; - type = (PyObject*) Py_TYPE(type); - Py_INCREF(type); - if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto raise_error; - } - } - __Pyx_PyThreadState_assign - __Pyx_ErrRestore(type, value, tb); - return; -raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return; -} -#else -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { - PyObject* owned_instance = NULL; - if (tb == Py_None) { - tb = 0; - } else if (tb && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto bad; - } - if (value == Py_None) - value = 0; - if (PyExceptionInstance_Check(type)) { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto bad; - } - value = type; - type = (PyObject*) Py_TYPE(value); - } else if (PyExceptionClass_Check(type)) { - PyObject *instance_class = NULL; - if (value && PyExceptionInstance_Check(value)) { - instance_class = (PyObject*) Py_TYPE(value); - if (instance_class != type) { - int is_subclass = PyObject_IsSubclass(instance_class, type); - if (!is_subclass) { - instance_class = NULL; - } else if (unlikely(is_subclass == -1)) { - goto bad; - } else { - type = instance_class; - } - } - } - if (!instance_class) { - PyObject *args; - if (!value) - args = PyTuple_New(0); - else if (PyTuple_Check(value)) { - Py_INCREF(value); - args = value; - } else - args = PyTuple_Pack(1, value); - if (!args) - goto bad; - owned_instance = PyObject_Call(type, args, NULL); - Py_DECREF(args); - if (!owned_instance) - goto bad; - value = owned_instance; - if (!PyExceptionInstance_Check(value)) { - PyErr_Format(PyExc_TypeError, - "calling %R should have returned an instance of " - "BaseException, not %R", - type, Py_TYPE(value)); - goto bad; - } - } - } else { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto bad; - } -#if PY_VERSION_HEX >= 0x03030000 - if (cause) { -#else - if (cause && cause != Py_None) { -#endif - PyObject *fixed_cause; - if (cause == Py_None) { - fixed_cause = NULL; - } else if (PyExceptionClass_Check(cause)) { - fixed_cause = PyObject_CallObject(cause, NULL); - if (fixed_cause == NULL) - goto bad; - } else if (PyExceptionInstance_Check(cause)) { - fixed_cause = cause; - Py_INCREF(fixed_cause); - } else { - PyErr_SetString(PyExc_TypeError, - "exception causes must derive from " - "BaseException"); - goto bad; - } - PyException_SetCause(value, fixed_cause); - } - PyErr_SetObject(type, value); - if (tb) { -#if CYTHON_COMPILING_IN_PYPY - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); - Py_INCREF(tb); - PyErr_Restore(tmp_type, tmp_value, tb); - Py_XDECREF(tmp_tb); -#else - PyThreadState *tstate = PyThreadState_GET(); - PyObject* tmp_tb = tstate->curexc_traceback; - if (tb != tmp_tb) { - Py_INCREF(tb); - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_tb); - } -#endif - } -bad: - Py_XDECREF(owned_instance); - return; -} -#endif - -/* GetException */ - #if CYTHON_FAST_THREAD_STATE -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { -#endif - PyObject *local_type, *local_value, *local_tb; -#if CYTHON_FAST_THREAD_STATE - PyObject *tmp_type, *tmp_value, *tmp_tb; - local_type = tstate->curexc_type; - local_value = tstate->curexc_value; - local_tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -#else - PyErr_Fetch(&local_type, &local_value, &local_tb); -#endif - PyErr_NormalizeException(&local_type, &local_value, &local_tb); -#if CYTHON_FAST_THREAD_STATE - if (unlikely(tstate->curexc_type)) -#else - if (unlikely(PyErr_Occurred())) -#endif - goto bad; - #if PY_MAJOR_VERSION >= 3 - if (local_tb) { - if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) - goto bad; - } - #endif - Py_XINCREF(local_tb); - Py_XINCREF(local_type); - Py_XINCREF(local_value); - *type = local_type; - *value = local_value; - *tb = local_tb; -#if CYTHON_FAST_THREAD_STATE - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = local_type; - tstate->exc_value = local_value; - tstate->exc_traceback = local_tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -#else - PyErr_SetExcInfo(local_type, local_value, local_tb); -#endif - return 0; -bad: - *type = 0; - *value = 0; - *tb = 0; - Py_XDECREF(local_type); - Py_XDECREF(local_value); - Py_XDECREF(local_tb); - return -1; -} - -/* SwapException */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = *type; - tstate->exc_value = *value; - tstate->exc_traceback = *tb; - *type = tmp_type; - *value = tmp_value; - *tb = tmp_tb; -} -#else -static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); - PyErr_SetExcInfo(*type, *value, *tb); - *type = tmp_type; - *value = tmp_value; - *tb = tmp_tb; -} -#endif - -/* SaveResetException */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - *type = tstate->exc_type; - *value = tstate->exc_value; - *tb = tstate->exc_traceback; - Py_XINCREF(*type); - Py_XINCREF(*value); - Py_XINCREF(*tb); -} -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = type; - tstate->exc_value = value; - tstate->exc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -#endif - -/* Import */ - static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - #if PY_VERSION_HEX < 0x03030000 - PyObject *py_import; - py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); - if (!py_import) - goto bad; - #endif - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - { - #if PY_MAJOR_VERSION >= 3 - if (level == -1) { - if (strchr(__Pyx_MODULE_NAME, '.')) { - #if PY_VERSION_HEX < 0x03030000 - PyObject *py_level = PyInt_FromLong(1); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, 1); - #endif - if (!module) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - goto bad; - PyErr_Clear(); - } - } - level = 0; - } - #endif - if (!module) { - #if PY_VERSION_HEX < 0x03030000 - PyObject *py_level = PyInt_FromLong(level); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, level); - #endif - } - } -bad: - #if PY_VERSION_HEX < 0x03030000 - Py_XDECREF(py_import); - #endif - Py_XDECREF(empty_list); - Py_XDECREF(empty_dict); - return module; -} - -/* ImportFrom */ - static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { - PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); - if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Format(PyExc_ImportError, - #if PY_MAJOR_VERSION < 3 - "cannot import name %.230s", PyString_AS_STRING(name)); - #else - "cannot import name %S", name); - #endif - } - return value; -} - -/* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { - int start = 0, mid = 0, end = count - 1; - if (end >= 0 && code_line > entries[end].code_line) { - return count; - } - while (start < end) { - mid = start + (end - start) / 2; - if (code_line < entries[mid].code_line) { - end = mid; - } else if (code_line > entries[mid].code_line) { - start = mid + 1; - } else { - return mid; - } - } - if (code_line <= entries[mid].code_line) { - return mid; - } else { - return mid + 1; - } -} -static PyCodeObject *__pyx_find_code_object(int code_line) { - PyCodeObject* code_object; - int pos; - if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { - return NULL; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { - return NULL; - } - code_object = __pyx_code_cache.entries[pos].code_object; - Py_INCREF(code_object); - return code_object; -} -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { - int pos, i; - __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; - if (unlikely(!code_line)) { - return; - } - if (unlikely(!entries)) { - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); - if (likely(entries)) { - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = 64; - __pyx_code_cache.count = 1; - entries[0].code_line = code_line; - entries[0].code_object = code_object; - Py_INCREF(code_object); - } - return; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { - PyCodeObject* tmp = entries[pos].code_object; - entries[pos].code_object = code_object; - Py_DECREF(tmp); - return; - } - if (__pyx_code_cache.count == __pyx_code_cache.max_count) { - int new_max = __pyx_code_cache.max_count + 64; - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( - __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); - if (unlikely(!entries)) { - return; - } - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = new_max; - } - for (i=__pyx_code_cache.count; i>pos; i--) { - entries[i] = entries[i-1]; - } - entries[pos].code_line = code_line; - entries[pos].code_object = code_object; - __pyx_code_cache.count++; - Py_INCREF(code_object); -} - -/* AddTraceback */ - #include "compile.h" -#include "frameobject.h" -#include "traceback.h" -static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( - const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; - #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(filename); - #else - py_srcfile = PyUnicode_FromString(filename); - #endif - if (!py_srcfile) goto bad; - if (c_line) { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #endif - } - else { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromString(funcname); - #else - py_funcname = PyUnicode_FromString(funcname); - #endif - } - if (!py_funcname) goto bad; - py_code = __Pyx_PyCode_New( - 0, - 0, - 0, - 0, - 0, - __pyx_empty_bytes, /*PyObject *code,*/ - __pyx_empty_tuple, /*PyObject *consts,*/ - __pyx_empty_tuple, /*PyObject *names,*/ - __pyx_empty_tuple, /*PyObject *varnames,*/ - __pyx_empty_tuple, /*PyObject *freevars,*/ - __pyx_empty_tuple, /*PyObject *cellvars,*/ - py_srcfile, /*PyObject *filename,*/ - py_funcname, /*PyObject *name,*/ - py_line, - __pyx_empty_bytes /*PyObject *lnotab*/ - ); - Py_DECREF(py_srcfile); - Py_DECREF(py_funcname); - return py_code; -bad: - Py_XDECREF(py_srcfile); - Py_XDECREF(py_funcname); - return NULL; -} -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyFrameObject *py_frame = 0; - py_code = __pyx_find_code_object(c_line ? c_line : py_line); - if (!py_code) { - py_code = __Pyx_CreateCodeObjectForTraceback( - funcname, c_line, py_line, filename); - if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? c_line : py_line, py_code); - } - py_frame = PyFrame_New( - PyThreadState_GET(), /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - __pyx_d, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ - ); - if (!py_frame) goto bad; - __Pyx_PyFrame_SetLineNumber(py_frame, py_line); - PyTraceBack_Here(py_frame); -bad: - Py_XDECREF(py_code); - Py_XDECREF(py_frame); -} - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { - const int neg_one = (int) -1, const_zero = (int) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(int) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(int) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int), - little, !is_unsigned); - } -} - -/* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) -#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) -#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ - {\ - func_type value = func_value;\ - if (sizeof(target_type) < sizeof(func_type)) {\ - if (unlikely(value != (func_type) (target_type) value)) {\ - func_type zero = 0;\ - if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ - return (target_type) -1;\ - if (is_unsigned && unlikely(value < zero))\ - goto raise_neg_overflow;\ - else\ - goto raise_overflow;\ - }\ - }\ - return (target_type) value;\ - } - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { - const long neg_one = (long) -1, const_zero = (long) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(long) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - -/* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { - const int neg_one = (int) -1, const_zero = (int) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (int) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { - return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { - return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { - return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (int) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(int) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) - case -2: - if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - } -#endif - if (sizeof(int) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - int val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (int) -1; - } - } else { - int val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (int) -1; - val = __Pyx_PyInt_As_int(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to int"); - return (int) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; -} - -/* CIntFromPy */ - static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { - const size_t neg_one = (size_t) -1, const_zero = (size_t) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(size_t) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (size_t) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (size_t) 0; - case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0]) - case 2: - if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) { - return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) { - return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) { - return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (size_t) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(size_t) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (size_t) 0; - case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, +digits[0]) - case -2: - if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { - return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { - return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { - return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { - return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { - return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { - return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - } -#endif - if (sizeof(size_t) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - size_t val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (size_t) -1; - } - } else { - size_t val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (size_t) -1; - val = __Pyx_PyInt_As_size_t(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to size_t"); - return (size_t) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to size_t"); - return (size_t) -1; -} - -/* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { - const long neg_one = (long) -1, const_zero = (long) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (long) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { - return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { - return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { - return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (long) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(long) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) - case -2: - if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - } -#endif - if (sizeof(long) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - long val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (long) -1; - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (long) -1; - val = __Pyx_PyInt_As_long(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to long"); - return (long) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long) -1; -} - -/* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { - char ctversion[4], rtversion[4]; - PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); - PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); - if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { - char message[200]; - PyOS_snprintf(message, sizeof(message), - "compiletime version %s of module '%.100s' " - "does not match runtime version %s", - ctversion, __Pyx_MODULE_NAME, rtversion); - return PyErr_WarnEx(NULL, message, 1); - } - return 0; -} - -/* ModuleImport */ - #ifndef __PYX_HAVE_RT_ImportModule -#define __PYX_HAVE_RT_ImportModule -static PyObject *__Pyx_ImportModule(const char *name) { - PyObject *py_name = 0; - PyObject *py_module = 0; - py_name = __Pyx_PyIdentifier_FromString(name); - if (!py_name) - goto bad; - py_module = PyImport_Import(py_name); - Py_DECREF(py_name); - return py_module; -bad: - Py_XDECREF(py_name); - return 0; -} -#endif - -/* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType -#define __PYX_HAVE_RT_ImportType -static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, - size_t size, int strict) -{ - PyObject *py_module = 0; - PyObject *result = 0; - PyObject *py_name = 0; - char warning[200]; - Py_ssize_t basicsize; -#ifdef Py_LIMITED_API - PyObject *py_basicsize; -#endif - py_module = __Pyx_ImportModule(module_name); - if (!py_module) - goto bad; - py_name = __Pyx_PyIdentifier_FromString(class_name); - if (!py_name) - goto bad; - result = PyObject_GetAttr(py_module, py_name); - Py_DECREF(py_name); - py_name = 0; - Py_DECREF(py_module); - py_module = 0; - if (!result) - goto bad; - if (!PyType_Check(result)) { - PyErr_Format(PyExc_TypeError, - "%.200s.%.200s is not a type object", - module_name, class_name); - goto bad; - } -#ifndef Py_LIMITED_API - basicsize = ((PyTypeObject *)result)->tp_basicsize; -#else - py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); - if (!py_basicsize) - goto bad; - basicsize = PyLong_AsSsize_t(py_basicsize); - Py_DECREF(py_basicsize); - py_basicsize = 0; - if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) - goto bad; -#endif - if (!strict && (size_t)basicsize > size) { - PyOS_snprintf(warning, sizeof(warning), - "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd", - module_name, class_name, basicsize, size); - if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; - } - else if ((size_t)basicsize != size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd", - module_name, class_name, basicsize, size); - goto bad; - } - return (PyTypeObject *)result; -bad: - Py_XDECREF(py_module); - Py_XDECREF(result); - return NULL; -} -#endif - -/* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { - while (t->p) { - #if PY_MAJOR_VERSION < 3 - if (t->is_unicode) { - *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); - } else if (t->intern) { - *t->p = PyString_InternFromString(t->s); - } else { - *t->p = PyString_FromStringAndSize(t->s, t->n - 1); - } - #else - if (t->is_unicode | t->is_str) { - if (t->intern) { - *t->p = PyUnicode_InternFromString(t->s); - } else if (t->encoding) { - *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); - } else { - *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); - } - } else { - *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); - } - #endif - if (!*t->p) - return -1; - ++t; - } - return 0; -} - -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { - return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); -} -static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { - Py_ssize_t ignore; - return __Pyx_PyObject_AsStringAndSize(o, &ignore); -} -static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } - } - } -#endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; -#else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } -#else - return PyUnicode_AsUTF8AndSize(o, length); -#endif -#endif - } else -#endif -#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) - if (PyByteArray_Check(o)) { - *length = PyByteArray_GET_SIZE(o); - return PyByteArray_AS_STRING(o); - } else -#endif - { - char* result; - int r = PyBytes_AsStringAndSize(o, &result, length); - if (unlikely(r < 0)) { - return NULL; - } else { - return result; - } - } -} -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { - int is_true = x == Py_True; - if (is_true | (x == Py_False) | (x == Py_None)) return is_true; - else return PyObject_IsTrue(x); -} -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { -#if CYTHON_USE_TYPE_SLOTS - PyNumberMethods *m; -#endif - const char *name = NULL; - PyObject *res = NULL; -#if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) -#else - if (PyLong_Check(x)) -#endif - return __Pyx_NewRef(x); -#if CYTHON_USE_TYPE_SLOTS - m = Py_TYPE(x)->tp_as_number; - #if PY_MAJOR_VERSION < 3 - if (m && m->nb_int) { - name = "int"; - res = PyNumber_Int(x); - } - else if (m && m->nb_long) { - name = "long"; - res = PyNumber_Long(x); - } - #else - if (m && m->nb_int) { - name = "int"; - res = PyNumber_Long(x); - } - #endif -#else - res = PyNumber_Int(x); -#endif - if (res) { -#if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { -#else - if (!PyLong_Check(res)) { -#endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; - } - } - else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, - "an integer is required"); - } - return res; -} -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { - Py_ssize_t ival; - PyObject *x; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(b))) { - if (sizeof(Py_ssize_t) >= sizeof(long)) - return PyInt_AS_LONG(b); - else - return PyInt_AsSsize_t(x); - } -#endif - if (likely(PyLong_CheckExact(b))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)b)->ob_digit; - const Py_ssize_t size = Py_SIZE(b); - if (likely(__Pyx_sst_abs(size) <= 1)) { - ival = likely(size) ? digits[0] : 0; - if (size == -1) ival = -ival; - return ival; - } else { - switch (size) { - case 2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - } - } - #endif - return PyLong_AsSsize_t(b); - } - x = PyNumber_Index(b); - if (!x) return -1; - ival = PyInt_AsSsize_t(x); - Py_DECREF(x); - return ival; -} -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { - return PyInt_FromSize_t(ival); -} - - -#endif /* Py_PYTHON_H */ diff --git a/zarr/blosc.pyx b/zarr/blosc.pyx deleted file mode 100644 index 0dd10018f2..0000000000 --- a/zarr/blosc.pyx +++ /dev/null @@ -1,338 +0,0 @@ -# -*- coding: utf-8 -*- -# cython: embedsignature=True -# cython: profile=False -# cython: linetrace=False -# cython: binding=False -from __future__ import absolute_import, print_function, division -import threading - - -# noinspection PyUnresolvedReferences -from cpython cimport array, PyObject -import array -from cpython.buffer cimport PyObject_GetBuffer, PyBuffer_Release, \ - PyBUF_ANY_CONTIGUOUS, PyBUF_WRITEABLE -from cpython.bytes cimport PyBytes_FromStringAndSize, PyBytes_AS_STRING, \ - _PyBytes_Resize - - -from zarr.compat import PY2, text_type - - -cdef extern from "blosc.h": - cdef enum: - BLOSC_MAX_OVERHEAD, - BLOSC_VERSION_STRING, - BLOSC_VERSION_DATE, - BLOSC_NOSHUFFLE, - BLOSC_SHUFFLE, - BLOSC_BITSHUFFLE, - BLOSC_MAX_BUFFERSIZE, - BLOSC_MAX_THREADS, - BLOSC_MAX_TYPESIZE - - void blosc_init() - void blosc_destroy() - int blosc_get_nthreads() - int blosc_set_nthreads(int nthreads) - int blosc_set_compressor(const char *compname) - char* blosc_list_compressors() - int blosc_compress(int clevel, int doshuffle, size_t typesize, - size_t nbytes, void *src, void *dest, - size_t destsize) nogil - int blosc_decompress(void *src, void *dest, size_t destsize) nogil - int blosc_compname_to_compcode(const char *compname) - int blosc_compress_ctx(int clevel, int doshuffle, size_t typesize, - size_t nbytes, const void* src, void* dest, - size_t destsize, const char* compressor, - size_t blocksize, int numinternalthreads) nogil - int blosc_decompress_ctx(const void *src, void *dest, size_t destsize, - int numinternalthreads) nogil - void blosc_cbuffer_sizes(const void *cbuffer, size_t *nbytes, - size_t *cbytes, size_t *blocksize) - - -MAX_OVERHEAD = BLOSC_MAX_OVERHEAD -MAX_BUFFERSIZE = BLOSC_MAX_BUFFERSIZE -MAX_THREADS = BLOSC_MAX_THREADS -MAX_TYPESIZE = BLOSC_MAX_TYPESIZE -VERSION_STRING = BLOSC_VERSION_STRING -VERSION_DATE = BLOSC_VERSION_DATE -if not PY2: - VERSION_STRING = VERSION_STRING.decode() - VERSION_DATE = VERSION_DATE.decode() -__version__ = VERSION_STRING -NOSHUFFLE = BLOSC_NOSHUFFLE -SHUFFLE = BLOSC_SHUFFLE -BITSHUFFLE = BLOSC_BITSHUFFLE - - -def version(): - return VERSION_STRING, VERSION_DATE - - -def init(): - blosc_init() - - -def destroy(): - blosc_destroy() - - -def compname_to_compcode(cname): - if isinstance(cname, text_type): - cname = cname.encode('ascii') - return blosc_compname_to_compcode(cname) - - -def list_compressors(): - return text_type(blosc_list_compressors(), 'ascii').split(',') - - -def get_nthreads(): - """Get the number of threads that Blosc uses internally for compression - and decompression. - .""" - return blosc_get_nthreads() - - -def set_nthreads(int nthreads): - """Set the number of threads that Blosc uses internally for compression - and decompression. - .""" - return blosc_set_nthreads(nthreads) - - -def cbuffer_sizes(source): - """Return information from the blosc header of some compressed data.""" - cdef: - char *source_ptr - Py_buffer source_buffer - array.array source_array - size_t nbytes, cbytes, blocksize - - # setup source buffer - if PY2 and isinstance(source, array.array): - # workaround fact that array.array does not support new-style buffer - # interface in PY2 - release_source_buffer = False - source_array = source - source_ptr = source_array.data.as_voidptr - else: - release_source_buffer = True - PyObject_GetBuffer(source, &source_buffer, PyBUF_ANY_CONTIGUOUS) - source_ptr = source_buffer.buf - - # determine buffer size - blosc_cbuffer_sizes(source_ptr, &nbytes, &cbytes, &blocksize) - - # release buffers - if release_source_buffer: - PyBuffer_Release(&source_buffer) - - return nbytes, cbytes, blocksize - - -def decompress(source, dest=None): - """Decompress data. - - Parameters - ---------- - source : bytes-like - Compressed data, including blosc header. Can be any object - supporting the buffer protocol. - dest : array-like, optional - Object to decompress into. - - Returns - ------- - dest : array-like - Object containing decompressed data. - - """ - cdef: - int ret - char *source_ptr - char *dest_ptr - Py_buffer source_buffer - array.array source_array - Py_buffer dest_buffer - size_t nbytes, cbytes, blocksize - - # setup source buffer - if PY2 and isinstance(source, array.array): - # workaround fact that array.array does not support new-style buffer - # interface in PY2 - release_source_buffer = False - source_array = source - source_ptr = source_array.data.as_voidptr - else: - release_source_buffer = True - PyObject_GetBuffer(source, &source_buffer, PyBUF_ANY_CONTIGUOUS) - source_ptr = source_buffer.buf - - # determine buffer size - blosc_cbuffer_sizes(source_ptr, &nbytes, &cbytes, &blocksize) - - # setup destination buffer - release_dest_buffer = False - if dest is None: - # allocate memory - dest = PyBytes_FromStringAndSize(NULL, nbytes) - dest_ptr = PyBytes_AS_STRING(dest) - dest_nbytes = nbytes - elif PY2 and isinstance(dest, array.array): - # workaround fact that array.array does not support new-style buffer - # interface in PY2 - dest_array = dest - dest_ptr = dest_array.data.as_voidptr - dest_nbytes = dest_array.buffer_info()[1] * dest_array.itemsize - else: - release_dest_buffer = True - PyObject_GetBuffer(dest, &dest_buffer, - PyBUF_ANY_CONTIGUOUS | PyBUF_WRITEABLE) - dest_ptr = dest_buffer.buf - dest_nbytes = dest_buffer.len - - try: - - # guard condition - if dest_nbytes != nbytes: - raise ValueError('destination buffer has wrong size; expected %s, ' - 'got %s' % (nbytes, dest_nbytes)) - - # perform decompression - if _get_use_threads(): - # allow blosc to use threads internally - with nogil: - ret = blosc_decompress(source_ptr, dest_ptr, nbytes) - else: - with nogil: - ret = blosc_decompress_ctx(source_ptr, dest_ptr, nbytes, 1) - - finally: - - # release buffers - if release_source_buffer: - PyBuffer_Release(&source_buffer) - if release_dest_buffer: - PyBuffer_Release(&dest_buffer) - - # handle errors - if ret <= 0: - raise RuntimeError('error during blosc decompression: %d' % ret) - - return dest - - -def compress(source, char* cname, int clevel, int shuffle): - """Compression. - - Parameters - ---------- - source : bytes-like - Data to be compressed. Can be any object supporting the buffer - protocol. - cname : bytes - Name of compression library to use. - clevel : int - Compression level. - shuffle : int - Shuffle filter. - - Returns - ------- - dest : array - Compressed data. - - """ - - cdef: - char *source_ptr - char *dest_ptr - Py_buffer source_buffer - size_t nbytes, cbytes, itemsize - array.array source_array - bytes dest - - # setup source buffer - if PY2 and isinstance(source, array.array): - # workaround fact that array.array does not support new-style buffer - # interface in PY2 - release_source_buffer = False - source_array = source - source_ptr = source_array.data.as_voidptr - itemsize = source_array.itemsize - nbytes = source_array.buffer_info()[1] * itemsize - else: - release_source_buffer = True - PyObject_GetBuffer(source, &source_buffer, PyBUF_ANY_CONTIGUOUS) - source_ptr = source_buffer.buf - itemsize = source_buffer.itemsize - nbytes = source_buffer.len - - try: - - # setup destination - dest = PyBytes_FromStringAndSize(NULL, nbytes + BLOSC_MAX_OVERHEAD) - dest_ptr = PyBytes_AS_STRING(dest) - - # perform compression - if _get_use_threads(): - # allow blosc to use threads internally - compressor_set = blosc_set_compressor(cname) - if compressor_set < 0: - raise ValueError('compressor not supported: %r' % cname) - with nogil: - cbytes = blosc_compress(clevel, shuffle, itemsize, nbytes, - source_ptr, dest_ptr, - nbytes + BLOSC_MAX_OVERHEAD) - - else: - with nogil: - cbytes = blosc_compress_ctx(clevel, shuffle, itemsize, nbytes, - source_ptr, dest_ptr, - nbytes + BLOSC_MAX_OVERHEAD, cname, - 0, 1) - - finally: - - # release buffers - if release_source_buffer: - PyBuffer_Release(&source_buffer) - - # check compression was successful - if cbytes <= 0: - raise RuntimeError('error during blosc compression: %d' % cbytes) - - # resize after compression - dest = dest[:cbytes] - - return dest - - -# set the value of this variable to True or False to override the -# default adaptive behaviour -use_threads = None - - -def _get_use_threads(): - global use_threads - - if use_threads in [True, False]: - # user has manually overridden the default behaviour - _use_threads = use_threads - - else: - # adaptive behaviour: allow blosc to use threads if it is being - # called from the main Python thread, inferring that it is being run - # from within a single-threaded program; otherwise do not allow - # blosc to use threads, inferring it is being run from within a - # multi-threaded program - if hasattr(threading, 'main_thread'): - _use_threads = (threading.main_thread() == - threading.current_thread()) - else: - _use_threads = threading.current_thread().name == 'MainThread' - - return _use_threads diff --git a/zarr/codecs.py b/zarr/codecs.py index f3bb672742..34230de03d 100644 --- a/zarr/codecs.py +++ b/zarr/codecs.py @@ -1,1004 +1,7 @@ # -*- coding: utf-8 -*- +# flake8: noqa from __future__ import absolute_import, print_function, division -import zlib -import bz2 -import array -import math -import multiprocessing -import atexit -import numpy as np - - -from zarr.compat import text_type, binary_type - - -codec_registry = dict() - - -def get_codec(config): - """Obtain a codec for the given configuration. - - Parameters - ---------- - config : dict-like - Configuration object. - - Returns - ------- - codec : Codec - - """ - codec_id = config.pop('id', None) - cls = codec_registry.get(codec_id, None) - if cls is None: - raise ValueError('codec not available: %r' % codec_id) - return cls.from_config(config) - - -class Codec(object): # pragma: no cover - """Codec abstract base class.""" - - # override in sub-class - id = None - - def encode(self, buf): - """Encode data in `buf`. - - Parameters - ---------- - buf : buffer-like - Data to be encoded. May be any object supporting the new-style - buffer protocol or `array.array`. - - Returns - ------- - enc : buffer-like - Encoded data. May be any object supporting the new-style buffer - protocol or `array.array`. - - """ - # override in sub-class - raise NotImplementedError - - def decode(self, buf, out=None): - """Decode data in `buf`. - - Parameters - ---------- - buf : buffer-like - Encoded data. May be any object supporting the new-style buffer - protocol or `array.array`. - out : buffer-like, optional - Buffer to store decoded data. - - Returns - ------- - out : buffer-like - Decoded data. May be any object supporting the new-style buffer - protocol or `array.array`. - - """ - # override in sub-class - raise NotImplementedError - - def get_config(self): - """Return a dictionary holding configuration parameters for this - codec. All values must be compatible with JSON encoding.""" - # override in sub-class - raise NotImplementedError - - @classmethod - def from_config(cls, config): - """Instantiate from a configuration object.""" - # override if need special decoding of config values - return cls(**config) - - -def _buffer_copy(buf, out=None): - - if out is None: - # no-op - return buf - - # handle ndarray destination - if isinstance(out, np.ndarray): - - # view source as destination dtype - if isinstance(buf, np.ndarray): - buf = buf.view(dtype=out.dtype).reshape(-1, order='A') - else: - buf = np.frombuffer(buf, dtype=out.dtype) - - # ensure shapes are compatible - if buf.shape != out.shape: - if out.flags.f_contiguous: - order = 'F' - else: - order = 'C' - buf = buf.reshape(out.shape, order=order) - - # copy via numpy - np.copyto(out, buf) - - # handle generic buffer destination - else: - - # obtain memoryview of destination - dest = memoryview(out) - - # ensure source is 1D - if isinstance(buf, np.ndarray): - buf = buf.reshape(-1, order='A') - # try to match itemsize - dtype = 'u%s' % dest.itemsize - buf = buf.view(dtype=dtype) - - # try to copy via memoryview - dest[:] = buf - - return out - - -class Zlib(Codec): - """Provides compression using zlib via the Python standard library. - - Parameters - ---------- - level : int - Compression level. - - """ - - codec_id = 'zlib' - - def __init__(self, level=1): - self.level = level - - def encode(self, buf): - - # if numpy array, can only handle C contiguous directly - if isinstance(buf, np.ndarray) and not buf.flags.c_contiguous: - buf = buf.tobytes(order='A') - - # do compression - return zlib.compress(buf, self.level) - - # noinspection PyMethodMayBeStatic - def decode(self, buf, out=None): - - # do decompression - dec = zlib.decompress(buf) - - # handle destination - return _buffer_copy(dec, out) - - def get_config(self): - config = dict() - config['id'] = self.codec_id - config['level'] = self.level - return config - - def __repr__(self): - r = '%s(level=%s)' % (type(self).__name__, self.level) - return r - - -codec_registry[Zlib.codec_id] = Zlib -codec_registry['gzip'] = Zlib # alias - - -class BZ2(Codec): - """Provides compression using bzip2 via the Python standard library. - - Parameters - ---------- - level : int - Compression level. - - """ - - codec_id = 'bz2' - - def __init__(self, level=1): - self.level = level - - def encode(self, buf): - - # if numpy array, can only handle C contiguous directly - if isinstance(buf, np.ndarray) and not buf.flags.c_contiguous: - buf = buf.tobytes(order='A') - - # do compression - return bz2.compress(buf, self.level) - - # noinspection PyMethodMayBeStatic - def decode(self, buf, out=None): - - # BZ2 cannot handle ndarray directly at all, coerce everything to - # memoryview - if not isinstance(buf, array.array): - buf = memoryview(buf) - - # do decompression - dec = bz2.decompress(buf) - - # handle destination - return _buffer_copy(dec, out) - - def get_config(self): - config = dict() - config['id'] = self.codec_id - config['level'] = self.level - return config - - def __repr__(self): - r = '%s(level=%s)' % (type(self).__name__, self.level) - return r - - -codec_registry[BZ2.codec_id] = BZ2 - - -lzma = None -try: - import lzma -except ImportError: # pragma: no cover - try: - from backports import lzma - except ImportError: - pass - -if lzma: - - # noinspection PyShadowingBuiltins - class LZMA(Codec): - """Provides compression using lzma via the Python standard library - (only available under Python 3). - - Parameters - ---------- - format : integer, optional - One of the lzma format codes, e.g., ``lzma.FORMAT_XZ``. - check : integer, optional - One of the lzma check codes, e.g., ``lzma.CHECK_NONE``. - preset : integer, optional - An integer between 0 and 9 inclusive, specifying the compression - level. - filters : list, optional - A list of dictionaries specifying compression filters. If - filters are provided, 'preset' must be None. - - """ - - codec_id = 'lzma' - - def __init__(self, format=1, check=-1, preset=None, filters=None): - self.format = format - self.check = check - self.preset = preset - self.filters = filters - - def encode(self, buf): - - # if numpy array, can only handle C contiguous directly - if isinstance(buf, np.ndarray) and not buf.flags.c_contiguous: - buf = buf.tobytes(order='A') - - # do compression - return lzma.compress(buf, format=self.format, check=self.check, - preset=self.preset, filters=self.filters) - - def decode(self, buf, out=None): - - # setup filters - if self.format == lzma.FORMAT_RAW: - # filters needed - filters = self.filters - else: - # filters should not be specified - filters = None - - # do decompression - dec = lzma.decompress(buf, format=self.format, filters=filters) - - # handle destination - return _buffer_copy(dec, out) - - def get_config(self): - config = dict() - config['id'] = self.codec_id - config['format'] = self.format - config['check'] = self.check - config['preset'] = self.preset - config['filters'] = self.filters - return config - - def __repr__(self): - r = '%s(format=%r, check=%r, preset=%r, filters=%r)' % \ - (type(self).__name__, self.format, self.check, self.preset, - self.filters) - return r - - codec_registry[LZMA.codec_id] = LZMA - -try: - from zarr import blosc -except ImportError: # pragma: no cover - pass -else: - - class Blosc(Codec): - """Provides compression using the blosc meta-compressor. - - Parameters - ---------- - cname : string, optional - A string naming one of the compression algorithms available - within blosc, e.g., 'blosclz', 'lz4', 'zlib' or 'snappy'. - clevel : integer, optional - An integer between 0 and 9 specifying the compression level. - shuffle : integer, optional - Either 0 (no shuffle), 1 (byte shuffle) or 2 (bit shuffle). - - """ - - codec_id = 'blosc' - - def __init__(self, cname='lz4', clevel=5, shuffle=1): - if isinstance(cname, text_type): - cname = cname.encode('ascii') - self.cname = cname - self.clevel = clevel - self.shuffle = shuffle - - def encode(self, buf): - return blosc.compress(buf, self.cname, self.clevel, self.shuffle) - - def decode(self, buf, out=None): - return blosc.decompress(buf, out) - - def get_config(self): - config = dict() - config['id'] = self.codec_id - config['cname'] = text_type(self.cname, 'ascii') - config['clevel'] = self.clevel - config['shuffle'] = self.shuffle - return config - - def __repr__(self): - r = '%s(cname=%r, clevel=%r, shuffle=%r)' % \ - (type(self).__name__, text_type(self.cname, 'ascii'), - self.clevel, self.shuffle) - return r - - codec_registry[Blosc.codec_id] = Blosc - - # initialize blosc - ncores = multiprocessing.cpu_count() - blosc.init() - blosc.set_nthreads(min(8, ncores)) - atexit.register(blosc.destroy) - - -def _ndarray_from_buffer(buf, dtype): - if isinstance(buf, np.ndarray): - arr = buf.reshape(-1, order='A').view(dtype) - else: - arr = np.frombuffer(buf, dtype=dtype) - return arr - - -class Delta(Codec): - """Filter to encode data as the difference between adjacent values. - - Parameters - ---------- - dtype : dtype - Data type to use for decoded data. - astype : dtype, optional - Data type to use for encoded data. - - Notes - ----- - If `astype` is an integer data type, please ensure that it is - sufficiently large to store encoded values. No checks are made and data - may become corrupted due to integer overflow if `astype` is too small. - Note also that the encoded data for each chunk includes the absolute - value of the first element in the chunk, and so the encoded data type in - general needs to be large enough to store absolute values from the array. - - Examples - -------- - >>> import zarr - >>> import numpy as np - >>> x = np.arange(100, 120, 2, dtype='i8') - >>> f = zarr.Delta(dtype='i8', astype='i1') - >>> y = f.encode(x) - >>> y - array([100, 2, 2, 2, 2, 2, 2, 2, 2, 2], dtype=int8) - >>> z = f.decode(y) - >>> z - array([100, 102, 104, 106, 108, 110, 112, 114, 116, 118]) - - """ # flake8: noqa - - codec_id = 'delta' - - def __init__(self, dtype, astype=None): - self.dtype = np.dtype(dtype) - if astype is None: - self.astype = self.dtype - else: - self.astype = np.dtype(astype) - - def encode(self, buf): - - # view input data as 1D array - arr = _ndarray_from_buffer(buf, self.dtype) - - # setup encoded output - enc = np.empty_like(arr, dtype=self.astype) - - # set first element - enc[0] = arr[0] - - # compute differences - enc[1:] = np.diff(arr) - - return enc - - def decode(self, buf, out=None): - - # view encoded data as 1D array - enc = _ndarray_from_buffer(buf, self.astype) - - # setup decoded output - if isinstance(out, np.ndarray): - # optimization, can decode directly to out - dec = out.reshape(-1, order='A') - copy_needed = False - else: - dec = np.empty_like(enc, dtype=self.dtype) - copy_needed = True - - # decode differences - np.cumsum(enc, out=dec) - - # handle output - if copy_needed: - out = _buffer_copy(dec, out) - - return out - - def get_config(self): - config = dict() - config['id'] = self.codec_id - config['dtype'] = self.dtype.str - config['astype'] = self.astype.str - return config - - def __repr__(self): - r = '%s(dtype=%s' % (type(self).__name__, self.dtype) - if self.astype != self.dtype: - r += ', astype=%s' % self.astype - r += ')' - return r - - -codec_registry[Delta.codec_id] = Delta - - -class AsType(Codec): - """Filter to convert data between different types. - - Parameters - ---------- - encode_dtype : dtype - Data type to use for encoded data. - decode_dtype : dtype, optional - Data type to use for decoded data. - - Notes - ----- - If `encode_dtype` is of lower precision than `decode_dtype`, please be - aware that data loss can occur by writing data to disk using this filter. - No checks are made to ensure the casting will work in that direction and - data corruption will occur. - - Examples - -------- - >>> import zarr - >>> import numpy as np - >>> x = np.arange(100, 120, 2, dtype=np.int8) - >>> x - array([100, 102, 104, 106, 108, 110, 112, 114, 116, 118], dtype=int8) - >>> f = zarr.AsType(encode_dtype=x.dtype, decode_dtype=np.int64) - >>> y = f.decode(x) - >>> y - array([100, 102, 104, 106, 108, 110, 112, 114, 116, 118]) - >>> z = f.encode(y) - >>> z - array([100, 102, 104, 106, 108, 110, 112, 114, 116, 118], dtype=int8) - - """ # flake8: noqa - - codec_id = 'astype' - - def __init__(self, encode_dtype, decode_dtype): - self.encode_dtype = np.dtype(encode_dtype) - self.decode_dtype = np.dtype(decode_dtype) - - def encode(self, buf): - - # view input data as 1D array - arr = _ndarray_from_buffer(buf, self.decode_dtype) - - # convert and copy - enc = arr.astype(self.encode_dtype) - - return enc - - def decode(self, buf, out=None): - - # view encoded data as 1D array - enc = _ndarray_from_buffer(buf, self.encode_dtype) - - # convert and copy - dec = enc.astype(self.decode_dtype) - - # handle output - out = _buffer_copy(dec, out) - - return out - - def get_config(self): - config = dict() - config['id'] = self.codec_id - config['encode_dtype'] = self.encode_dtype.str - config['decode_dtype'] = self.decode_dtype.str - return config - - def __repr__(self): - return ( - '%s(encode_dtype=%r, decode_dtype=%r)' % ( - type(self).__name__, - self.encode_dtype.str, - self.decode_dtype.str - ) - ) - - -codec_registry[AsType.codec_id] = AsType - - -class FixedScaleOffset(Codec): - """Simplified version of the scale-offset filter available in HDF5. - Applies the transformation `(x - offset) * scale` to all chunks. Results - are rounded to the nearest integer but are not packed according to the - minimum number of bits. - - Parameters - ---------- - offset : float - Value to subtract from data. - scale : int - Value to multiply by data. - dtype : dtype - Data type to use for decoded data. - astype : dtype, optional - Data type to use for encoded data. - - Notes - ----- - If `astype` is an integer data type, please ensure that it is - sufficiently large to store encoded values. No checks are made and data - may become corrupted due to integer overflow if `astype` is too small. - - Examples - -------- - >>> import zarr - >>> import numpy as np - >>> x = np.linspace(1000, 1001, 10, dtype='f8') - >>> x - array([ 1000. , 1000.11111111, 1000.22222222, 1000.33333333, - 1000.44444444, 1000.55555556, 1000.66666667, 1000.77777778, - 1000.88888889, 1001. ]) - >>> f1 = zarr.FixedScaleOffset(offset=1000, scale=10, dtype='f8', astype='u1') - >>> y1 = f1.encode(x) - >>> y1 - array([ 0, 1, 2, 3, 4, 6, 7, 8, 9, 10], dtype=uint8) - >>> z1 = f1.decode(y1) - >>> z1 - array([ 1000. , 1000.1, 1000.2, 1000.3, 1000.4, 1000.6, 1000.7, - 1000.8, 1000.9, 1001. ]) - >>> f2 = zarr.FixedScaleOffset(offset=1000, scale=10**2, dtype='f8', astype='u1') - >>> y2 = f2.encode(x) - >>> y2 - array([ 0, 11, 22, 33, 44, 56, 67, 78, 89, 100], dtype=uint8) - >>> z2 = f2.decode(y2) - >>> z2 - array([ 1000. , 1000.11, 1000.22, 1000.33, 1000.44, 1000.56, - 1000.67, 1000.78, 1000.89, 1001. ]) - >>> f3 = zarr.FixedScaleOffset(offset=1000, scale=10**3, dtype='f8', astype='u2') - >>> y3 = f3.encode(x) - >>> y3 - array([ 0, 111, 222, 333, 444, 556, 667, 778, 889, 1000], dtype=uint16) - >>> z3 = f3.decode(y3) - >>> z3 - array([ 1000. , 1000.111, 1000.222, 1000.333, 1000.444, 1000.556, - 1000.667, 1000.778, 1000.889, 1001. ]) - - """ # flake8: noqa - - codec_id = 'fixedscaleoffset' - - def __init__(self, offset, scale, dtype, astype=None): - self.offset = offset - self.scale = scale - self.dtype = np.dtype(dtype) - if astype is None: - self.astype = self.dtype - else: - self.astype = np.dtype(astype) - - def encode(self, buf): - - # interpret buffer as 1D array - arr = _ndarray_from_buffer(buf, self.dtype) - - # compute scale offset - enc = (arr - self.offset) * self.scale - - # round to nearest integer - enc = np.around(enc) - - # convert dtype - enc = enc.astype(self.astype, copy=False) - - return enc - - def decode(self, buf, out=None): - - # interpret buffer as 1D array - enc = _ndarray_from_buffer(buf, self.astype) - - # decode scale offset - dec = (enc / self.scale) + self.offset - - # convert dtype - dec = dec.astype(self.dtype, copy=False) - - # handle output - return _buffer_copy(dec, out) - - def get_config(self): - config = dict() - config['id'] = self.codec_id - config['astype'] = self.astype.str - config['dtype'] = self.dtype.str - config['scale'] = self.scale - config['offset'] = self.offset - return config - - def __repr__(self): - r = '%s(scale=%s, offset=%s, dtype=%s' % \ - (type(self).__name__, self.scale, self.offset, self.dtype) - if self.astype != self.dtype: - r += ', astype=%s' % self.astype - r += ')' - return r - -codec_registry[FixedScaleOffset.codec_id] = FixedScaleOffset - - -class Quantize(Codec): - """Lossy filter to reduce the precision of floating point data. - - Parameters - ---------- - digits : int - Desired precision (number of decimal digits). - dtype : dtype - Data type to use for decoded data. - astype : dtype, optional - Data type to use for encoded data. - - Examples - -------- - >>> import zarr - >>> import numpy as np - >>> x = np.linspace(0, 1, 10, dtype='f8') - >>> x - array([ 0. , 0.11111111, 0.22222222, 0.33333333, 0.44444444, - 0.55555556, 0.66666667, 0.77777778, 0.88888889, 1. ]) - >>> f1 = zarr.Quantize(digits=1, dtype='f8') - >>> y1 = f1.encode(x) - >>> y1 - array([ 0. , 0.125 , 0.25 , 0.3125, 0.4375, 0.5625, 0.6875, - 0.75 , 0.875 , 1. ]) - >>> f2 = zarr.Quantize(digits=2, dtype='f8') - >>> y2 = f2.encode(x) - >>> y2 - array([ 0. , 0.109375 , 0.21875 , 0.3359375, 0.4453125, - 0.5546875, 0.6640625, 0.78125 , 0.890625 , 1. ]) - >>> f3 = zarr.Quantize(digits=3, dtype='f8') - >>> y3 = f3.encode(x) - >>> y3 - array([ 0. , 0.11132812, 0.22265625, 0.33300781, 0.44433594, - 0.55566406, 0.66699219, 0.77734375, 0.88867188, 1. ]) - - """ - - codec_id = 'quantize' - - def __init__(self, digits, dtype, astype=None): - self.digits = digits - self.dtype = np.dtype(dtype) - if astype is None: - self.astype = self.dtype - else: - self.astype = np.dtype(astype) - if self.dtype.kind != 'f' or self.astype.kind != 'f': - raise ValueError('only floating point data types are supported') - - def encode(self, buf): - - # interpret buffer as 1D array - arr = _ndarray_from_buffer(buf, self.dtype) - - # apply scaling - precision = 10. ** -self.digits - exp = math.log(precision, 10) - if exp < 0: - exp = int(math.floor(exp)) - else: - exp = int(math.ceil(exp)) - bits = math.ceil(math.log(10. ** -exp, 2)) - scale = 2. ** bits - enc = np.around(scale * arr) / scale - - # cast dtype - enc = enc.astype(self.astype, copy=False) - - return enc - - def decode(self, buf, out=None): - # filter is lossy, decoding is no-op - dec = _ndarray_from_buffer(buf, self.astype) - dec = dec.astype(self.dtype, copy=False) - return _buffer_copy(dec, out) - - def get_config(self): - config = dict() - config['id'] = self.codec_id - config['digits'] = self.digits - config['dtype'] = self.dtype.str - config['astype'] = self.astype.str - return config - - def __repr__(self): - r = '%s(digits=%s, dtype=%s' % \ - (type(self).__name__, self.digits, self.dtype) - if self.astype != self.dtype: - r += ', astype=%s' % self.astype - r += ')' - return r - - -codec_registry[Quantize.codec_id] = Quantize - - -class PackBits(Codec): - """Filter to pack elements of a boolean array into bits in a uint8 array. - - Examples - -------- - >>> import zarr - >>> import numpy as np - >>> f = zarr.PackBits() - >>> x = np.array([True, False, False, True], dtype=bool) - >>> y = f.encode(x) - >>> y - array([ 4, 144], dtype=uint8) - >>> z = f.decode(y) - >>> z - array([ True, False, False, True], dtype=bool) - - Notes - ----- - The first element of the encoded array stores the number of bits that - were padded to complete the final byte. - - """ - - codec_id = 'packbits' - - def __init__(self): - pass - - def encode(self, buf): - - # view input as ndarray - arr = _ndarray_from_buffer(buf, bool) - - # determine size of packed data - n = arr.size - n_bytes_packed = (n // 8) - n_bits_leftover = n % 8 - if n_bits_leftover > 0: - n_bytes_packed += 1 - - # setup output - enc = np.empty(n_bytes_packed + 1, dtype='u1') - - # store how many bits were padded - if n_bits_leftover: - n_bits_padded = 8 - n_bits_leftover - else: - n_bits_padded = 0 - enc[0] = n_bits_padded - - # apply encoding - enc[1:] = np.packbits(arr) - - return enc - - def decode(self, buf, out=None): - - # view encoded data as ndarray - enc = _ndarray_from_buffer(buf, 'u1') - - # find out how many bits were padded - n_bits_padded = int(enc[0]) - - # apply decoding - dec = np.unpackbits(enc[1:]) - - # remove padded bits - if n_bits_padded: - dec = dec[:-n_bits_padded] - - # view as boolean array - dec = dec.view(bool) - - # handle destination - return _buffer_copy(dec, out) - - def get_config(self): - config = dict() - config['id'] = self.codec_id - return config - - def __repr__(self): - r = '%s()' % type(self).__name__ - return r - - -codec_registry[PackBits.codec_id] = PackBits - - -def _ensure_bytes(l): - if isinstance(l, binary_type): - return l - elif isinstance(l, text_type): - return l.encode('ascii') - else: - raise ValueError('expected bytes, found %r' % l) - - -def _ensure_text(l): - if isinstance(l, text_type): - return l - elif isinstance(l, binary_type): - return text_type(l, 'ascii') - else: - raise ValueError('expected text, found %r' % l) - - -class Categorize(Codec): - """Filter encoding categorical string data as integers. - - Parameters - ---------- - labels : sequence of strings - Category labels. - dtype : dtype - Data type to use for decoded data. - astype : dtype, optional - Data type to use for encoded data. - - Examples - -------- - >>> import zarr - >>> import numpy as np - >>> x = np.array([b'male', b'female', b'female', b'male', b'unexpected']) - >>> x - array([b'male', b'female', b'female', b'male', b'unexpected'], - dtype='|S10') - >>> f = zarr.Categorize(labels=[b'female', b'male'], dtype=x.dtype) - >>> y = f.encode(x) - >>> y - array([2, 1, 1, 2, 0], dtype=uint8) - >>> z = f.decode(y) - >>> z - array([b'male', b'female', b'female', b'male', b''], - dtype='|S10') - - """ - - codec_id = 'categorize' - - def __init__(self, labels, dtype, astype='u1'): - self.dtype = np.dtype(dtype) - if self.dtype.kind == 'S': - self.labels = [_ensure_bytes(l) for l in labels] - elif self.dtype.kind == 'U': - self.labels = [_ensure_text(l) for l in labels] - else: - raise ValueError('data type not supported') - self.astype = np.dtype(astype) - - def encode(self, buf): - - # view input as ndarray - arr = _ndarray_from_buffer(buf, self.dtype) - - # setup output array - enc = np.zeros_like(arr, dtype=self.astype) - - # apply encoding, reserving 0 for values not specified in labels - for i, l in enumerate(self.labels): - enc[arr == l] = i + 1 - - return enc - - def decode(self, buf, out=None): - - # view encoded data as ndarray - enc = _ndarray_from_buffer(buf, self.astype) - - # setup output - if isinstance(out, np.ndarray): - # optimization, decode directly to output - dec = out.reshape(-1, order='A') - copy_needed = False - else: - dec = np.zeros_like(enc, dtype=self.dtype) - copy_needed = True - - # apply decoding - for i, l in enumerate(self.labels): - dec[enc == (i + 1)] = l - - # handle output - if copy_needed: - dec = _buffer_copy(dec, out) - - return dec - - def get_config(self): - config = dict() - config['id'] = self.codec_id - config['labels'] = [_ensure_text(l) for l in self.labels] - config['dtype'] = self.dtype.str - config['astype'] = self.astype.str - return config - - def __repr__(self): - # make sure labels part is not too long - labels = repr(self.labels[:3]) - if len(self.labels) > 3: - labels = labels[:-1] + ', ...]' - r = '%s(dtype=%s, astype=%s, labels=%s)' % \ - (type(self).__name__, self.dtype, self.astype, labels) - return r - - -codec_registry[Categorize.codec_id] = Categorize - - -__all__ = ['get_codec', 'codec_registry'] -for _cls in codec_registry.values(): - __all__.append(_cls.__name__) +from numcodecs import * +from numcodecs.registry import codec_registry diff --git a/zarr/core.py b/zarr/core.py index 6203fa7950..b7f416d3f8 100644 --- a/zarr/core.py +++ b/zarr/core.py @@ -384,7 +384,7 @@ def __getitem__(self, item): >>> z Array((100000000,), int32, chunks=(1000000,), order=C) nbytes: 381.5M; nbytes_stored: 6.4M; ratio: 59.9; initialized: 100/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: dict Take some slices:: @@ -408,8 +408,8 @@ def __getitem__(self, item): ... chunks=(1000, 1000), dtype='i4') >>> z Array((10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 9.2M; ratio: 41.6; initialized: 100/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 381.5M; nbytes_stored: 9.2M; ratio: 41.5; initialized: 100/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: dict Take some slices:: @@ -506,8 +506,8 @@ def __setitem__(self, item, value): >>> z = zarr.zeros(100000000, chunks=1000000, dtype='i4') >>> z Array((100000000,), int32, chunks=(1000000,), order=C) - nbytes: 381.5M; nbytes_stored: 301; ratio: 1328903.7; initialized: 0/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 381.5M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: dict Set all array elements to the same scalar value:: @@ -528,8 +528,8 @@ def __setitem__(self, item, value): >>> z = zarr.zeros((10000, 10000), chunks=(1000, 1000), dtype='i4') >>> z Array((10000, 10000), int32, chunks=(1000, 1000), order=C) - nbytes: 381.5M; nbytes_stored: 323; ratio: 1238390.1; initialized: 0/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 381.5M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: dict Set all array elements to the same scalar value:: @@ -890,23 +890,14 @@ def resize(self, *args): -------- >>> import zarr >>> z = zarr.zeros(shape=(10000, 10000), chunks=(1000, 1000)) - >>> z - Array((10000, 10000), float64, chunks=(1000, 1000), order=C) - nbytes: 762.9M; nbytes_stored: 323; ratio: 2476780.2; initialized: 0/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) - store: dict + >>> z.shape + (10000, 10000) >>> z.resize(20000, 10000) - >>> z - Array((20000, 10000), float64, chunks=(1000, 1000), order=C) - nbytes: 1.5G; nbytes_stored: 323; ratio: 4953560.4; initialized: 0/200 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) - store: dict + >>> z.shape + (20000, 10000) >>> z.resize(30000, 1000) - >>> z - Array((30000, 1000), float64, chunks=(1000, 1000), order=C) - nbytes: 228.9M; nbytes_stored: 322; ratio: 745341.6; initialized: 0/30 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) - store: dict + >>> z.shape + (30000, 1000) Notes ----- @@ -972,25 +963,15 @@ def append(self, data, axis=0): >>> import zarr >>> a = np.arange(10000000, dtype='i4').reshape(10000, 1000) >>> z = zarr.array(a, chunks=(1000, 100)) - >>> z - Array((10000, 1000), int32, chunks=(1000, 100), order=C) - nbytes: 38.1M; nbytes_stored: 1.9M; ratio: 20.3; initialized: 100/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) - store: dict + >>> z.shape + (10000, 1000) >>> z.append(a) (20000, 1000) - >>> z - Array((20000, 1000), int32, chunks=(1000, 100), order=C) - nbytes: 76.3M; nbytes_stored: 3.8M; ratio: 20.3; initialized: 200/200 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) - store: dict >>> z.append(np.vstack([a, a]), axis=1) (20000, 2000) >>> z Array((20000, 2000), int32, chunks=(1000, 100), order=C) - nbytes: 152.6M; nbytes_stored: 7.5M; ratio: 20.3; initialized: 400/400 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) - store: dict + ... """ return self._write_op(self._append_nosync, data, axis=axis) diff --git a/zarr/creation.py b/zarr/creation.py index 1812e11a80..0b28a23f25 100644 --- a/zarr/creation.py +++ b/zarr/creation.py @@ -9,7 +9,7 @@ from zarr.core import Array from zarr.storage import DirectoryStore, init_array, contains_array, \ contains_group, default_compressor, normalize_storage_path -from zarr.codecs import codec_registry +from numcodecs.registry import codec_registry from zarr.errors import err_contains_array, err_contains_group, \ err_array_not_found @@ -67,10 +67,49 @@ def create(shape, chunks=None, dtype=None, compressor='default', >>> z = zarr.create((10000, 10000), chunks=(1000, 1000)) >>> z Array((10000, 10000), float64, chunks=(1000, 1000), order=C) - nbytes: 762.9M; nbytes_stored: 323; ratio: 2476780.2; initialized: 0/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 762.9M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: dict + Create an array with different some different configuration options:: + + >>> from numcodecs import Blosc + >>> z = zarr.create((10000, 10000), chunks=(1000, 1000), dtype='i1', order='F', + ... compressor=Blosc(cname='zstd', clevel=1, shuffle=Blosc.BITSHUFFLE)) + >>> z + Array((10000, 10000), int8, chunks=(1000, 1000), order=F) + nbytes: 95.4M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + compressor: Blosc(cname='zstd', clevel=1, shuffle=BITSHUFFLE, blocksize=0) + store: dict + + To create an array with object dtype requires a filter that can handle Python object encoding, + e.g., `MsgPack` or `Pickle` from `numcodecs`:: + + >>> from numcodecs import MsgPack + >>> z = zarr.create((10000, 10000), chunks=(1000, 1000), dtype='object', + ... filters=[MsgPack()]) + >>> z + Array((10000, 10000), object, chunks=(1000, 1000), order=C) + nbytes: 762.9M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + filters: MsgPack(encoding='utf-8') + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) + store: dict + + Example with some filters, and also storing chunks separately from metadata:: + + >>> from numcodecs import Quantize, Adler32 + >>> store, chunk_store = dict(), dict() + >>> z = zarr.create((10000, 10000), chunks=(1000, 1000), dtype='f8', + ... filters=[Quantize(digits=2, dtype='f8'), Adler32()], + ... store=store, chunk_store=chunk_store) + >>> z + Array((10000, 10000), float64, chunks=(1000, 1000), order=C) + nbytes: 762.9M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + filters: Quantize(digits=2, dtype='>> z = zarr.zeros((10000, 10000), chunks=(1000, 1000)) >>> z Array((10000, 10000), float64, chunks=(1000, 1000), order=C) - nbytes: 762.9M; nbytes_stored: 323; ratio: 2476780.2; initialized: 0/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 762.9M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: dict >>> z[:2, :2] array([[ 0., 0.], @@ -208,8 +247,8 @@ def ones(shape, **kwargs): >>> z = zarr.ones((10000, 10000), chunks=(1000, 1000)) >>> z Array((10000, 10000), float64, chunks=(1000, 1000), order=C) - nbytes: 762.9M; nbytes_stored: 323; ratio: 2476780.2; initialized: 0/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 762.9M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: dict >>> z[:2, :2] array([[ 1., 1.], @@ -232,8 +271,8 @@ def full(shape, fill_value, **kwargs): >>> z = zarr.full((10000, 10000), chunks=(1000, 1000), fill_value=42) >>> z Array((10000, 10000), float64, chunks=(1000, 1000), order=C) - nbytes: 762.9M; nbytes_stored: 324; ratio: 2469135.8; initialized: 0/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 762.9M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: dict >>> z[:2, :2] array([[ 42., 42.], @@ -279,7 +318,7 @@ def array(data, **kwargs): >>> z Array((10000, 10000), int64, chunks=(1000, 1000), order=C) nbytes: 762.9M; nbytes_stored: 15.2M; ratio: 50.2; initialized: 100/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: dict """ # flake8: noqa @@ -366,13 +405,13 @@ def open_array(store=None, mode='a', shape=None, chunks=None, dtype=None, >>> z1 Array((10000, 10000), float64, chunks=(1000, 1000), order=C) nbytes: 762.9M; nbytes_stored: 23.0M; ratio: 33.2; initialized: 100/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: DirectoryStore >>> z2 = zarr.open_array('example.zarr', mode='r') >>> z2 Array((10000, 10000), float64, chunks=(1000, 1000), order=C) nbytes: 762.9M; nbytes_stored: 23.0M; ratio: 33.2; initialized: 100/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: DirectoryStore >>> np.all(z1[:] == z2[:]) True diff --git a/zarr/hierarchy.py b/zarr/hierarchy.py index fbf853bcf8..42f9b93c0b 100644 --- a/zarr/hierarchy.py +++ b/zarr/hierarchy.py @@ -31,7 +31,7 @@ class Group(MutableMapping): read_only : bool, optional True if group should be protected against modification. chunk_store : MutableMapping, optional - Separate storage for chunks. If not provided, `store` will be used + Separate storage for chunks. If not provided, `store` will be used for storage of both chunks and metadata. synchronizer : object, optional Array synchronizer. @@ -142,7 +142,7 @@ def read_only(self): @property def chunk_store(self): - """A MutableMapping providing the underlying storage for array + """A MutableMapping providing the underlying storage for array chunks.""" return self._chunk_store @@ -291,8 +291,8 @@ def __getitem__(self, item): store: DictStore >>> g1['foo/bar/baz'] Array(/foo/bar/baz, (100,), float64, chunks=(10,), order=C) - nbytes: 800; nbytes_stored: 290; ratio: 2.8; initialized: 0/10 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 800; nbytes_stored: ...; ratio: ...; initialized: 0/10 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: DictStore """ # flake8: noqa @@ -690,8 +690,8 @@ def create_dataset(self, name, **kwargs): ... chunks=(1000, 1000)) >>> d1 Array(/foo, (10000, 10000), float64, chunks=(1000, 1000), order=C) - nbytes: 762.9M; nbytes_stored: 323; ratio: 2476780.2; initialized: 0/100 - compressor: Blosc(cname='lz4', clevel=5, shuffle=1) + nbytes: 762.9M; nbytes_stored: ...; ratio: ...; initialized: 0/100 + compressor: Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0) store: DictStore """ # flake8: noqa diff --git a/zarr/storage.py b/zarr/storage.py index c337b21214..38c6f883e4 100644 --- a/zarr/storage.py +++ b/zarr/storage.py @@ -16,7 +16,7 @@ normalize_storage_path, buffer_size from zarr.meta import encode_array_metadata, encode_group_metadata from zarr.compat import PY2, binary_type -from zarr.codecs import codec_registry +from numcodecs.registry import codec_registry from zarr.errors import err_contains_group, err_contains_array, \ err_path_not_found, err_bad_compressor, err_fspath_exists_notdir, \ err_read_only @@ -188,6 +188,7 @@ def init_array(store, shape, chunks=None, dtype=None, compressor='default', 1000 ], "compressor": { + "blocksize": 0, "clevel": 5, "cname": "lz4", "id": "blosc", @@ -222,6 +223,7 @@ def init_array(store, shape, chunks=None, dtype=None, compressor='default', 1000000 ], "compressor": { + "blocksize": 0, "clevel": 5, "cname": "lz4", "id": "blosc", diff --git a/zarr/tests/test_codecs.py b/zarr/tests/test_codecs.py deleted file mode 100644 index 80547e7bbb..0000000000 --- a/zarr/tests/test_codecs.py +++ /dev/null @@ -1,538 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, division -import unittest -import itertools -import array - - -import numpy as np -from numpy.testing import assert_array_equal, assert_array_almost_equal, \ - assert_raises -from nose.tools import eq_ as eq - - -from zarr.codecs import codec_registry, get_codec -from zarr.util import buffer_tobytes -from zarr.compat import PY2 -from zarr import blosc - - -class CodecTests(object): - - # override in sub-class - codec_id = None - - def init_codec(self, **kwargs): - codec_cls = codec_registry[self.codec_id] - codec = codec_cls(**kwargs) - return codec - - def _test_encode(self, arr, **kwargs): - - # setup - codec = self.init_codec(**kwargs) - - # encoding should support any object exporting the buffer protocol, - # as well as array.array in PY2 - - # test encoding of numpy array - buf = arr - enc = codec.encode(buf) - enc_bytes = buffer_tobytes(enc) - - # test encoding of raw bytes - buf = arr.tobytes(order='A') - enc = codec.encode(buf) - actual = buffer_tobytes(enc) - eq(enc_bytes, actual) - - # test encoding of array.array - buf = array.array('b', arr.tobytes(order='A')) - enc = codec.encode(buf) - actual = buffer_tobytes(enc) - eq(enc_bytes, actual) - - def _test_decode_lossless(self, arr, **kwargs): - if arr.flags.f_contiguous: - order = 'F' - else: - order = 'C' - - # setup - codec = self.init_codec(**kwargs) - - # encode - enc = codec.encode(arr) - enc_bytes = buffer_tobytes(enc) - - # decoding should support any object exporting the buffer protocol, - # as well as array.array in PY2 - - # test decoding of raw bytes - buf = enc_bytes - dec = codec.decode(buf) - dec = np.frombuffer(dec, dtype=arr.dtype).reshape(arr.shape, - order=order) - assert_array_equal(arr, dec) - - # test decoding of array.array - buf = array.array('b', enc_bytes) - dec = codec.decode(buf) - dec = np.frombuffer(dec, dtype=arr.dtype).reshape(arr.shape, - order=order) - assert_array_equal(arr, dec) - - # test decoding of numpy array - buf = np.frombuffer(enc_bytes, dtype='u1') - dec = codec.decode(buf) - dec = np.frombuffer(dec, dtype=arr.dtype).reshape(arr.shape, - order=order) - assert_array_equal(arr, dec) - - # test decoding into numpy array - out = np.empty_like(arr) - codec.decode(enc_bytes, out=out) - assert_array_equal(arr, out) - - # test decoding into bytearray - out = bytearray(arr.nbytes) - codec.decode(enc_bytes, out=out) - expect = arr.tobytes(order='A') - eq(expect, out) - - def _test_decode_lossy(self, arr, decimal, **kwargs): - if arr.flags.f_contiguous: - order = 'F' - else: - order = 'C' - - # setup - codec = self.init_codec(**kwargs) - - # encode - enc = codec.encode(arr) - enc_bytes = buffer_tobytes(enc) - - # decoding should support any object exporting the buffer protocol, - # as well as array.array in PY2 - - # test decoding of raw bytes - buf = enc_bytes - dec = codec.decode(buf) - dec = np.frombuffer(dec, dtype=arr.dtype).reshape(arr.shape, - order=order) - assert_array_almost_equal(arr, dec, decimal=decimal) - - # test decoding of array.array - buf = array.array('b', enc_bytes) - dec = codec.decode(buf) - dec = np.frombuffer(dec, dtype=arr.dtype).reshape(arr.shape, - order=order) - assert_array_almost_equal(arr, dec, decimal=decimal) - - # test decoding of numpy array - buf = np.frombuffer(enc_bytes, dtype='u1') - dec = codec.decode(buf) - dec = np.frombuffer(dec, dtype=arr.dtype).reshape(arr.shape, - order=order) - assert_array_almost_equal(arr, dec, decimal=decimal) - - # test decoding into numpy array - out = np.empty_like(arr) - codec.decode(enc_bytes, out=out) - assert_array_almost_equal(arr, out, decimal=decimal) - - # test decoding into bytearray - out = bytearray(arr.nbytes) - codec.decode(enc_bytes, out=out) - out = np.frombuffer(out, dtype=arr.dtype).reshape(arr.shape, - order=order) - assert_array_almost_equal(arr, out, decimal=decimal) - - -test_arrays = [ - np.arange(1000, dtype='i4'), - np.linspace(1000, 1001, 1000, dtype='f8'), - np.random.normal(loc=1000, scale=1, size=(100, 10)), - np.random.randint(0, 2, size=1000, dtype=bool).reshape(100, 10, order='F'), - np.random.choice([b'a', b'bb', b'ccc'], size=1000).reshape(10, 10, 10) -] - - -class TestZlib(CodecTests, unittest.TestCase): - - codec_id = 'zlib' - - configs = [ - dict(), - dict(level=-1), - dict(level=0), - dict(level=1), - dict(level=5), - dict(level=9), - ] - - def test_encode(self): - for arr, config in itertools.product(test_arrays, self.configs): - self._test_encode(arr, **config) - - def test_decode(self): - for arr, config in itertools.product(test_arrays, self.configs): - self._test_decode_lossless(arr, **config) - - -class TestBZ2(CodecTests, unittest.TestCase): - - codec_id = 'bz2' - - configs = [ - dict(), - dict(level=1), - dict(level=5), - dict(level=9), - ] - - def test_encode(self): - for arr, config in itertools.product(test_arrays, self.configs): - self._test_encode(arr, **config) - - def test_decode(self): - for arr, config in itertools.product(test_arrays, self.configs): - self._test_decode_lossless(arr, **config) - - -lzma = None -try: - import lzma -except ImportError: # pragma: no cover - try: - from backports import lzma - except ImportError: - pass - -if lzma: - - class TestLZMA(CodecTests, unittest.TestCase): - - codec_id = 'lzma' - - configs = [ - dict(), - dict(preset=1), - dict(preset=5), - dict(preset=9), - dict(format=lzma.FORMAT_RAW, - filters=[dict(id=lzma.FILTER_LZMA2, preset=1)]) - ] - - def test_encode(self): - for arr, config in itertools.product(test_arrays, self.configs): - self._test_encode(arr, **config) - - def test_decode(self): - for arr, config in itertools.product(test_arrays, self.configs): - self._test_decode_lossless(arr, **config) - - -class TestBlosc(CodecTests, unittest.TestCase): - - codec_id = 'blosc' - - configs = [ - dict(), - dict(clevel=0), - dict(cname='lz4'), - dict(cname='lz4', clevel=1, shuffle=blosc.NOSHUFFLE), - dict(cname='lz4', clevel=1, shuffle=blosc.SHUFFLE), - dict(cname='lz4', clevel=1, shuffle=blosc.BITSHUFFLE), - dict(cname='zlib', clevel=1, shuffle=0), - dict(cname='zstd', clevel=1, shuffle=1), - dict(cname='blosclz', clevel=1, shuffle=2), - dict(cname='snappy', clevel=1, shuffle=2), - ] - - def test_encode(self): - - # N.B., watch out here with blosc compressor, if the itemsize of - # the source buffer is different then the results of compression - # may be different. - - for arr, config in itertools.product(test_arrays, self.configs): - if arr.dtype.itemsize == 1: - self._test_encode(arr, **config) - - def test_decode(self): - for arr, config in itertools.product(test_arrays, self.configs): - self._test_decode_lossless(arr, **config) - - -class TestDelta(CodecTests, unittest.TestCase): - - codec_id = 'delta' - - def test_encode(self): - for arr in test_arrays: - if arr.dtype.kind in {'f', 'i', 'u'}: - self._test_encode(arr, dtype=arr.dtype) - - def test_decode(self): - for arr in test_arrays: - if arr.dtype.kind == 'f': - self._test_decode_lossy(arr, decimal=10, dtype=arr.dtype) - elif arr.dtype.kind in {'i', 'u'}: - self._test_decode_lossless(arr, dtype=arr.dtype) - - def test_encode_output(self): - dtype = 'i8' - astype = 'i4' - codec = self.init_codec(dtype=dtype, astype=astype) - arr = np.arange(10, 20, 1, dtype=dtype) - expect = np.array([10] + ([1] * 9), dtype=astype) - actual = codec.encode(arr) - assert_array_equal(expect, actual) - eq(np.dtype(astype), actual.dtype) - - def test_repr(self): - codec = self.init_codec(dtype='i8', astype='i4') - expect = 'Delta(dtype=int64, astype=int32)' - actual = repr(codec) - eq(expect, actual) - - -class TestAsType(CodecTests, unittest.TestCase): - - codec_id = 'astype' - - def test_encode(self): - for arr in test_arrays: - if arr.dtype.kind in {'f', 'i', 'u'}: - self._test_encode( - arr, - encode_dtype=arr.dtype, - decode_dtype=arr.dtype - ) - - def test_decode(self): - for arr in test_arrays: - if arr.dtype.kind == 'f': - self._test_decode_lossy( - arr, - decimal=10, - encode_dtype=arr.dtype, - decode_dtype=arr.dtype - ) - elif arr.dtype.kind in {'i', 'u'}: - self._test_decode_lossless( - arr, encode_dtype=arr.dtype, decode_dtype=arr.dtype - ) - - def test_encode_output(self): - encode_dtype = 'i4' - decode_dtype = 'i8' - codec = self.init_codec( - encode_dtype=encode_dtype, decode_dtype=decode_dtype - ) - arr = np.arange(10, 20, 1, dtype=decode_dtype) - expect = arr.astype(encode_dtype) - actual = codec.encode(arr) - assert_array_equal(expect, actual) - eq(np.dtype(encode_dtype), actual.dtype) - - def test_decode_input(self): - encode_dtype = 'i4' - decode_dtype = 'i8' - codec = self.init_codec( - encode_dtype=encode_dtype, decode_dtype=decode_dtype - ) - arr = np.arange(10, 20, 1, dtype=encode_dtype) - expect = arr.astype(decode_dtype) - actual = codec.decode(arr) - assert_array_equal(expect, actual) - eq(np.dtype(decode_dtype), actual.dtype) - - def test_repr(self): - codec = self.init_codec(encode_dtype='i4', decode_dtype='i8') - expect = "AsType(encode_dtype='