Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions numcodecs/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@
"""

from abc import ABC, abstractmethod
from typing import Optional


class Codec(ABC):
"""Codec abstract base class."""

# override in sub-class
codec_id: Optional[str] = None
codec_id: str | None = None
"""Codec identifier."""

@abstractmethod
Expand Down
4 changes: 2 additions & 2 deletions numcodecs/checksum32.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import zlib
from contextlib import suppress
from types import ModuleType
from typing import Literal, Optional
from typing import Literal

import numpy as np
from typing_extensions import Buffer
Expand All @@ -12,7 +12,7 @@
from .compat import ensure_contiguous_ndarray, ndarray_copy
from .jenkins import jenkins_lookup3

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

Expand Down
3 changes: 1 addition & 2 deletions numcodecs/lzma.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from types import ModuleType
from typing import Optional

_lzma: Optional[ModuleType] = None
_lzma: ModuleType | None = None
try:
import lzma as _lzma
except ImportError: # pragma: no cover
Expand Down
24 changes: 12 additions & 12 deletions numcodecs/tests/test_zarr3.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ def test_generic_filter(
],
)

a[:, :] = data.copy()
a = zarr.open_array(store / "generic", mode="r")
a[:, :] = data.copy()
a = zarr.open_array(store / "generic", mode="r")
np.testing.assert_array_equal(data, a[:, :])


Expand All @@ -140,8 +140,8 @@ def test_generic_filter_bitround(store: StorePath):
filters=[numcodecs.zarr3.BitRound(keepbits=3)],
)

a[:, :] = data.copy()
a = zarr.open_array(store / "generic_bitround", mode="r")
a[:, :] = data.copy()
a = zarr.open_array(store / "generic_bitround", mode="r")
assert np.allclose(data, a[:, :], atol=0.1)


Expand All @@ -158,8 +158,8 @@ def test_generic_filter_quantize(store: StorePath):
filters=[numcodecs.zarr3.Quantize(digits=3)],
)

a[:, :] = data.copy()
a = zarr.open_array(store / "generic_quantize", mode="r")
a[:, :] = data.copy()
a = zarr.open_array(store / "generic_quantize", mode="r")
assert np.allclose(data, a[:, :], atol=0.001)


Expand All @@ -177,8 +177,8 @@ def test_generic_filter_packbits(store: StorePath):
filters=[numcodecs.zarr3.PackBits()],
)

a[:, :] = data.copy()
a = zarr.open_array(store / "generic_packbits", mode="r")
a[:, :] = data.copy()
a = zarr.open_array(store / "generic_packbits", mode="r")
np.testing.assert_array_equal(data, a[:, :])

with pytest.raises(ValueError, match=".*requires bool dtype.*"):
Expand Down Expand Up @@ -217,8 +217,8 @@ def test_generic_checksum(
compressors=[codec_class()],
)

a[:, :] = data.copy()
a = zarr.open_array(store / "generic_checksum", mode="r")
a[:, :] = data.copy()
a = zarr.open_array(store / "generic_checksum", mode="r")
np.testing.assert_array_equal(data, a[:, :])


Expand Down Expand Up @@ -267,8 +267,8 @@ def test_delta_astype(store: StorePath):
],
)

a[:, :] = data.copy()
a = zarr.open_array(store / "generic", mode="r")
a[:, :] = data.copy()
a = zarr.open_array(store / "generic", mode="r")
np.testing.assert_array_equal(data, a[:, :])


Expand Down
3 changes: 1 addition & 2 deletions numcodecs/zfpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from contextlib import suppress
from importlib.metadata import PackageNotFoundError, version
from types import ModuleType
from typing import Optional

_zfpy: Optional[ModuleType] = None
_zfpy: ModuleType | None = None

_zfpy_version: tuple = ()
with suppress(PackageNotFoundError):
Expand Down
Loading