Skip to content

Commit 28015ae

Browse files
committed
Merge branch 'main' into ig/itemsize_blosc
2 parents bf6e4e5 + 0417d64 commit 28015ae

File tree

18 files changed

+126
-63
lines changed

18 files changed

+126
-63
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
python-version: ["3.11", "3.12", "3.13"]
16-
# macos-13 is an intel runner, macos-14 is a arm64 runner
17-
platform: [ubuntu-latest, windows-latest, macos-13, macos-14]
16+
# macos-13 is an intel runner, macos-14 is an arm64 runner
17+
platform: [ubuntu-latest, ubuntu-22.04-arm, windows-latest, macos-13, macos-14]
1818

1919
defaults:
2020
run:
@@ -28,7 +28,7 @@ jobs:
2828
fetch-depth: 0 # required for version resolution
2929

3030
- name: Set up Conda
31-
uses: conda-incubator/[email protected].0
31+
uses: conda-incubator/[email protected].1
3232
with:
3333
channels: conda-forge
3434
miniforge-version: latest
@@ -50,20 +50,13 @@ jobs:
5050
- name: Install numcodecs
5151
run: |
5252
export DISABLE_NUMCODECS_AVX2=""
53-
# TODO: put back zfpy import when it supports numpy 2.0
54-
python -m pip install -v -e .[test,test_extras,msgpack,crc32c,pcodec]
53+
python -m pip install -v -e .[test,test_extras,msgpack,crc32c,pcodec,zfpy]
5554
5655
- name: Install zarr-python
5756
# Since zarr v3 requires numpy >= 1.25, on Python 3.11 leave it out
5857
# so we can have some tests of our minimum version of numpy (1.24)
5958
if: matrix.python-version != '3.11'
60-
# TODO: remove --pre option when zarr v3 is out
61-
run: python -m pip install --pre zarr>=3.0.0b2
62-
63-
# This is used to test with zfpy, which does not yet support numpy 2.0
64-
- name: Install older numpy and zfpy
65-
if: matrix.python-version == '3.11'
66-
run: python -m pip install -v ".[zfpy]"
59+
run: python -m pip install zarr>=3
6760

6861
- name: List installed packages
6962
run: python -m pip list

.github/workflows/wheel.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
# macos-13 is an intel runner, macos-14 is a arm64 runner
17-
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
16+
# macos-13 is an intel runner, macos-14 is an arm64 runner
17+
os: [ubuntu-latest, ubuntu-22.04-arm, windows-latest, macos-13, macos-14]
1818
env:
1919
CIBW_TEST_COMMAND: python -c "import numcodecs"
2020
CIBW_BUILD: "cp311-* cp312-* cp313-*"

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ repos:
1414
- id: debug-statements
1515

1616
- repo: https://github.com/astral-sh/ruff-pre-commit
17-
rev: v0.8.4
17+
rev: v0.9.4
1818
hooks:
1919
- id: ruff
2020
args: ["--fix", "--show-fixes"]
2121
- id: ruff-format
2222

2323
- repo: https://github.com/scientific-python/cookie
24-
rev: 2024.08.19
24+
rev: 2025.01.22
2525
hooks:
2626
- id: sp-repo-review
2727

2828
- repo: https://github.com/pre-commit/mirrors-mypy
29-
rev: v1.14.0
29+
rev: v1.14.1
3030
hooks:
3131
- id: mypy
3232
args: [--config-file, pyproject.toml]

docs/release.rst

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,38 @@ Release notes
1111
Unreleased
1212
----------
1313

14+
1415
.. _unreleased:
1516

1617
Unreleased
1718
----------
1819

20+
Enhancements
21+
~~~~~~~~~~~~
22+
23+
* Add support for the Linux AArch64 architecture, and bump the minimum
24+
macOS deployment target for x86_64 to 10.13.
25+
By :user:`Agriya Khetarpal <agriyakhetarpal>`, :issue:`288`.
26+
27+
Improvements
28+
~~~~~~~~~~~~
29+
* Raise a custom `UnknownCodecError` when trying to retrieve an unavailable codec.
30+
By :user:`Cas Wognum <cwognum>`.
31+
* Add ``typesize`` argument to ``Blosc`` to allow for buffers that are passed to ``encode``
32+
use that information. zarr v3 currently has its Blosc codec as bytes-to-bytes but does retain
33+
the size information so using it here allows for massive compression ratio gains.
34+
By :user:`Ilan Gold <ilan-gold>`
35+
36+
Fixes
37+
~~~~~
38+
* Remove redundant ``id`` from codec metadata serialization in Zarr3 codecs.
39+
By :user:`Norman Rzepka <normanrz>`, :issue:`685`
40+
41+
.. _release_0.15.0:
42+
43+
0.15.0
44+
------
45+
1946
Breaking changes
2047
~~~~~~~~~~~~~~~~
2148
* All arguments to the ``PCodec`` constructor except for ``level``
@@ -24,7 +51,7 @@ Breaking changes
2451

2552
Deprecations
2653
~~~~~~~~~~~~
27-
The following ``blosc`` funcitons are deprecated, with no replacement.
54+
The following ``blosc`` functions are deprecated, with no replacement.
2855
This is because they are not intended to be public API.
2956

3057
- ``numcodecs.blosc.init``
@@ -36,11 +63,16 @@ This is because they are not intended to be public API.
3663
In addition, ``numcodecs.blosc.decompress_partial`` is deprecated as
3764
has always been experimental and there is no equivalent in the official
3865
blsoc Python package.
66+
By :user:`David Stansby <dstansby>`, :issue`619`
3967

4068
Fixes
4169
~~~~~
4270
* Fixes issue with ``Delta`` Zarr 3 codec not working with ``astype``.
4371
By :user:`Norman Rzepka <normanrz>`, :issue:`664`
72+
* Cleanup ``PCodec`` soft dependency.
73+
Previously importing ``numcodecs.pcodec`` would work if ``pcodec`` is not installed,
74+
but now it will fail to import. This mirrors the behaviour of other optional dependencies.
75+
By :user:`John Kirkham <jakirkham>`, :issue:`647`
4476
* Fixes issues with the upcoming ``zarr`` 3.0.0 release.
4577
By :user:`Norman Rzepka <normanrz>`, :issue:`675`
4678

@@ -63,10 +95,8 @@ Improvements
6395
Import errors caused by optional dependencies (ZFPY, MsgPack, CRC32C, and PCodec)
6496
are still silently caught.
6597
By :user:`David Stansby <dstansby>`, :issue:`550`.
66-
* Add ``typesize`` argument to ``Blosc`` to allow for buffers that are passed to ``encode``
67-
use that information. zarr v3 currently has its Blosc codec as bytes-to-bytes but does retain
68-
the size information so using it here allows for massive compression ratio gains.
69-
By :user:`Ilan Gold <ilan-gold>`
98+
99+
.. _release_0.14.1:
70100

71101
0.14.1
72102
------

numcodecs/checksum32.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
_crc32c: Optional[ModuleType] = None
1515
with suppress(ImportError):
16-
import crc32c as _crc32c # type: ignore[no-redef]
16+
import crc32c as _crc32c # type: ignore[no-redef, unused-ignore]
1717

1818
if TYPE_CHECKING: # pragma: no cover
1919
from typing_extensions import Buffer

numcodecs/delta.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ def encode(self, buf):
6363
enc[0] = arr[0]
6464

6565
# compute differences
66-
# using np.subtract for in-place operations
67-
if arr.dtype == bool:
68-
np.not_equal(arr[1:], arr[:-1], out=enc[1:])
69-
else:
70-
np.subtract(arr[1:], arr[:-1], out=enc[1:])
71-
66+
enc[1:] = np.diff(arr)
7267
return enc
7368

7469
def decode(self, buf, out=None):

numcodecs/errors.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
This module defines custom exceptions that are raised in the `numcodecs` codebase.
3+
"""
4+
5+
6+
class UnknownCodecError(ValueError):
7+
"""
8+
An exception that is raised when trying to receive a codec that has not been registered.
9+
10+
Parameters
11+
----------
12+
codec_id : str
13+
Codec identifier.
14+
15+
Examples
16+
----------
17+
>>> import numcodecs
18+
>>> numcodecs.get_codec({"codec_id": "unknown"})
19+
Traceback (most recent call last):
20+
...
21+
UnknownCodecError: codec not available: 'unknown'
22+
"""
23+
24+
def __init__(self, codec_id: str):
25+
self.codec_id = codec_id
26+
super().__init__(f"codec not available: '{codec_id}'")

numcodecs/json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(
6868
def encode(self, buf):
6969
try:
7070
buf = np.asarray(buf)
71-
except ValueError:
71+
except ValueError: # pragma: no cover
7272
buf = np.asarray(buf, dtype=object)
7373
items = np.atleast_1d(buf).tolist()
7474
items.append(buf.dtype.str)

numcodecs/pcodec.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
from numcodecs.abc import Codec
44
from numcodecs.compat import ensure_contiguous_ndarray
5-
6-
try:
7-
from pcodec import ChunkConfig, DeltaSpec, ModeSpec, PagingSpec, standalone
8-
except ImportError: # pragma: no cover
9-
standalone = None
10-
5+
from pcodec import ChunkConfig, DeltaSpec, ModeSpec, PagingSpec, standalone
116

127
DEFAULT_MAX_PAGE_N = 262144
138

@@ -58,9 +53,6 @@ def __init__(
5853
delta_encoding_order: int | None = None,
5954
equal_pages_up_to: int = DEFAULT_MAX_PAGE_N,
6055
):
61-
if standalone is None: # pragma: no cover
62-
raise ImportError("pcodec must be installed to use the PCodec codec.")
63-
6456
# note that we use `level` instead of `compression_level` to
6557
# match other codecs
6658
self.level = level

numcodecs/quantize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ def encode(self, buf):
6565
precision = 10.0**-self.digits
6666
exp = math.log10(precision)
6767
if exp < 0:
68-
exp = int(math.floor(exp))
68+
exp = math.floor(exp)
6969
else:
70-
exp = int(math.ceil(exp))
70+
exp = math.ceil(exp)
7171
bits = math.ceil(math.log2(10.0**-exp))
7272
scale = 2.0**bits
7373
enc = np.around(scale * arr) / scale

0 commit comments

Comments
 (0)