Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ZFPY import error #540

Merged
merged 11 commits into from
Jul 8, 2024
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
2 changes: 2 additions & 0 deletions docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Fix
By :user:`Elliott Sales de Andrade <QuLogic>`, :issue:`487`.
* Fix Upgrade to Zstd 1.5.5 due to potential corruption.
By :user:`Mark Kittisopikul <mkitti>`, :issue:`429`
* Add version constraint(<2.0) for numpy in zfpy.
By :user:`Tom Liang <px39n>`, :issue:`540`.

Maintenance
~~~~~~~~~~~
Expand Down
21 changes: 19 additions & 2 deletions numcodecs/zfpy.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
from contextlib import suppress
from importlib.metadata import PackageNotFoundError, version
import warnings

_zfpy = None
with suppress(ImportError):
import zfpy as _zfpy

_zfpy_version: tuple = ()
with suppress(PackageNotFoundError):
_zfpy_version = tuple(map(int, version("zfpy").split(".")))

if _zfpy_version:
# Check NumPy version
_numpy_version: tuple = tuple(map(int, version("numpy").split('.')))
if _numpy_version >= (2, 0, 0) and _zfpy_version <= (1, 0, 1):
_zfpy_version = ()
warnings.warn(

Check warning on line 16 in numcodecs/zfpy.py

View check run for this annotation

Codecov / codecov/patch

numcodecs/zfpy.py#L15-L16

Added lines #L15 - L16 were not covered by tests
"NumPy version >= 2.0.0 detected. The zfpy library is incompatible with this version of NumPy. "
"Please downgrade to NumPy < 2.0.0 or wait for an update from zfpy.",
UserWarning,
)
else:
with suppress(ImportError):
import zfpy as _zfpy

if _zfpy:
from .abc import Codec
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ msgpack = [
]
zfpy = [
"zfpy>=1.0.0",
"numpy<2.0.0",
]
pcodec = [
"pcodec>=0.1.0",
Expand Down