|
6 | 6 | import threading |
7 | 7 | import multiprocessing |
8 | 8 | import os |
9 | | -from deprecated import deprecated |
10 | 9 |
|
11 | 10 |
|
12 | 11 | from cpython.buffer cimport PyBUF_ANY_CONTIGUOUS, PyBUF_WRITEABLE |
@@ -45,7 +44,6 @@ cdef extern from "blosc.h": |
45 | 44 | void* src, void* dest, size_t destsize) nogil |
46 | 45 | int blosc_decompress(void *src, void *dest, size_t destsize) nogil |
47 | 46 | int blosc_getitem(void* src, int start, int nitems, void* dest) |
48 | | - int blosc_compname_to_compcode(const char* compname) |
49 | 47 | int blosc_compress_ctx(int clevel, int doshuffle, size_t typesize, size_t nbytes, |
50 | 48 | const void* src, void* dest, size_t destsize, |
51 | 49 | const char* compressor, size_t blocksize, |
@@ -100,28 +98,12 @@ def _init(): |
100 | 98 | """Initialize the Blosc library environment.""" |
101 | 99 | blosc_init() |
102 | 100 |
|
103 | | -init = deprecated(_init) |
104 | | - |
105 | 101 |
|
106 | 102 | def _destroy(): |
107 | 103 | """Destroy the Blosc library environment.""" |
108 | 104 | blosc_destroy() |
109 | 105 |
|
110 | 106 |
|
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 | | - |
124 | | - |
125 | 107 | def list_compressors(): |
126 | 108 | """Get a list of compressors supported in the current build.""" |
127 | 109 | s = blosc_list_compressors() |
@@ -168,7 +150,6 @@ def _cbuffer_sizes(source): |
168 | 150 |
|
169 | 151 | return nbytes, cbytes, blocksize |
170 | 152 |
|
171 | | -cbuffer_sizes = deprecated(_cbuffer_sizes) |
172 | 153 |
|
173 | 154 | def cbuffer_complib(source): |
174 | 155 | """Return the name of the compression library used to compress `source`.""" |
@@ -226,13 +207,10 @@ def _cbuffer_metainfo(source): |
226 | 207 |
|
227 | 208 | return typesize, shuffle, memcpyed |
228 | 209 |
|
229 | | -cbuffer_metainfo = deprecated(_cbuffer_metainfo) |
230 | | - |
231 | 210 | def _err_bad_cname(cname): |
232 | 211 | raise ValueError('bad compressor or compressor not supported: %r; expected one of ' |
233 | 212 | '%s' % (cname, list_compressors())) |
234 | 213 |
|
235 | | -err_bad_cname = deprecated(_err_bad_cname) |
236 | 214 |
|
237 | 215 | def compress(source, char* cname, int clevel, int shuffle=SHUFFLE, |
238 | 216 | int blocksize=AUTOBLOCKS): |
@@ -415,82 +393,6 @@ def decompress(source, dest=None): |
415 | 393 |
|
416 | 394 | return dest |
417 | 395 |
|
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 | | - |
494 | 396 | # set the value of this variable to True or False to override the |
495 | 397 | # default adaptive behaviour |
496 | 398 | use_threads = None |
@@ -584,11 +486,6 @@ class Blosc(Codec): |
584 | 486 | buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) |
585 | 487 | return decompress(buf, out) |
586 | 488 |
|
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 | | - |
592 | 489 | def __repr__(self): |
593 | 490 | r = '%s(cname=%r, clevel=%r, shuffle=%s, blocksize=%s)' % \ |
594 | 491 | (type(self).__name__, |
|
0 commit comments