|
1 | 1 | import array |
2 | 2 | import json as _json |
3 | 3 | import os |
| 4 | +import warnings |
4 | 5 | from glob import glob |
5 | 6 |
|
6 | 7 | import numpy as np |
@@ -183,7 +184,11 @@ def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, pref |
183 | 184 | for arr_fn in glob(os.path.join(fixture_dir, 'array.*.npy')): |
184 | 185 | # setup |
185 | 186 | i = int(arr_fn.split('.')[-2]) |
186 | | - arr = np.load(arr_fn, allow_pickle=True) |
| 187 | + with warnings.catch_warnings(): |
| 188 | + # Old .npy fixture files contain dtype descriptors with align=0 (int). |
| 189 | + # NumPy 2.4+ requires align to be a boolean. |
| 190 | + warnings.filterwarnings("ignore", message="dtype.*align", category=UserWarning) |
| 191 | + arr = np.load(arr_fn, allow_pickle=True) |
187 | 192 | arr_bytes = arr.tobytes(order='A') |
188 | 193 | if arr.flags.f_contiguous: |
189 | 194 | order = 'F' |
@@ -222,9 +227,13 @@ def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, pref |
222 | 227 | # load and decode data |
223 | 228 | with open(enc_fn, mode='rb') as ef: |
224 | 229 | enc = ef.read() |
225 | | - dec = codec.decode(enc) |
226 | | - dec_arr = ensure_ndarray(dec).reshape(-1, order='A') |
227 | | - dec_arr = dec_arr.view(dtype=arr.dtype).reshape(arr.shape, order=order) |
| 230 | + with warnings.catch_warnings(): |
| 231 | + # Old fixture data may contain dtypes with align=0 (int). |
| 232 | + # NumPy 2.4+ requires align to be a boolean. |
| 233 | + warnings.filterwarnings("ignore", message="dtype.*align", category=UserWarning) |
| 234 | + dec = codec.decode(enc) |
| 235 | + dec_arr = ensure_ndarray(dec).reshape(-1, order='A') |
| 236 | + dec_arr = dec_arr.view(dtype=arr.dtype).reshape(arr.shape, order=order) |
228 | 237 | if precision and precision[j] is not None: |
229 | 238 | assert_array_almost_equal(arr, dec_arr, decimal=precision[j]) |
230 | 239 | elif arr.dtype == 'object': |
|
0 commit comments