Skip to content

Commit 5372a7e

Browse files
committed
Remove deprecated blosc code
1 parent a2bdbe5 commit 5372a7e

File tree

2 files changed

+0
-198
lines changed

2 files changed

+0
-198
lines changed

numcodecs/blosc.pyx

Lines changed: 0 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ cdef extern from "blosc.h":
4545
void* src, void* dest, size_t destsize) nogil
4646
int blosc_decompress(void *src, void *dest, size_t destsize) nogil
4747
int blosc_getitem(void* src, int start, int nitems, void* dest)
48-
int blosc_compname_to_compcode(const char* compname)
4948
int blosc_compress_ctx(int clevel, int doshuffle, size_t typesize, size_t nbytes,
5049
const void* src, void* dest, size_t destsize,
5150
const char* compressor, size_t blocksize,
@@ -100,27 +99,6 @@ def _init():
10099
"""Initialize the Blosc library environment."""
101100
blosc_init()
102101

103-
init = deprecated(_init)
104-
105-
106-
def _destroy():
107-
"""Destroy the Blosc library environment."""
108-
blosc_destroy()
109-
110-
111-
destroy = deprecated(_destroy)
112-
113-
114-
def _compname_to_compcode(cname):
115-
"""Return the compressor code associated with the compressor name. If the compressor
116-
name is not recognized, or there is not support for it in this build, -1 is returned
117-
instead."""
118-
if isinstance(cname, str):
119-
cname = cname.encode('ascii')
120-
return blosc_compname_to_compcode(cname)
121-
122-
compname_to_compcode = deprecated(_compname_to_compcode)
123-
124102

125103
def list_compressors():
126104
"""Get a list of compressors supported in the current build."""
@@ -141,35 +119,6 @@ def set_nthreads(int nthreads):
141119
return blosc_set_nthreads(nthreads)
142120

143121

144-
def _cbuffer_sizes(source):
145-
"""Return information about a compressed buffer, namely the number of uncompressed
146-
bytes (`nbytes`) and compressed (`cbytes`). It also returns the `blocksize` (which
147-
is used internally for doing the compression by blocks).
148-
149-
Returns
150-
-------
151-
nbytes : int
152-
cbytes : int
153-
blocksize : int
154-
155-
"""
156-
cdef:
157-
Buffer buffer
158-
size_t nbytes, cbytes, blocksize
159-
160-
# obtain buffer
161-
buffer = Buffer(source, PyBUF_ANY_CONTIGUOUS)
162-
163-
# determine buffer size
164-
blosc_cbuffer_sizes(buffer.ptr, &nbytes, &cbytes, &blocksize)
165-
166-
# release buffers
167-
buffer.release()
168-
169-
return nbytes, cbytes, blocksize
170-
171-
cbuffer_sizes = deprecated(_cbuffer_sizes)
172-
173122
def cbuffer_complib(source):
174123
"""Return the name of the compression library used to compress `source`."""
175124
cdef:
@@ -189,45 +138,6 @@ def cbuffer_complib(source):
189138
return complib
190139

191140

192-
def _cbuffer_metainfo(source):
193-
"""Return some meta-information about the compressed buffer in `source`, including
194-
the typesize, whether the shuffle or bit-shuffle filters were used, and the
195-
whether the buffer was memcpyed.
196-
197-
Returns
198-
-------
199-
typesize
200-
shuffle
201-
memcpyed
202-
203-
"""
204-
cdef:
205-
Buffer buffer
206-
size_t typesize
207-
int flags
208-
209-
# obtain buffer
210-
buffer = Buffer(source, PyBUF_ANY_CONTIGUOUS)
211-
212-
# determine buffer size
213-
blosc_cbuffer_metainfo(buffer.ptr, &typesize, &flags)
214-
215-
# release buffers
216-
buffer.release()
217-
218-
# decompose flags
219-
if flags & BLOSC_DOSHUFFLE:
220-
shuffle = SHUFFLE
221-
elif flags & BLOSC_DOBITSHUFFLE:
222-
shuffle = BITSHUFFLE
223-
else:
224-
shuffle = NOSHUFFLE
225-
memcpyed = flags & BLOSC_MEMCPYED
226-
227-
return typesize, shuffle, memcpyed
228-
229-
cbuffer_metainfo = deprecated(_cbuffer_metainfo)
230-
231141
def _err_bad_cname(cname):
232142
raise ValueError('bad compressor or compressor not supported: %r; expected one of '
233143
'%s' % (cname, list_compressors()))
@@ -415,82 +325,6 @@ def decompress(source, dest=None):
415325

416326
return dest
417327

418-
419-
def _decompress_partial(source, start, nitems, dest=None):
420-
"""**Experimental**
421-
Decompress data of only a part of a buffer.
422-
423-
Parameters
424-
----------
425-
source : bytes-like
426-
Compressed data, including blosc header. Can be any object supporting the buffer
427-
protocol.
428-
start: int,
429-
Offset in item where we want to start decoding
430-
nitems: int
431-
Number of items we want to decode
432-
dest : array-like, optional
433-
Object to decompress into.
434-
435-
436-
Returns
437-
-------
438-
dest : bytes
439-
Object containing decompressed data.
440-
441-
"""
442-
cdef:
443-
int ret
444-
int encoding_size
445-
int nitems_bytes
446-
int start_bytes
447-
char *source_ptr
448-
char *dest_ptr
449-
Buffer source_buffer
450-
Buffer dest_buffer = None
451-
452-
# setup source buffer
453-
source_buffer = Buffer(source, PyBUF_ANY_CONTIGUOUS)
454-
source_ptr = source_buffer.ptr
455-
456-
# get encoding size from source buffer header
457-
encoding_size = source[3]
458-
459-
# convert variables to handle type and encoding sizes
460-
nitems_bytes = nitems * encoding_size
461-
start_bytes = (start * encoding_size)
462-
463-
# setup destination buffer
464-
if dest is None:
465-
dest = PyBytes_FromStringAndSize(NULL, nitems_bytes)
466-
dest_ptr = PyBytes_AS_STRING(dest)
467-
dest_nbytes = nitems_bytes
468-
else:
469-
arr = ensure_contiguous_ndarray(dest)
470-
dest_buffer = Buffer(arr, PyBUF_ANY_CONTIGUOUS | PyBUF_WRITEABLE)
471-
dest_ptr = dest_buffer.ptr
472-
dest_nbytes = dest_buffer.nbytes
473-
474-
# try decompression
475-
try:
476-
if dest_nbytes < nitems_bytes:
477-
raise ValueError('destination buffer too small; expected at least %s, '
478-
'got %s' % (nitems_bytes, dest_nbytes))
479-
ret = blosc_getitem(source_ptr, start, nitems, dest_ptr)
480-
481-
finally:
482-
source_buffer.release()
483-
if dest_buffer is not None:
484-
dest_buffer.release()
485-
486-
# ret refers to the number of bytes returned from blosc_getitem.
487-
if ret <= 0:
488-
raise RuntimeError('error during blosc partial decompression: %d', ret)
489-
490-
return dest
491-
492-
decompress_partial = deprecated(_decompress_partial)
493-
494328
# set the value of this variable to True or False to override the
495329
# default adaptive behaviour
496330
use_threads = None
@@ -584,11 +418,6 @@ class Blosc(Codec):
584418
buf = ensure_contiguous_ndarray(buf, self.max_buffer_size)
585419
return decompress(buf, out)
586420

587-
def decode_partial(self, buf, int start, int nitems, out=None):
588-
'''**Experimental**'''
589-
buf = ensure_contiguous_ndarray(buf, self.max_buffer_size)
590-
return _decompress_partial(buf, start, nitems, dest=out)
591-
592421
def __repr__(self):
593422
r = '%s(cname=%r, clevel=%r, shuffle=%s, blocksize=%s)' % \
594423
(type(self).__name__,

numcodecs/tests/test_blosc.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -117,33 +117,6 @@ def test_eq():
117117
assert Blosc(cname='lz4') != 'foo'
118118

119119

120-
def test_compress_blocksize_default(use_threads):
121-
arr = np.arange(1000, dtype='i4')
122-
123-
blosc.use_threads = use_threads
124-
125-
# default blocksize
126-
enc = blosc.compress(arr, b'lz4', 1, Blosc.NOSHUFFLE)
127-
_, _, blocksize = blosc._cbuffer_sizes(enc)
128-
assert blocksize > 0
129-
130-
# explicit default blocksize
131-
enc = blosc.compress(arr, b'lz4', 1, Blosc.NOSHUFFLE, 0)
132-
_, _, blocksize = blosc._cbuffer_sizes(enc)
133-
assert blocksize > 0
134-
135-
136-
@pytest.mark.parametrize('bs', [2**7, 2**8])
137-
def test_compress_blocksize(use_threads, bs):
138-
arr = np.arange(1000, dtype='i4')
139-
140-
blosc.use_threads = use_threads
141-
142-
enc = blosc.compress(arr, b'lz4', 1, Blosc.NOSHUFFLE, bs)
143-
_, _, blocksize = blosc._cbuffer_sizes(enc)
144-
assert blocksize == bs
145-
146-
147120
def test_compress_complib(use_threads):
148121
arr = np.arange(1000, dtype='i4')
149122
expected_complibs = {

0 commit comments

Comments
 (0)