Skip to content

Commit ed3e79e

Browse files
authored
Merge branch 'zarr-developers:main' into main
2 parents 3f22780 + 88660de commit ed3e79e

24 files changed

+190
-109
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
run: |
7979
conda activate env
8080
# TODO: remove --pre option when zarr v3 is out
81-
python -m pip install --pre zarr
81+
python -m pip install --pre zarr>=3.0.0b2
8282
8383
# This is used to test with zfpy, which does not yet support numpy 2.0
8484
- name: Install older numpy and zfpy
@@ -100,7 +100,7 @@ jobs:
100100
conda activate env
101101
pytest -v
102102
103-
- uses: codecov/codecov-action@v4
103+
- uses: codecov/codecov-action@v5
104104
with:
105105
token: ${{ secrets.CODECOV_TOKEN }}
106106
verbose: true

.pre-commit-config.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ repos:
1515
- id: debug-statements
1616

1717
- repo: https://github.com/astral-sh/ruff-pre-commit
18-
rev: v0.7.2
18+
rev: v0.7.4
1919
hooks:
2020
- id: ruff
2121
args: ["--fix", "--show-fixes"]
@@ -25,3 +25,10 @@ repos:
2525
rev: 2024.08.19
2626
hooks:
2727
- id: sp-repo-review
28+
29+
- repo: https://github.com/pre-commit/mirrors-mypy
30+
rev: 'v1.13.0'
31+
hooks:
32+
- id: mypy
33+
args: [--config-file, pyproject.toml]
34+
additional_dependencies: [numpy, pytest, crc32c, zfpy, 'zarr>=3.0.0b2']

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ build:
99
python: "3.12"
1010
jobs:
1111
post_install:
12-
- python -m pip install --pre 'zarr'
12+
- python -m pip install --pre 'zarr>=3.0.0b2'
1313

1414
sphinx:
1515
configuration: docs/conf.py

docs/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
1414

15-
1615
import os
1716
import sys
1817
from unittest.mock import Mock as MagicMock
@@ -232,7 +231,7 @@ def __getattr__(cls, name):
232231

233232
# -- Options for LaTeX output ---------------------------------------------
234233

