File: numpy-2.0.patch

package info (click to toggle)
hickle 5.0.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 956 kB
  • sloc: python: 5,578; sh: 17; makefile: 15
file content (95 lines) | stat: -rw-r--r-- 4,944 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
From: Colin Watson <cjwatson@debian.org>
Date: Mon, 3 Feb 2025 15:28:10 +0000
Subject: Support numpy 2.0

See: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword

Forwarded: https://github.com/telegraphic/hickle/pull/186
Bug-Debian: https://bugs.debian.org/1094905
Last-Update: 2025-02-03
---
 hickle/legacy_v3/loaders/load_numpy.py | 2 +-
 hickle/loaders/load_builtins.py        | 4 ++--
 hickle/loaders/load_numpy.py           | 2 +-
 hickle/tests/test_02_hickle_lookup.py  | 6 +++---
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/hickle/legacy_v3/loaders/load_numpy.py b/hickle/legacy_v3/loaders/load_numpy.py
index 0fd6c0a..d17044b 100644
--- a/hickle/legacy_v3/loaders/load_numpy.py
+++ b/hickle/legacy_v3/loaders/load_numpy.py
@@ -115,7 +115,7 @@ def load_np_scalar_dataset(h_node):
 
 def load_ndarray_dataset(h_node):
     py_type, data = get_type_and_data(h_node)
-    return np.array(data, copy=False)
+    return np.asarray(data)
 
 def load_ndarray_masked_dataset(h_node):
     py_type, data = get_type_and_data(h_node)
diff --git a/hickle/loaders/load_builtins.py b/hickle/loaders/load_builtins.py
index 7cfbf28..53b7442 100644
--- a/hickle/loaders/load_builtins.py
+++ b/hickle/loaders/load_builtins.py
@@ -170,7 +170,7 @@ def create_listlike_dataset(py_obj, h_group, name,list_len = -1,item_dtype = Non
         # strings and bytes are stored as array of bytes with strings encoded
         # using utf8 encoding
         string_data = bytearray(py_obj,"utf8") if isinstance(py_obj,str) else memoryview(py_obj)
-        string_data = np.array(string_data,copy=False)
+        string_data = np.asarray(string_data)
         string_data.dtype = 'S1'
         dataset = h_group.create_dataset( name, data = string_data,shape = (1,string_data.size), **kwargs)
         dataset.attrs["str_type"] = py_obj.__class__.__name__.encode("ascii")
@@ -385,7 +385,7 @@ def load_list_dataset(h_node,base_type,py_obj_type):
         if h_node.dtype.itemsize > 1 and 'bytes' in h_node.dtype.name:
 
             # string dataset 4.0.x style convert it back to python string
-            content = np.array(content, copy=False, dtype=str).tolist()
+            content = np.asarray(content, dtype=str).tolist()
         else:
 
             # decode bytes representing python string before final conversion
diff --git a/hickle/loaders/load_numpy.py b/hickle/loaders/load_numpy.py
index a4c76e9..bff9818 100644
--- a/hickle/loaders/load_numpy.py
+++ b/hickle/loaders/load_numpy.py
@@ -232,7 +232,7 @@ def load_ndarray_dataset(h_node,base_type,py_obj_type):
             # not converted to list of string but saved as ar consequently
             # itemsize of dtype is > 1
             string_data = bytes(string_data).decode("utf8")
-        return np.array(string_data,copy=False,dtype=dtype)
+        return np.asarray(string_data,dtype=dtype)
     if issubclass(py_obj_type,np.matrix):
         return py_obj_type(data=h_node[()],dtype=dtype)
     # TODO how to restore other ndarray derived object_types
diff --git a/hickle/tests/test_02_hickle_lookup.py b/hickle/tests/test_02_hickle_lookup.py
index 628a2b1..dd91ffd 100644
--- a/hickle/tests/test_02_hickle_lookup.py
+++ b/hickle/tests/test_02_hickle_lookup.py
@@ -816,7 +816,7 @@ def test_ReferenceManager_get_root(h5_data):
     content = data_group.create_dataset('mydata',data=12)
     type_table = root_group.create_group('hickle_types_table')
     int_pickle_string = bytearray(pickle.dumps(int))
-    int_np_entry = np.array(int_pickle_string,copy=False)
+    int_np_entry = np.asarray(int_pickle_string)
     int_np_entry.dtype = 'S1'
     int_entry = type_table.create_dataset(str(len(type_table)),data = int_np_entry,shape =(1,int_np_entry.size))
     int_base_type = b'int'
@@ -878,7 +878,7 @@ def test_ReferenceManager(h5_data):
     with pytest.raises(lookup.ReferenceError):
         reference_manager = lookup.ReferenceManager(false_root)
     int_pickle_string = bytearray(pickle.dumps(int))
-    int_np_entry = np.array(int_pickle_string,copy=False)
+    int_np_entry = np.asarray(int_pickle_string)
     int_np_entry.dtype = 'S1'
     int_entry = type_table.create_dataset(str(len(type_table)),data = int_np_entry,shape =(1,int_np_entry.size))
     int_base_type = b'int'
@@ -1052,7 +1052,7 @@ def test_ReferenceManager_store_type(h5_data,compression_kwargs):
 @pytest.mark.no_compression
 def test_ReferenceManager_get_manager(h5_data):
     h_node = h5_data.create_group('some_list')
-    item_data = np.array(memoryview(b'hallo welt lore grueszet dich ipsum aus der lore von ipsum gelort in ipsum'),copy=False)
+    item_data = np.asarray(memoryview(b'hallo welt lore grueszet dich ipsum aus der lore von ipsum gelort in ipsum'))
     item_data.dtype = 'S1'
     h_item = h_node.create_dataset('0',data=item_data,shape=(1,item_data.size))
     with lookup.ReferenceManager.create_manager(h5_data) as memo: