summaryrefslogtreecommitdiff
path: root/debian/patches/0002-Python-3.10-compatibility-fix.patch
blob: 52ffb0997f2cd96d2634dd2a3dfddb924459bd5b (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
From: Gard Spreemann <gspr@nonempty.org>
Date: Sun, 21 Nov 2021 15:12:18 +0100
Subject: Python 3.10 compatibility fix

Importing Sequence et al. from collections has been deprecated since
Python 3.7.
---
 pyspike/DiscreteFunc.py       | 6 +++---
 pyspike/PieceWiseConstFunc.py | 8 ++++----
 pyspike/PieceWiseLinFunc.py   | 8 ++++----
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/pyspike/DiscreteFunc.py b/pyspike/DiscreteFunc.py
index caad290..48bc787 100644
--- a/pyspike/DiscreteFunc.py
+++ b/pyspike/DiscreteFunc.py
@@ -5,7 +5,7 @@
 from __future__ import absolute_import, print_function
 
 import numpy as np
-import collections
+import collections.abc
 import pyspike
 
 
@@ -155,11 +155,11 @@ class DiscreteFunc(object):
             multiplicity = np.sum(self.mp[1:-1])
         else:
             # check if interval is as sequence
-            assert isinstance(interval, collections.Sequence), \
+            assert isinstance(interval, collections.abc.Sequence), \
                 "Invalid value for `interval`. None, Sequence or Tuple \
 expected."
             # check if interval is a sequence of intervals
-            if not isinstance(interval[0], collections.Sequence):
+            if not isinstance(interval[0], collections.abc.Sequence):
                 # find the indices corresponding to the interval
                 start_ind, end_ind = get_indices(interval)
                 value = np.sum(self.y[start_ind:end_ind])
diff --git a/pyspike/PieceWiseConstFunc.py b/pyspike/PieceWiseConstFunc.py
index 17fdd3f..e33c61d 100644
--- a/pyspike/PieceWiseConstFunc.py
+++ b/pyspike/PieceWiseConstFunc.py
@@ -5,7 +5,7 @@
 from __future__ import absolute_import, print_function
 
 import numpy as np
-import collections
+import collections.abc
 import pyspike
 
 
@@ -39,7 +39,7 @@ class PieceWiseConstFunc(object):
 
         ind = np.searchsorted(self.x, t, side='right')
 
-        if isinstance(t, collections.Sequence):
+        if isinstance(t, collections.abc.Sequence):
             # t is a sequence of values
             # correct the cases t == x[0], t == x[-1]
             ind[ind == 0] = 1
@@ -173,10 +173,10 @@ class PieceWiseConstFunc(object):
             return self.integral() / (self.x[-1]-self.x[0])
 
         # check if interval is as sequence
-        assert isinstance(interval, collections.Sequence), \
+        assert isinstance(interval, collections.abc.Sequence), \
             "Invalid value for `interval`. None, Sequence or Tuple expected."
         # check if interval is a sequence of intervals
-        if not isinstance(interval[0], collections.Sequence):
+        if not isinstance(interval[0], collections.abc.Sequence):
             # just one interval
             a = self.integral(interval) / (interval[1]-interval[0])
         else:
diff --git a/pyspike/PieceWiseLinFunc.py b/pyspike/PieceWiseLinFunc.py
index 8faaec4..b3b503b 100644
--- a/pyspike/PieceWiseLinFunc.py
+++ b/pyspike/PieceWiseLinFunc.py
@@ -5,7 +5,7 @@
 from __future__ import absolute_import, print_function
 
 import numpy as np
-import collections
+import collections.abc
 import pyspike
 
 
@@ -46,7 +46,7 @@ class PieceWiseLinFunc:
 
         ind = np.searchsorted(self.x, t, side='right')
 
-        if isinstance(t, collections.Sequence):
+        if isinstance(t, collections.abc.Sequence):
             # t is a sequence of values
             # correct the cases t == x[0], t == x[-1]
             ind[ind == 0] = 1
@@ -211,10 +211,10 @@ class PieceWiseLinFunc:
             return self.integral() / (self.x[-1]-self.x[0])
 
         # check if interval is as sequence
-        assert isinstance(interval, collections.Sequence), \
+        assert isinstance(interval, collections.abc.Sequence), \
             "Invalid value for `interval`. None, Sequence or Tuple expected."
         # check if interval is a sequence of intervals
-        if not isinstance(interval[0], collections.Sequence):
+        if not isinstance(interval[0], collections.abc.Sequence):
             # just one interval
             a = self.integral(interval) / (interval[1]-interval[0])
         else: