Skip to content

Commit d9f20de

Browse files
committed
Remove deprecated blosc code
1 parent a2bdbe5 commit d9f20de

File tree

4 files changed

+24
-175
lines changed

4 files changed

+24
-175
lines changed

docs/release.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ Release notes
1717
Unreleased
1818
----------
1919

20+
Removals
21+
~~~~~~~~
22+
23+
The following ``blosc`` funcitons are removed, with no replacement.
24+
This is because they were not intended to be public API.
25+
26+
- ``numcodecs.blosc.init``
27+
- ``numcodecs.blosc.destroy``
28+
- ``numcodecs.blosc.compname_to_compcode``
29+
- ``numcodecs.blosc.cbuffer_sizes``
30+
- ``numcodecs.blosc.cbuffer_metainfo``
31+
32+
In addition, ``numcodecs.blosc.decompress_partial`` is removed as
33+
has always been experimental and there is no equivalent in the official
34+
blsoc Python package.
35+
By :user:`David Stansby <dstansby>`, :issue:`712`
36+
37+
0.15.1
38+
------
39+
2040
Improvements
2141
~~~~~~~~~~~~
2242
* Raise a custom `UnknownCodecError` when trying to retrieve an unavailable codec.
@@ -52,7 +72,7 @@ This is because they are not intended to be public API.
5272
In addition, ``numcodecs.blosc.decompress_partial`` is deprecated as
5373
has always been experimental and there is no equivalent in the official
5474
blsoc Python package.
55-
By :user:`David Stansby <dstansby>`, :issue`619`
75+
By :user:`David Stansby <dstansby>`, :issue:`619`
5676

5777
Fixes
5878
~~~~~

numcodecs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
ncores = 1
5252
blosc._init()
5353
blosc.set_nthreads(min(8, ncores))
54-
atexit.register(blosc.destroy)
54+
atexit.register(blosc._destroy)
5555

5656
from numcodecs import zstd as zstd
5757
from numcodecs.zstd import Zstd

numcodecs/blosc.pyx

Lines changed: 0 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import threading
77
import multiprocessing
88
import os
9-
from deprecated import deprecated
109

1110

1211
from cpython.buffer cimport PyBUF_ANY_CONTIGUOUS, PyBUF_WRITEABLE
@@ -45,7 +44,6 @@ cdef extern from "blosc.h":
4544
void* src, void* dest, size_t destsize) nogil
4645
int blosc_decompress(void *src, void *dest, size_t destsize) nogil
4746
int blosc_getitem(void* src, int start, int nitems, void* dest)
48-
int blosc_compname_to_compcode(const char* compname)
4947
int blosc_compress_ctx(int clevel, int doshuffle, size_t typesize, size_t nbytes,
5048
const void* src, void* dest, size_t destsize,
5149
const char* compressor, size_t blocksize,
@@ -100,28 +98,12 @@ def _init():
10098
"""Initialize the Blosc library environment."""
10199
blosc_init()
102100

103-
init = deprecated(_init)
104-
105101

106102
def _destroy():
107103
"""Destroy the Blosc library environment."""
108104
blosc_destroy()
109105

110106

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-
125107
def list_compressors():
126108
"""Get a list of compressors supported in the current build."""
127109
s = blosc_list_compressors()
@@ -141,35 +123,6 @@ def set_nthreads(int nthreads):
141123
return blosc_set_nthreads(nthreads)
142124

143125

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-
173126
def cbuffer_complib(source):
174127
"""Return the name of the compression library used to compress `source`."""
175128
cdef:
@@ -189,50 +142,10 @@ def cbuffer_complib(source):
189142
return complib
190143

191144

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-
231145
def _err_bad_cname(cname):
232146
raise ValueError('bad compressor or compressor not supported: %r; expected one of '
233147
'%s' % (cname, list_compressors()))
234148

235-
err_bad_cname = deprecated(_err_bad_cname)
236149

237150
def compress(source, char* cname, int clevel, int shuffle=SHUFFLE,
238151
int blocksize=AUTOBLOCKS):
@@ -415,82 +328,6 @@ def decompress(source, dest=None):
415328

416329
return dest
417330

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-
494331
# set the value of this variable to True or False to override the
495332
# default adaptive behaviour
496333
use_threads = None
@@ -584,11 +421,6 @@ class Blosc(Codec):
584421
buf = ensure_contiguous_ndarray(buf, self.max_buffer_size)
585422
return decompress(buf, out)
586423

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-
592424
def __repr__(self):
593425
r = '%s(cname=%r, clevel=%r, shuffle=%s, blocksize=%s)' % \
594426
(type(self).__name__,

pyproject.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ name = "numcodecs"
1313
description = """
1414
A Python package providing buffer compression and transformation codecs \
1515
for use in data storage and communication applications."""
16-
readme = "README.rst"
17-
dependencies = [
18-
"numpy>=1.24",
19-
"deprecated"
20-
]
16+
readme = "README.rst"
17+
dependencies = ["numpy>=1.24"]
2118
requires-python = ">=3.11"
2219
dynamic = [
2320
"version",

0 commit comments

Comments
 (0)