Debian Codegraph @

debian/patches/numpy2.patch

raw symbols SCIP
1 Author: Timo Röhling <[email protected]>
2 Description: NumPy 2 compatibility
3 Last-Update: Thu, 30 Jan 2025 09:36:02 +0100
4 Forwarded: no
5
6 ---
7 skmisc/loess/src/_loess.pyx | 17 ++++++-----------
8 skmisc/loess/tests/test_loess.py | 8 ++++----
9 2 files changed, 10 insertions(+), 15 deletions(-)
10
11 diff --git a/skmisc/loess/src/_loess.pyx b/skmisc/loess/src/_loess.pyx
12 index 34c779d..7548661 100644
13 --- a/skmisc/loess/src/_loess.pyx
14 +++ b/skmisc/loess/src/_loess.pyx
15 @@ -76,10 +76,8 @@ cdef class loess_inputs:
16 # if none was allocated prior to the error.
17 self.allocated = False
18
19 - x = np.array(x, copy=False, subok=True,
20 - dtype=np.float_, order='C')
21 - y = np.array(y, copy=False, subok=True,
22 - dtype=np.float_, order='C')
23 + x = np.asarray(x, dtype=np.float64, order='C')
24 + y = np.asarray(y, dtype=np.float64, order='C')
25 n = len(x)
26
27 # Check the dimensions
28 @@ -100,13 +98,12 @@ cdef class loess_inputs:
29 "observations.")
30
31 if weights is None:
32 - weights = np.ones((n,), dtype=np.float_)
33 + weights = np.ones((n,), dtype=np.float64)
34
35 if weights.ndim > 1 or weights.size != n:
36 raise ValueError("Invalid size of the 'weights' vector!")
37
38 - weights = np.array(weights, copy=False, subok=True,
39 - dtype=np.float_, order='C')
40 + weights = np.asarray(weights, dtype=np.float64, order='C')
41
42 # Python objects -> C structures -> *data in C structures
43 _x = x.ravel()
44 @@ -417,8 +414,7 @@ cdef class loess_model:
45 "of booleans with length equal to the number "
46 "of independent variables")
47
48 - p_ndr = np.atleast_1d(np.array(value, copy=False, subok=True,
49 - dtype=bool))
50 + p_ndr = np.atleast_1d(np.asarray(value, dtype=bool))
51 for i in range(self.p):
52 self._base.parametric[i] = p_ndr[i]
53
54 @@ -438,8 +434,7 @@ cdef class loess_model:
55 "of booleans with length equal to the number "
56 "of independent variables")
57
58 - d_ndr = np.atleast_1d(np.array(value, copy=False,
59 - subok=True, dtype=bool))
60 + d_ndr = np.atleast_1d(np.asarray(value, dtype=bool))
61 for i in range(self.p):
62 self._base.drop_square[i] = d_ndr[i]
63
64 diff --git a/skmisc/loess/tests/test_loess.py b/skmisc/loess/tests/test_loess.py
65 index e8fa175..00926bb 100644
66 --- a/skmisc/loess/tests/test_loess.py
67 +++ b/skmisc/loess/tests/test_loess.py
68 @@ -19,11 +19,11 @@ def madeup_data():
69 f.readline()
70 x = np.fromiter(
71 (float(v) for v in f.readline().rstrip().split()),
72 - np.float_).reshape(-1, 2)
73 + np.float64).reshape(-1, 2)
74 f.readline()
75 y = np.fromiter(
76 (float(v) for v in f.readline().rstrip().split()),
77 - np.float_)
78 + np.float64)
79
80 results = []
81 with open(rfile, 'r') as f:
82 @@ -31,7 +31,7 @@ def madeup_data():
83 f.readline()
84 z = np.fromiter(
85 (float(v) for v in f.readline().rstrip().split()),
86 - np.float_)
87 + np.float64)
88 results.append(z)
89
90 newdata1 = np.array([[-2.5, 0.], [2.5, 0.], [0., 0.]])
91 @@ -58,7 +58,7 @@ def gas_data():
92 f.readline()
93 z = np.fromiter(
94 (float(v) for v in f.readline().rstrip().split()),
95 - np.float_)
96 + np.float64)
97 results.append(z)
98 return (E, NOx, gas_fit_E, newdata, alpha, results)
99