235-
latex_elements = {
234+
latex_elements: dict[str, str] = {
236235
# The paper size ('letterpaper' or 'a4paper').
237236
#'papersize': 'letterpaper',
238237
# The font size ('10pt', '11pt' or '12pt').

docs/contributing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Contributing to NumCodecs
2-
=========================
1+
Contributing
2+
============
33

44
NumCodecs is a community maintained project. We welcome contributions in the form of bug
55
reports, bug fixes, documentation, enhancement proposals and more. This page provides

docs/release.rst

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

14-
Fix
15-
~~~
16-
* Fix in-place mutation of input array in `BitRound`.
17-
By :user:`Sam Levang <slevang>`, :issue:`608`
18-
* Fix an issue where importing numcodecs would lock the state of `multiprocessing`
19-
and prevent user code to call `multiprocessing.set_start_method("spawn")`
20-
subsequently.
21-
By :user:`Clément Robert <neutrinoceros>` :issue:`522`
14+
Fixes
15+
~~~~~
16+
* Cleanup ``crc32c`` soft dependency.
17+
By :user:`John Kirkham <jakirkham>`, :issue:`637`
18+
19+
Improvements
20+
~~~~~~~~~~~~
21+
* Add `noexcept` to `_utils` C-equiv functions
22+
By :user:`John Kirkham <jakirkham>`, :issue:`641`.
23+
24+
.. _release_0.14.0:
25+
26+
0.14.0
27+
------
2228

2329
Enhancements
2430
~~~~~~~~~~~~
2531
* Add Crc32c checksum codec.
2632
By :user:`Norman Rzepka <normanrz>`, :issue:`613`.
2733
* Add codec wrappers for Zarr 3.
2834
By :user:`Norman Rzepka <normanrz>`, :issue:`524`
35+
* Added mypy type checking to continuous integration.
36+
By :user:`David Stansby <dstansby>`, :issue:`460`.
37+
38+
Fixes
39+
~~~~~
40+
* Fix in-place mutation of input array in `BitRound`.
41+
By :user:`Sam Levang <slevang>`, :issue:`608`
42+
* Fix an issue where importing numcodecs would lock the state of `multiprocessing`
43+
and prevent user code to call `multiprocessing.set_start_method("spawn")`
44+
subsequently.
45+
By :user:`Clément Robert <neutrinoceros>` :issue:`522`
2946

3047
Maintenance
3148
~~~~~~~~~~~

numcodecs/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,17 @@
117117

118118
register_codec(MsgPack)
119119

120-
from numcodecs.checksum32 import CRC32, CRC32C, Adler32, JenkinsLookup3
120+
from numcodecs.checksum32 import CRC32, Adler32, JenkinsLookup3
121121

122122
register_codec(CRC32)
123-
register_codec(CRC32C)
124123
register_codec(Adler32)
125124
register_codec(JenkinsLookup3)
126125

126+
with suppress(ImportError):
127+
from numcodecs.checksum32 import CRC32C
128+
129+
register_codec(CRC32C)
130+
127131
from numcodecs.json import JSON
128132

129133
register_codec(JSON)

numcodecs/_utils.pxd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
from libc.stdint cimport uint8_t, uint32_t
99

1010

11-
cdef inline void store_le32(uint8_t c[4], uint32_t i) nogil:
11+
cdef inline void store_le32(uint8_t c[4], uint32_t i) noexcept nogil:
1212
c[0] = i & 0xFF
1313
c[1] = (i >> 8) & 0xFF
1414
c[2] = (i >> 16) & 0xFF
1515
c[3] = (i >> 24) & 0xFF
1616

1717

18-
cdef inline uint32_t load_le32(const uint8_t c[4]) nogil:
18+
cdef inline uint32_t load_le32(const uint8_t c[4]) noexcept nogil:
1919
return (
2020
c[0] |
2121
(c[1] << 8) |

numcodecs/abc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@
2929
"""
3030

3131
from abc import ABC, abstractmethod
32+
from typing import Optional
3233

3334

3435
class Codec(ABC):
3536
"""Codec abstract base class."""
3637

3738
# override in sub-class
38-
codec_id = None
39+
codec_id: Optional[str] = None
3940
"""Codec identifier."""
4041

4142
@abstractmethod

numcodecs/checksum32.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
import struct
22
import zlib
3-
from typing import Literal
3+
from collections.abc import Callable
4+
from contextlib import suppress
5+
from types import ModuleType
6+
from typing import TYPE_CHECKING, Literal, Optional
47

58
import numpy as np
69

710
from .abc import Codec
811
from .compat import ensure_contiguous_ndarray, ndarray_copy
912
from .jenkins import jenkins_lookup3
1013

14+
_crc32c: Optional[ModuleType] = None
15+
with suppress(ImportError):
16+
import crc32c as _crc32c # type: ignore[no-redef]
17+
18+
if TYPE_CHECKING: # pragma: no cover
19+
from typing_extensions import Buffer
20+
1121
CHECKSUM_LOCATION = Literal['start', 'end']
1222

1323

1424
class Checksum32(Codec):
1525
# override in sub-class
16-
checksum = None
26+
checksum: Callable[["Buffer", int], int] | None = None
1727
location: CHECKSUM_LOCATION = 'start'
1828

1929
def __init__(self, location: CHECKSUM_LOCATION | None = None):
@@ -72,28 +82,6 @@ class CRC32(Checksum32):
7282
location = 'start'
7383

7484

75-
class CRC32C(Checksum32):
76-
"""Codec add a crc32c checksum to the buffer.
77-
78-
Parameters
79-
----------
80-
location : 'start' or 'end'
81-
Where to place the checksum in the buffer.
82-
"""
83-
84-
codec_id = 'crc32c'
85-
86-
def checksum(self, buf):
87-
try:
88-
from crc32c import crc32c as crc32c_
89-
90-
return crc32c_(buf)
91-
except ImportError: # pragma: no cover
92-
raise ImportError("crc32c must be installed to use the CRC32C checksum codec.")
93-
94-
location = 'end'
95-
96-
9785
class Adler32(Checksum32):
9886
"""Codec add a adler32 checksum to the buffer.
9987
@@ -164,3 +152,19 @@ def decode(self, buf, out=None):
164152
out.view("uint8")[:] = b[:-4]
165153
return out
166154
return memoryview(b[:-4])
155+
156+
157+
if _crc32c:
158+
159+
class CRC32C(Checksum32):
160+
"""Codec add a crc32c checksum to the buffer.
161+
162+
Parameters
163+
----------
164+
location : 'start' or 'end'
165+
Where to place the checksum in the buffer.
166+
"""
167+
168+
codec_id = 'crc32c'
169+
checksum = _crc32c.crc32c # type: ignore[union-attr]
170+
location = 'end'

0 commit comments

Comments
 (0)