Skip to content

Commit b6f6461

Browse files
committed
Deprecate blosc helper functions
1 parent e3299b8 commit b6f6461

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

docs/compression/blosc.rst

-6
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,9 @@ Blosc
1818
Helper functions
1919
----------------
2020

21-
.. autofunction:: init
22-
.. autofunction:: destroy
23-
.. autofunction:: compname_to_compcode
2421
.. autofunction:: list_compressors
2522
.. autofunction:: get_nthreads
2623
.. autofunction:: set_nthreads
27-
.. autofunction:: cbuffer_sizes
2824
.. autofunction:: cbuffer_complib
29-
.. autofunction:: cbuffer_metainfo
3025
.. autofunction:: compress
3126
.. autofunction:: decompress
32-
.. autofunction:: decompress_partial

numcodecs/blosc.pyx

+18-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import threading
77
import multiprocessing
88
import os
9+
from deprecated import deprecated
910

1011

1112
from cpython.buffer cimport PyBUF_ANY_CONTIGUOUS, PyBUF_WRITEABLE
@@ -86,24 +87,31 @@ except ImportError:
8687
_importer_pid = os.getpid()
8788

8889

89-
def init():
90+
def _init():
9091
"""Initialize the Blosc library environment."""
9192
blosc_init()
9293

94+
init = deprecated(_init)
9395

94-
def destroy():
96+
97+
def _destroy():
9598
"""Destroy the Blosc library environment."""
9699
blosc_destroy()
97100

98101

99-
def compname_to_compcode(cname):
102+
destroy = deprecated(_destroy)
103+
104+
105+
def _compname_to_compcode(cname):
100106
"""Return the compressor code associated with the compressor name. If the compressor
101107
name is not recognized, or there is not support for it in this build, -1 is returned
102108
instead."""
103109
if isinstance(cname, str):
104110
cname = cname.encode('ascii')
105111
return blosc_compname_to_compcode(cname)
106112

113+
compname_to_compcode = deprecated(_compname_to_compcode)
114+
107115

108116
def list_compressors():
109117
"""Get a list of compressors supported in the current build."""
@@ -124,7 +132,7 @@ def set_nthreads(int nthreads):
124132
return blosc_set_nthreads(nthreads)
125133

126134

127-
def cbuffer_sizes(source):
135+
def _cbuffer_sizes(source):
128136
"""Return information about a compressed buffer, namely the number of uncompressed
129137
bytes (`nbytes`) and compressed (`cbytes`). It also returns the `blocksize` (which
130138
is used internally for doing the compression by blocks).
@@ -151,6 +159,7 @@ def cbuffer_sizes(source):
151159

152160
return nbytes, cbytes, blocksize
153161

162+
cbuffer_sizes = deprecated(_cbuffer_sizes)
154163

155164
def cbuffer_complib(source):
156165
"""Return the name of the compression library used to compress `source`."""
@@ -171,7 +180,7 @@ def cbuffer_complib(source):
171180
return complib
172181

173182

174-
def cbuffer_metainfo(source):
183+
def _cbuffer_metainfo(source):
175184
"""Return some meta-information about the compressed buffer in `source`, including
176185
the typesize, whether the shuffle or bit-shuffle filters were used, and the
177186
whether the buffer was memcpyed.
@@ -208,11 +217,13 @@ def cbuffer_metainfo(source):
208217

209218
return typesize, shuffle, memcpyed
210219

220+
cbuffer_metainfo = deprecated(_cbuffer_metainfo)
211221

212222
def err_bad_cname(cname):
213223
raise ValueError('bad compressor or compressor not supported: %r; expected one of '
214224
'%s' % (cname, list_compressors()))
215225

226+
err_bad_cname = deprecated(_err_bad_cname)
216227

217228
def compress(source, char* cname, int clevel, int shuffle=SHUFFLE,
218229
int blocksize=AUTOBLOCKS):
@@ -396,7 +407,7 @@ def decompress(source, dest=None):
396407
return dest
397408

398409

399-
def decompress_partial(source, start, nitems, dest=None):
410+
def _decompress_partial(source, start, nitems, dest=None):
400411
"""**Experimental**
401412
Decompress data of only a part of a buffer.
402413
@@ -469,6 +480,7 @@ def decompress_partial(source, start, nitems, dest=None):
469480

470481
return dest
471482

483+
decompress_partial = deprecated(_decompress_partial)
472484

473485
# set the value of this variable to True or False to override the
474486
# default adaptive behaviour

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ for use in data storage and communication applications."""
1616
readme = "README.rst"
1717
dependencies = [
1818
"numpy>=1.7",
19+
"deprecated"
1920
]
2021
requires-python = ">=3.10"
2122
dynamic = [

0 commit comments

Comments
 (0)