|
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.bytes cimport PyBytes_AS_STRING, PyBytes_FromStringAndSize |
@@ -44,7 +43,6 @@ cdef extern from "blosc.h": |
44 | 43 | void* src, void* dest, size_t destsize) nogil |
45 | 44 | int blosc_decompress(void *src, void *dest, size_t destsize) nogil |
46 | 45 | int blosc_getitem(void* src, int start, int nitems, void* dest) |
47 | | - int blosc_compname_to_compcode(const char* compname) |
48 | 46 | int blosc_compress_ctx(int clevel, int doshuffle, size_t typesize, size_t nbytes, |
49 | 47 | const void* src, void* dest, size_t destsize, |
50 | 48 | const char* compressor, size_t blocksize, |
@@ -99,28 +97,12 @@ def _init(): |
99 | 97 | """Initialize the Blosc library environment.""" |
100 | 98 | blosc_init() |
101 | 99 |
|
102 | | -init = deprecated(_init) |
103 | | - |
104 | 100 |
|
105 | 101 | def _destroy(): |
106 | 102 | """Destroy the Blosc library environment.""" |
107 | 103 | blosc_destroy() |
108 | 104 |
|
109 | 105 |
|
110 | | -destroy = deprecated(_destroy) |
111 | | - |
112 | | - |
113 | | -def _compname_to_compcode(cname): |
114 | | - """Return the compressor code associated with the compressor name. If the compressor |
115 | | - name is not recognized, or there is not support for it in this build, -1 is returned |
116 | | - instead.""" |
117 | | - if isinstance(cname, str): |
118 | | - cname = cname.encode('ascii') |
119 | | - return blosc_compname_to_compcode(cname) |
120 | | - |
121 | | -compname_to_compcode = deprecated(_compname_to_compcode) |
122 | | - |
123 | | - |
124 | 106 | def list_compressors(): |
125 | 107 | """Get a list of compressors supported in the current build.""" |
126 | 108 | s = blosc_list_compressors() |
@@ -166,7 +148,6 @@ def _cbuffer_sizes(source): |
166 | 148 |
|
167 | 149 | return nbytes, cbytes, blocksize |
168 | 150 |
|
169 | | -cbuffer_sizes = deprecated(_cbuffer_sizes) |
170 | 151 |
|
171 | 152 | def cbuffer_complib(source): |
172 | 153 | """Return the name of the compression library used to compress `source`.""" |
@@ -222,13 +203,10 @@ def _cbuffer_metainfo(source): |
222 | 203 |
|
223 | 204 | return typesize, shuffle, memcpyed |
224 | 205 |
|
225 | | -cbuffer_metainfo = deprecated(_cbuffer_metainfo) |
226 | | - |
227 | 206 | def _err_bad_cname(cname): |
228 | 207 | raise ValueError('bad compressor or compressor not supported: %r; expected one of ' |
229 | 208 | '%s' % (cname, list_compressors())) |
230 | 209 |
|
231 | | -err_bad_cname = deprecated(_err_bad_cname) |
232 | 210 |
|
233 | 211 | def compress(source, char* cname, int clevel, int shuffle=SHUFFLE, |
234 | 212 | int blocksize=AUTOBLOCKS, typesize=None): |
@@ -423,86 +401,6 @@ def decompress(source, dest=None): |
423 | 401 | return dest |
424 | 402 |
|
425 | 403 |
|
426 | | -def _decompress_partial(source, start, nitems, dest=None): |
427 | | - """**Experimental** |
428 | | - Decompress data of only a part of a buffer. |
429 | | -
|
430 | | - Parameters |
431 | | - ---------- |
432 | | - source : bytes-like |
433 | | - Compressed data, including blosc header. Can be any object supporting the buffer |
434 | | - protocol. |
435 | | - start: int, |
436 | | - Offset in item where we want to start decoding |
437 | | - nitems: int |
438 | | - Number of items we want to decode |
439 | | - dest : array-like, optional |
440 | | - Object to decompress into. |
441 | | -
|
442 | | -
|
443 | | - Returns |
444 | | - ------- |
445 | | - dest : bytes |
446 | | - Object containing decompressed data. |
447 | | -
|
448 | | - """ |
449 | | - cdef: |
450 | | - int ret |
451 | | - int encoding_size |
452 | | - int nitems_bytes |
453 | | - int start_bytes |
454 | | - memoryview source_mv |
455 | | - const Py_buffer* source_pb |
456 | | - const char* source_ptr |
457 | | - memoryview dest_mv |
458 | | - Py_buffer* dest_pb |
459 | | - char* dest_ptr |
460 | | - size_t dest_nbytes |
461 | | - |
462 | | - # obtain source memoryview |
463 | | - source_mv = ensure_continguous_memoryview(source) |
464 | | - source_pb = PyMemoryView_GET_BUFFER(source_mv) |
465 | | - |
466 | | - # setup source pointer |
467 | | - source_ptr = <const char*>source_pb.buf |
468 | | - |
469 | | - # get encoding size from source buffer header |
470 | | - encoding_size = source[3] |
471 | | - |
472 | | - # convert variables to handle type and encoding sizes |
473 | | - nitems_bytes = nitems * encoding_size |
474 | | - start_bytes = (start * encoding_size) |
475 | | - |
476 | | - # setup destination buffer |
477 | | - if dest is None: |
478 | | - # allocate memory |
479 | | - dest_1d = dest = PyBytes_FromStringAndSize(NULL, nitems_bytes) |
480 | | - else: |
481 | | - dest_1d = ensure_contiguous_ndarray(dest) |
482 | | - |
483 | | - # obtain dest memoryview |
484 | | - dest_mv = memoryview(dest_1d) |
485 | | - dest_pb = PyMemoryView_GET_BUFFER(dest_mv) |
486 | | - dest_ptr = <char*>dest_pb.buf |
487 | | - dest_nbytes = dest_pb.len |
488 | | - |
489 | | - # try decompression |
490 | | - try: |
491 | | - if dest_nbytes < nitems_bytes: |
492 | | - raise ValueError('destination buffer too small; expected at least %s, ' |
493 | | - 'got %s' % (nitems_bytes, dest_nbytes)) |
494 | | - ret = blosc_getitem(source_ptr, start, nitems, dest_ptr) |
495 | | - finally: |
496 | | - pass |
497 | | - |
498 | | - # ret refers to the number of bytes returned from blosc_getitem. |
499 | | - if ret <= 0: |
500 | | - raise RuntimeError('error during blosc partial decompression: %d', ret) |
501 | | - |
502 | | - return dest |
503 | | - |
504 | | -decompress_partial = deprecated(_decompress_partial) |
505 | | - |
506 | 404 | # set the value of this variable to True or False to override the |
507 | 405 | # default adaptive behaviour |
508 | 406 | use_threads = None |
@@ -601,11 +499,6 @@ class Blosc(Codec): |
601 | 499 | buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) |
602 | 500 | return decompress(buf, out) |
603 | 501 |
|
604 | | - def decode_partial(self, buf, int start, int nitems, out=None): |
605 | | - '''**Experimental**''' |
606 | | - buf = ensure_contiguous_ndarray(buf, self.max_buffer_size) |
607 | | - return _decompress_partial(buf, start, nitems, dest=out) |
608 | | - |
609 | 502 | def __repr__(self): |
610 | 503 | r = '%s(cname=%r, clevel=%r, shuffle=%s, blocksize=%s)' % \ |
611 | 504 | (type(self).__name__, |
|
0 commit comments