Skip to content

Commit e1179a3

Browse files
committed
Deprecate blosc helper functions
1 parent d8a0a55 commit e1179a3

File tree

3 files changed

+59
-71
lines changed

3 files changed

+59
-71
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

+19-7
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
@@ -95,24 +96,31 @@ def get_mutex():
9596
_importer_pid = os.getpid()
9697

9798

98-
def init():
99+
def _init():
99100
"""Initialize the Blosc library environment."""
100101
blosc_init()
101102

103+
init = deprecated(_init)
102104

103-
def destroy():
105+
106+
def _destroy():
104107
"""Destroy the Blosc library environment."""
105108
blosc_destroy()
106109

107110

108-
def compname_to_compcode(cname):
111+
destroy = deprecated(_destroy)
112+
113+
114+
def _compname_to_compcode(cname):
109115
"""Return the compressor code associated with the compressor name. If the compressor
110116
name is not recognized, or there is not support for it in this build, -1 is returned
111117
instead."""
112118
if isinstance(cname, str):
113119
cname = cname.encode('ascii')
114120
return blosc_compname_to_compcode(cname)
115121

122+
compname_to_compcode = deprecated(_compname_to_compcode)
123+
116124

117125
def list_compressors():
118126
"""Get a list of compressors supported in the current build."""
@@ -133,7 +141,7 @@ def set_nthreads(int nthreads):
133141
return blosc_set_nthreads(nthreads)
134142

135143

136-
def cbuffer_sizes(source):
144+
def _cbuffer_sizes(source):
137145
"""Return information about a compressed buffer, namely the number of uncompressed
138146
bytes (`nbytes`) and compressed (`cbytes`). It also returns the `blocksize` (which
139147
is used internally for doing the compression by blocks).
@@ -160,6 +168,7 @@ def cbuffer_sizes(source):
160168

161169
return nbytes, cbytes, blocksize
162170

171+
cbuffer_sizes = deprecated(_cbuffer_sizes)
163172

164173
def cbuffer_complib(source):
165174
"""Return the name of the compression library used to compress `source`."""
@@ -180,7 +189,7 @@ def cbuffer_complib(source):
180189
return complib
181190

182191

183-
def cbuffer_metainfo(source):
192+
def _cbuffer_metainfo(source):
184193
"""Return some meta-information about the compressed buffer in `source`, including
185194
the typesize, whether the shuffle or bit-shuffle filters were used, and the
186195
whether the buffer was memcpyed.
@@ -217,11 +226,13 @@ def cbuffer_metainfo(source):
217226

218227
return typesize, shuffle, memcpyed
219228

229+
cbuffer_metainfo = deprecated(_cbuffer_metainfo)
220230

221-
def err_bad_cname(cname):
231+
def _err_bad_cname(cname):
222232
raise ValueError('bad compressor or compressor not supported: %r; expected one of '
223233
'%s' % (cname, list_compressors()))
224234

235+
err_bad_cname = deprecated(_err_bad_cname)
225236

226237
def compress(source, char* cname, int clevel, int shuffle=SHUFFLE,
227238
int blocksize=AUTOBLOCKS):
@@ -405,7 +416,7 @@ def decompress(source, dest=None):
405416
return dest
406417

407418

408-
def decompress_partial(source, start, nitems, dest=None):
419+
def _decompress_partial(source, start, nitems, dest=None):
409420
"""**Experimental**
410421
Decompress data of only a part of a buffer.
411422
@@ -478,6 +489,7 @@ def decompress_partial(source, start, nitems, dest=None):
478489

479490
return dest
480491

492+
decompress_partial = deprecated(_decompress_partial)
481493

482494
# set the value of this variable to True or False to override the
483495
# default adaptive behaviour

pyproject.toml

+40-58
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@ 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-
]
16+
readme = "README.rst"
17+
dependencies = ["numpy>=1.24", "deprecated"]
2018
requires-python = ">=3.11"
21-
dynamic = [
22-
"version",
23-
]
19+
dynamic = ["version"]
2420
classifiers = [
2521
"Development Status :: 4 - Beta",
2622
"Intended Audience :: Developers",
@@ -33,9 +29,7 @@ classifiers = [
3329
"Programming Language :: Python :: 3",
3430
"Programming Language :: Python :: 3 :: Only",
3531
]
36-
maintainers = [
37-
{ name = "Alistair Miles", email = "[email protected]" },
38-
]
32+
maintainers = [{ name = "Alistair Miles", email = "[email protected]" }]
3933
license = { text = "MIT" }
4034

4135
[project.urls]
@@ -45,33 +39,13 @@ Documentation = "https://numcodecs.readthedocs.io/"
4539
Homepage = "https://github.com/zarr-developers/numcodecs"
4640

4741
[project.optional-dependencies]
48-
docs = [
49-
"sphinx",
50-
"sphinx-issues",
51-
"pydata-sphinx-theme",
52-
"numpydoc",
53-
]
54-
test = [
55-
"coverage",
56-
"pytest",
57-
"pytest-cov",
58-
]
59-
test_extras = [
60-
"importlib_metadata",
61-
]
62-
msgpack = [
63-
"msgpack",
64-
]
65-
zfpy = [
66-
"zfpy>=1.0.0",
67-
"numpy<2.0.0",
68-
]
69-
pcodec = [
70-
"pcodec>=0.2,<0.3",
71-
]
72-
crc32c = [
73-
"crc32c>=2.7",
74-
]
42+
docs = ["sphinx", "sphinx-issues", "pydata-sphinx-theme", "numpydoc"]
43+
test = ["coverage", "pytest", "pytest-cov"]
44+
test_extras = ["importlib_metadata"]
45+
msgpack = ["msgpack"]
46+
zfpy = ["zfpy>=1.0.0", "numpy<2.0.0"]
47+
pcodec = ["pcodec>=0.2,<0.3"]
48+
crc32c = ["crc32c>=2.7"]
7549

7650
[project.entry-points."zarr.codecs"]
7751
"numcodecs.blosc" = "numcodecs.zarr3:Blosc"
@@ -98,14 +72,14 @@ crc32c = [
9872

9973
[tool.setuptools]
10074
license-files = ["LICENSE.txt"]
101-
package-dir = {"" = "."}
75+
package-dir = { "" = "." }
10276
packages = ["numcodecs", "numcodecs.tests"]
10377
zip-safe = false
10478

10579
[tool.setuptools.package-data]
10680
numcodecs = [
10781
"tests/package_with_entrypoint/__init__.py",
108-
"tests/package_with_entrypoint-0.1.dist-info/entry_points.txt"
82+
"tests/package_with_entrypoint-0.1.dist-info/entry_points.txt",
10983
]
11084

11185
[tool.setuptools_scm]
@@ -118,13 +92,25 @@ skip = "./.git,fixture"
11892
ignore-words-list = "ba, compiletime, hist, nd, unparseable"
11993

12094
[tool.coverage.report]
121-
exclude_lines = [
122-
"pragma: no cover",
123-
"pragma: ${PY_MAJOR_VERSION} no cover",
124-
]
95+
exclude_lines = ["pragma: no cover", "pragma: ${PY_MAJOR_VERSION} no cover"]
12596

12697
[tool.repo-review]
127-
ignore = ["PY005", "PY007", "PP302", "PP308", "PP309", "GH103", "GH212", "PC111", "PC140", "PC160", "PC170", "PC180", "MY100", "RF103"]
98+
ignore = [
99+
"PY005",
100+
"PY007",
101+
"PP302",
102+
"PP308",
103+
"PP309",
104+
"GH103",
105+
"GH212",
106+
"PC111",
107+
"PC140",
108+
"PC160",
109+
"PC170",
110+
"PC180",
111+
"MY100",
112+
"RF103",
113+
]
128114

129115
[tool.pytest.ini_options]
130116
addopts = "-ra --strict-config --strict-markers --cov=numcodecs --cov-report xml --doctest-modules --doctest-glob=*.pyx"
@@ -133,9 +119,7 @@ doctest_optionflags = [
133119
"ELLIPSIS",
134120
"IGNORE_EXCEPTION_DETAIL",
135121
]
136-
testpaths = [
137-
"numcodecs/tests",
138-
]
122+
testpaths = ["numcodecs/tests"]
139123
norecursedirs = [
140124
".git",
141125
".github",
@@ -150,17 +134,15 @@ norecursedirs = [
150134
]
151135
log_cli_level = "INFO"
152136
xfail_strict = true
153-
filterwarnings = [
154-
"error",
155-
]
137+
filterwarnings = ["error"]
156138

157139
[tool.cibuildwheel]
158-
environment = { DISABLE_NUMCODECS_AVX2=1 }
140+
environment = { DISABLE_NUMCODECS_AVX2 = 1 }
159141
[tool.cibuildwheel.macos]
160-
environment = { MACOSX_DEPLOYMENT_TARGET=10.9, DISABLE_NUMCODECS_AVX2=1, CFLAGS="$CFLAGS -Wno-implicit-function-declaration" }
142+
environment = { MACOSX_DEPLOYMENT_TARGET = 10.9, DISABLE_NUMCODECS_AVX2 = 1, CFLAGS = "$CFLAGS -Wno-implicit-function-declaration" }
161143
[[tool.cibuildwheel.overrides]]
162144
select = "*-macosx_arm64"
163-
environment = { DISABLE_NUMCODECS_AVX2=1, DISABLE_NUMCODECS_SSE2=1 }
145+
environment = { DISABLE_NUMCODECS_AVX2 = 1, DISABLE_NUMCODECS_SSE2 = 1 }
164146

165147
[tool.ruff]
166148
line-length = 100
@@ -189,13 +171,13 @@ ignore = [
189171
"FURB101",
190172
"FURB103",
191173
"PT001",
192-
"PT004", # deprecated
193-
"PT005", # deprecated
174+
"PT004", # deprecated
175+
"PT005", # deprecated
194176
"PT011",
195-
"RUF001",
177+
"RUF001",
196178
"UP007",
197-
"UP027", # deprecated
198-
"UP038", # https://github.com/astral-sh/ruff/issues/7871
179+
"UP027", # deprecated
180+
"UP038", # https://github.com/astral-sh/ruff/issues/7871
199181
]
200182

201183
[tool.ruff.format]

0 commit comments

Comments
 (0)