Skip to content

Commit 4976a29

Browse files
committed
Version check for zfpy lower than 1.0.1
1 parent e3c0b34 commit 4976a29

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

numcodecs/zfpy.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from contextlib import suppress
23
from importlib.metadata import PackageNotFoundError, version
34
from types import ModuleType
@@ -10,8 +11,19 @@
1011
_zfpy_version = tuple(map(int, version("zfpy").split(".")))
1112

1213
if _zfpy_version:
13-
with suppress(ImportError):
14-
import zfpy as _zfpy # type: ignore[no-redef]
14+
# Check NumPy version
15+
_numpy_version: tuple = tuple(map(int, version("numpy").split('.')))
16+
if _numpy_version >= (2, 0, 0) and _zfpy_version < (1, 0, 1): # pragma: no cover
17+
_zfpy_version = ()
18+
warnings.warn(
19+
"NumPy version >= 2.0.0 detected. The zfpy library is incompatible with this version of NumPy. "
20+
"Please downgrade to NumPy < 2.0.0 or wait for an update from zfpy.",
21+
UserWarning,
22+
stacklevel=2,
23+
)
24+
else:
25+
with suppress(ImportError):
26+
import zfpy as _zfpy # type: ignore[no-redef]
1527

1628
if _zfpy:
1729
import numpy as np

0 commit comments

Comments
 (0)