Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
TEST: only expect the old pickled dtype warning for numpy 2.4.0 to 2.4.4
numpy 2.4.5 undid the deprecation for the np.dtype() signature used by old
pickles (numpy PR #31177), so it no longer warns when loading old H5 files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
gdementen and claude committed Oct 7, 2026
commit 113be8bec64ab3fb9e81f0752736c6d0aa02b623
3 changes: 2 additions & 1 deletion larray/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@


NUMPY2 = NumpyVersion(np.__version__) >= '2.0.0'
NUMPY24 = NumpyVersion(np.__version__) >= '2.4.0'
# numpy 2.4.0 to 2.4.4 emit a deprecation warning when unpickling old dtypes
NUMPY_WARNS_ON_OLD_PICKLED_DTYPES = '2.4.0' <= NumpyVersion(np.__version__) < '2.4.5'
SKIP_EXCEL_TESTS = False
TESTDATADIR = Path(__file__).parent

Expand Down
6 changes: 3 additions & 3 deletions larray/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
assert_nparray_equal, assert_nparray_nan_equal,
needs_xlwings, needs_pytables, needs_xlsxwriter, needs_openpyxl,
needs_matplotlib,
NUMPY2, NUMPY24,
NUMPY2, NUMPY_WARNS_ON_OLD_PICKLED_DTYPES,
must_warn, must_raise
)
from larray import (
Expand Down Expand Up @@ -3910,8 +3910,8 @@ def test_hdf_roundtrip(tmp_path, meta):
msg = (f"'{fpath}' was created with an old version of NumPy. Please "
"rewrite the file with a recent version of NumPy to avoid future "
"compatibility issues.")
# if we do not use numpy >= 2.4, the warning is not triggered
num_expected = int(NUMPY24)
# the warning is only triggered for numpy versions emitting the original warning
num_expected = int(NUMPY_WARNS_ON_OLD_PICKLED_DTYPES)
with must_warn(FutureWarning, msg=msg, num_expected=num_expected):
_ = read_hdf(fpath, '__groups__/a01')

Expand Down
7 changes: 4 additions & 3 deletions larray/tests/test_checked_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
ndtest, full, full_like, zeros_like, ones, ones_like, isnan)
from larray.tests.common import (inputpath, assert_array_nan_equal, meta, # noqa: F401
needs_pytables, needs_openpyxl, needs_xlwings,
must_warn, must_raise, NUMPY24)
must_warn, must_raise,
NUMPY_WARNS_ON_OLD_PICKLED_DTYPES)
from larray.tests.test_session import (a, a2, a3, anonymous, a01, ano01, b, b2, b024, # noqa: F401
c, d, e, f, g, h,
assert_seq_equal, session, test_getitem, test_getattr,
Expand Down Expand Up @@ -162,8 +163,8 @@ def test_init_checkedsession_hdf():

# check_file is False because the warning stack level is calibrated for
# Session and not CheckedSession which uses a Session
# if we do not use numpy >= 2.4, the warning is not triggered
num_expected = int(NUMPY24)
# the warning is only triggered for numpy versions emitting the original warning
num_expected = int(NUMPY_WARNS_ON_OLD_PICKLED_DTYPES)
with must_warn(FutureWarning, msg=msg, check_file=False,
num_expected=num_expected):
cs = CheckedSessionExample(fpath)
Expand Down
6 changes: 3 additions & 3 deletions larray/tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
assert_larray_equal, assert_array_nan_equal, assert_larray_nan_equal,
needs_xlwings, needs_pytables, needs_openpyxl,
must_warn, must_raise,
NUMPY24
NUMPY_WARNS_ON_OLD_PICKLED_DTYPES
)
from larray.inout.common import _supported_scalars_types
from larray import (Session, Axis, Array, Group, CheckedSession,
Expand Down Expand Up @@ -96,8 +96,8 @@ def test_init_session_hdf():
msg = (f"'{fpath}' was created with an old version of NumPy. Please "
"rewrite the file with a recent version of NumPy to avoid future "
"compatibility issues.")
# if we do not use numpy >= 2.4, the warning is not triggered
num_expected = int(NUMPY24)
# the warning is only triggered for numpy versions emitting the original warning
num_expected = int(NUMPY_WARNS_ON_OLD_PICKLED_DTYPES)
with must_warn(FutureWarning, msg=msg, num_expected=num_expected):
s = Session(fpath)
assert list(s.keys()) == ['e', 'f', 'g', 'h', 'a', 'a2', 'anonymous', 'b', 'a01', 'ano01', 'b024']
Expand Down