python3Packages.hickle: fix testing with numpy 2.3

This commit is contained in:
Sergey Volkov 2025-06-29 11:05:47 +02:00
parent dd5540905b
commit 48a64a0503
2 changed files with 36 additions and 0 deletions

View File

@ -34,6 +34,9 @@ buildPythonPackage rec {
url = "https://github.com/cjwatson/hickle/commit/246d8e82c805e2e49ea0abd39abc9b2d800bde59.patch";
hash = "sha256-IEVw2K7S1nCkzgn9q0xghm4brfXcallNjzXpt2cRq1M=";
})
# fixes test failing with numpy 2.3 as ndarray.tostring was deleted
# FIXME: delete once https://github.com/telegraphic/hickle/pull/187 is merged
./numpy-2.3-ndarray-tostring.patch
];
build-system = [ setuptools ];

View File

@ -0,0 +1,33 @@
From 7a0d0e625dd9e92159a145a26dd68ef3b61fde6e Mon Sep 17 00:00:00 2001
From: Sergey Volkov <taranarmo@gmail.com>
Date: Sun, 29 Jun 2025 10:54:00 +0200
Subject: [PATCH] replace `ndarray.tostring` with `ndarray.tobytes`
`ndarray.tostring` is deprecated since numpy 1.19 and removed in numpy 2.3
https://numpy.org/doc/stable/release/2.3.0-notes.html
---
hickle/tests/test_06_load_astropy.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hickle/tests/test_06_load_astropy.py b/hickle/tests/test_06_load_astropy.py
index 628a4b3..b630bfd 100755
--- a/hickle/tests/test_06_load_astropy.py
+++ b/hickle/tests/test_06_load_astropy.py
@@ -166,7 +166,7 @@ def test_astropy_time_array(h5_data,compression_kwargs):
assert reloaded.format == t1.format
assert reloaded.scale == t1.scale
for index in range(len(t1)):
- assert reloaded.value[index].tostring() == t1.value[index].tostring()
+ assert reloaded.value[index].tobytes() == t1.value[index].tobytes()
del h_dataset.attrs['np_dtype']
reloaded = load_astropy.load_astropy_time_dataset(h_dataset,b'astropy_time',t1.__class__)
@@ -174,7 +174,7 @@ def test_astropy_time_array(h5_data,compression_kwargs):
assert reloaded.format == t1.format
assert reloaded.scale == t1.scale
for index in range(len(t1)):
- assert reloaded.value[index].tostring() == t1.value[index].tostring()
+ assert reloaded.value[index].tobytes() == t1.value[index].tobytes()
loop_counter += 1