-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_grinder_filter.py
269 lines (260 loc) · 26.6 KB
/
test_grinder_filter.py
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
import unittest
from grinder_filter import GrinderFilter
class MyTestCase(unittest.TestCase):
def test_filter_voltages1(self):
filter_size = 16
settle_time = 2 * filter_size
v_filter = GrinderFilter(30000, filter_size)
# Calculated with floating point arithmetic and "verified" by looking at and thinking about plot
expected = [30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000,
30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000,
30000, 30000, 30000, 30000, 28125, 26250, 24375, 22500, 20625, 18750, 16876, 15002, 13128, 11255,
9383, 7514, 5648, 3788, 1936, 99, 161, 261, 422, 683, 1106, 1790, 2896, 4686, 7583, 12270, 12267,
12261, 12252, 12238, 12214, 12176, 12114, 12014, 11853, 11592, 11169, 10485, 9378, 7587, 4689, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4689, 4689, 4689, 4689, 4689, 4689, 4689, 4689, 4689,
4689, 4689, 4689, 4689, 4689, 4689, 4689, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 2, 3, 5, 8, 14, 23, 38, 61, 99, 161, 261, 422, 683, 1106, 1790, 2896, 4686, 7583,
12270, 12267, 12261, 12252, 12238, 12214, 12176, 12114, 12014, 11853, 11592, 11169, 10485, 9378,
7587, 4689, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4689, 4689, 4689, 4689, 4689, 4689,
4689, 4689, 4689, 4689, 4689, 4689, 4689, 4689, 4689, 4689, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 4, 5, 6, 8, 10, 14, 17, 23, 28, 37, 46, 60,
74, 97, 120, 158, 195, 255, 316, 413, 511, 669, 827, 1083, 1339, 1752, 2166, 2836, 3505, 4589, 5672,
7425, 9178, 12014, 14851, 19440, 24029, 23868, 23706, 23445, 23184, 22761, 22338, 21654, 20970,
19863, 18756, 16965, 15174, 12276, 9378, 4689, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4689, 9378, 9378, 9378, 9378, 9378, 9378, 9378, 9378, 9378, 9378, 9378, 9378, 9378, 9378, 9378,
4689, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 2, 2, 3, 3, 4, 5, 5, 7, 8, 9, 11, 13, 15, 18, 21, 24, 30, 35, 40, 48, 56, 65, 78, 92, 105,
127, 149, 170, 206, 241, 275, 334, 390, 446, 540, 631, 722, 874, 1021, 1168, 1415, 1653, 1890, 2290,
2674, 3059, 3705, 4327, 4950, 5995, 7002, 8009, 9701, 11330, 12960, 15696, 18333, 20970, 25397,
29664, 33930, 33507, 32823, 32139, 31455, 30348, 29241, 28134, 26343, 24552, 22761, 19863, 16965,
14067, 9378, 4689, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4689, 9378, 14067, 14067,
14067, 14067, 14067, 14067, 14067, 14067, 14067, 14067, 14067, 14067, 14067, 14067, 9378, 4689, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 7, 7, 8, 9, 10, 11, 12, 13, 15, 16, 18,
20, 21, 24, 27, 29, 32, 35, 39, 44, 48, 52, 56, 64, 71, 78, 85, 92, 104, 115, 126, 137, 149, 169,
187, 205, 223, 241, 273, 302, 332, 361, 390, 442, 490, 537, 584, 631, 716, 792, 869, 945, 1021,
1159, 1283, 1406, 1529, 1653, 1876, 2075, 2275, 2475, 2674, 3035, 3358, 3681, 4004, 4327, 4912,
5434, 5957, 6480, 7002, 7948, 8793, 9639, 10485, 11330, 12860, 14228, 15596, 16965, 18333, 20808,
23022, 25236, 27450, 29664, 33669, 37251, 40833, 44415, 47997, 46890, 45099, 43308, 41517, 39726,
37935, 35037, 32139, 29241, 26343, 23445, 18756, 14067, 9378, 4689, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 4689, 9378, 14067, 18756, 23445, 23445, 23445, 23445, 23445, 23445, 23445, 23445,
23445, 23445, 23445, 23445, 18756, 14067, 9378, 4689, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10,
11, 12, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 26, 27, 29, 31, 33, 36, 38, 40, 42, 44, 47,
51, 54, 58, 61, 65, 68, 72, 77, 83, 88, 94, 99, 105, 110, 116, 125, 134, 143, 152, 161, 170, 179,
188, 203, 217, 232, 246, 261, 275, 290, 305, 328, 352, 375, 399, 422, 446, 469, 493, 531, 569, 607,
646, 684, 722, 760, 798, 860, 921, 983, 1045, 1106, 1168, 1230, 1292, 1391, 1491, 1591, 1691, 1791,
1890, 1990, 2090, 2252, 2413, 2575, 2736, 2898, 3059, 3221, 3382, 3643, 3905, 4166, 4427, 4689,
4950, 5211, 5473, 5895, 6318, 6741, 7164, 7587, 8009, 8432, 8855, 9539, 10223, 10907, 11592, 12276,
12960, 13644, 14328, 15435, 16542, 17649, 18756, 19863, 20970, 22077, 23184, 24975, 26766, 28557,
30348, 32139, 33930, 35721, 37512, 40410, 43308, 46206, 49104, 52002, 54900, 57798, 60696, 57798,
54900, 52002, 49104, 46206, 43308, 40410, 37512, 32823, 28134, 23445, 18756, 14067, 9378, 4689, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4689, 9378, 14067, 18756, 23445, 28134, 32823,
37512, 37512, 37512, 37512, 37512, 37512, 37512, 37512, 37512, 32823, 28134, 23445, 18756, 14067,
9378, 4689, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4,
4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 14, 15,
15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 22, 23, 24, 25, 25, 26, 27, 28, 29, 29, 30, 31, 33, 35, 37,
39, 40, 41, 43, 44, 45, 47, 48, 49, 51, 54, 57, 61, 63, 65, 67, 69, 72, 74, 76, 78, 80, 82, 88, 93,
99, 102, 106, 109, 113, 116, 119, 123, 126, 130, 133, 142, 151, 160, 166, 171, 177, 182, 188, 194,
199, 205, 210, 216, 230, 245, 260, 269, 278, 287, 296, 305, 314, 323, 332, 341, 350, 373, 397, 420,
435, 449, 464, 478, 493, 508, 522, 537, 551, 566, 604, 642, 680, 704, 727, 751, 774, 798, 822, 845,
869, 892, 916, 978, 1039, 1101, 1139, 1177, 1215, 1253, 1292, 1330, 1368, 1406, 1444, 1482, 1582,
1682, 1782, 1843, 1905, 1967, 2028, 2090, 2152, 2213, 2275, 2337, 2398, 2560, 2721, 2883, 2983,
3083, 3182, 3282, 3382, 3482, 3582, 3681, 3781, 3881, 4142, 4404, 4665, 4827, 4988, 5150, 5311,
5473, 5634, 5796, 5957, 6119, 6280, 6703, 7126, 7548, 7810, 8071, 8332, 8594, 8855, 9116, 9378,
9639, 9900, 10162, 10846, 11530, 12214, 12637, 13060, 13482, 13905, 14328, 14751, 15174, 15596,
16019, 16442, 17549, 18656, 19763, 20447, 21131, 21815, 22499, 23184, 23868, 24552, 25236, 25920,
26604, 28395, 30186, 31977, 33084, 34191, 35298, 36405, 37512, 38619, 39726, 40833, 41940, 43047,
45945, 48843, 51741, 53532, 55323, 57114, 58905, 60696, 62487, 64278, 66069, 67860, 69651, 66753,
63855, 60957, 56268, 51579, 46890, 42201, 37512, 32823, 28134, 23445, 18756, 14067, 9378, 4689, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4689, 9378, 14067, 18756, 23445, 28134, 32823,
37512, 42201, 46890, 51579, 56268, 60957, 60957, 60957, 60957, 56268, 51579, 46890, 42201, 37512,
32823, 28134, 23445, 18756, 14067, 9378, 4689, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6,
6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13,
13, 13, 13, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 21, 21, 21,
21, 21, 22, 23, 24, 25, 25, 26, 27, 28, 29, 29, 30, 31, 32, 33, 34, 34, 34, 34, 34, 34, 35, 36, 37,
39, 40, 41, 43, 44, 45, 47, 48, 49, 51, 52, 53, 55, 55, 55, 55, 55, 55, 57, 59, 61, 63, 65, 67, 69,
72, 74, 76, 78, 80, 82, 84, 86, 89, 89, 89, 89, 89, 89, 92, 95, 99, 102, 106, 109, 113, 116, 119,
123, 126, 130, 133, 137, 140, 144, 144, 144, 144, 144, 144, 149, 155, 160, 166, 171, 177, 182, 188,
194, 199, 205, 210, 216, 221, 227, 233, 233, 233, 233, 233, 233, 242, 251, 260, 269, 278, 287, 296,
305, 314, 323, 332, 341, 350, 359, 368, 377, 377, 377, 377, 377, 377, 391, 406, 420, 435, 449, 464,
478, 493, 508, 522, 537, 551, 566, 580, 595, 610, 610, 610, 610, 610, 610, 633, 657, 680, 704, 727,
751, 774, 798, 822, 845, 869, 892, 916, 939, 963, 987, 987, 987, 987, 987, 987, 1025, 1063, 1101,
1139, 1177, 1215, 1253, 1292, 1330, 1368, 1406, 1444, 1482, 1520, 1558, 1597, 1597, 1597, 1597,
1597, 1597, 1658, 1720, 1782, 1843, 1905, 1967, 2028, 2090, 2152, 2213, 2275, 2337, 2398, 2460,
2522, 2584, 2584, 2584, 2584, 2584, 2584, 2683, 2783, 2883, 2983, 3083, 3182, 3282, 3382, 3482,
3582, 3681, 3781, 3881, 3981, 4081, 4181, 4181, 4181, 4181, 4181, 4181, 4342, 4504, 4665, 4827,
4988, 5150, 5311, 5473, 5634, 5796, 5957, 6119, 6280, 6442, 6603, 6765, 6765, 6765, 6765, 6765,
6765, 7026, 7287, 7548, 7810, 8071, 8332, 8594, 8855, 9116, 9378, 9639, 9900, 10162, 10423, 10684,
10946, 10946, 10946, 10946, 10946, 10946, 11368, 11791, 12214, 12637, 13060, 13482, 13905, 14328,
14751, 15174, 15596, 16019, 16442, 16865, 17288, 17711, 17711, 17711, 17711, 17711, 17711, 18395,
19079, 19763, 20447, 21131, 21815, 22499, 23184, 23868, 24552, 25236, 25920, 26604, 27288, 27972,
28657, 28657, 28657, 28657, 28657, 28657, 29763, 30870, 31977, 33084, 34191, 35298, 36405, 37512,
38619, 39726, 40833, 41940, 43047, 44154, 45261, 46368, 46368, 46368, 46368, 46368, 46368, 48159,
49950, 51741, 53532, 55323, 57114, 58905, 60696, 62487, 64278, 66069, 67860, 69651, 71442, 73233,
75025, 75025, 75025, 75025, 75025, 75025, 70335, 65646, 60957, 56268, 51579, 46890, 42201, 37512,
32823, 28134, 23445, 18756, 14067, 9378, 4689, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4689, 9378, 14067, 18756, 23445, 28134, 32823, 37512, 42201, 46890, 51579, 56268, 60957, 65646,
70335, 75025, 75025, 75025, 75025, 75025, 75025, 70335, 65646, 60957, 56268, 51579, 46890, 42201,
37512, 32823, 28134, 23445, 18756, 14067, 9378, 4689, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 4689, 9378, 14067, 18756, 23445, 28134, 32823, 37512, 42201, 46890, 51579, 56268, 60957,
65646, 70335, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 70335, 70335, 70335, 70335, 70335, 70335, 70335, 70335, 70335,
70335, 70335, 70335, 70335, 70335, 70335, 70335, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 73233, 70335, 66753,
62748, 58482, 54054, 49527, 44938, 40310, 35659, 30994, 26319, 21639, 16956, 12270, 7583, 4686,
2896, 1790, 1106, 683, 422, 261, 161, 99, 4750, 9416, 14090, 18770, 23454, 28139, 32826, 37514,
42202, 46891, 51580, 56269, 60957, 65646, 70335, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 70335, 70335, 70335, 70335,
70335, 70335, 70335, 70335, 70335, 70335, 70335, 70335, 70335, 70335, 70335, 70335, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 73233, 70335, 66753, 62748, 58482, 54054, 49527, 44938, 40310, 35659, 30994, 26319,
21639, 16956, 12270, 7583, 4686, 2896, 1790, 1106, 683, 422, 261, 161, 99, 4750, 9416, 14090, 18770,
23454, 28139, 32826, 37514, 42202, 46891, 51580, 56269, 60957, 65646, 70335, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
70335, 65646, 65646, 65646, 65646, 65646, 65646, 65646, 65646, 65646, 65646, 65646, 65646, 65646,
65646, 65646, 70335, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 73233, 71442, 68544, 65646, 62064, 58482,
54477, 50472, 46206, 41940, 37512, 33084, 28557, 24029, 19440, 14851, 12014, 9178, 7425, 5672, 4589,
3505, 2836, 2166, 1752, 1339, 1083, 827, 669, 511, 413, 316, 255, 195, 158, 120, 97, 74, 60, 46, 37,
28, 23, 17, 14, 10, 8, 6, 5, 4, 4692, 9380, 14069, 18757, 23446, 28135, 32824, 37513, 42201, 46890,
51579, 56268, 60957, 65646, 70335, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 70335, 65646, 60957, 60957, 60957, 60957,
60957, 60957, 60957, 60957, 60957, 60957, 60957, 60957, 60957, 60957, 65646, 70335, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 73233, 71442, 69651, 66753, 63855, 60957, 57375, 53793, 50211, 46206,
42201, 38196, 33930, 29664, 25397, 20970, 18333, 15696, 12960, 11330, 9701, 8009, 7002, 5995, 4950,
4327, 3705, 3059, 2674, 2290, 1890, 1653, 1415, 1168, 1021, 874, 722, 631, 540, 446, 390, 334, 275,
241, 206, 170, 149, 127, 105, 92, 78, 65, 56, 48, 40, 35, 30, 24, 21, 18, 15, 13, 11, 9, 8, 7, 5, 5,
4, 3, 3, 2, 2, 1, 1, 4690, 9379, 14068, 18757, 23445, 28134, 32823, 37512, 42201, 46890, 51579,
56268, 60957, 65646, 70335, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 70335, 65646, 60957, 56268, 51579, 51579, 51579,
51579, 51579, 51579, 51579, 51579, 51579, 51579, 51579, 51579, 56268, 60957, 65646, 70335, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 73233, 71442, 69651, 67860, 66069, 63171, 60273,
57375, 54477, 51579, 47997, 44415, 40833, 37251, 33669, 29664, 27450, 25236, 23022, 20808, 18333,
16965, 15596, 14228, 12860, 11330, 10485, 9639, 8793, 7948, 7002, 6480, 5957, 5434, 4912, 4327,
4004, 3681, 3358, 3035, 2674, 2475, 2275, 2075, 1876, 1653, 1529, 1406, 1283, 1159, 1021, 945, 869,
792, 716, 631, 584, 537, 490, 442, 390, 361, 332, 302, 273, 241, 223, 205, 187, 169, 149, 137, 126,
115, 104, 92, 85, 78, 71, 64, 56, 52, 48, 44, 39, 35, 32, 29, 27, 24, 21, 20, 18, 16, 15, 13, 12,
11, 10, 9, 8, 7, 7, 6, 5, 5, 4, 4, 4, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 4689, 9378,
14067, 18756, 23445, 28134, 32823, 37512, 42201, 46890, 51579, 56268, 60957, 65646, 70335, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 70335, 65646, 60957, 56268, 51579, 46890, 42201, 37512, 37512, 37512, 37512, 37512,
37512, 37512, 37512, 37512, 42201, 46890, 51579, 56268, 60957, 65646, 70335, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 73233, 71442, 69651, 67860, 66069, 64278,
62487, 60696, 57798, 54900, 52002, 49104, 46206, 43308, 40410, 37512, 35721, 33930, 32139, 30348,
28557, 26766, 24975, 23184, 22077, 20970, 19863, 18756, 17649, 16542, 15435, 14328, 13644, 12960,
12276, 11592, 10907, 10223, 9539, 8855, 8432, 8009, 7587, 7164, 6741, 6318, 5895, 5473, 5211, 4950,
4689, 4427, 4166, 3905, 3643, 3382, 3221, 3059, 2898, 2736, 2575, 2413, 2252, 2090, 1990, 1890,
1791, 1691, 1591, 1491, 1391, 1292, 1230, 1168, 1106, 1045, 983, 921, 860, 798, 760, 722, 684, 646,
607, 569, 531, 493, 469, 446, 422, 399, 375, 352, 328, 305, 290, 275, 261, 246, 232, 217, 203, 188,
179, 170, 161, 152, 143, 134, 125, 116, 110, 105, 99, 94, 88, 83, 77, 72, 68, 65, 61, 58, 54, 51,
47, 44, 42, 40, 38, 36, 33, 31, 29, 27, 26, 24, 23, 22, 20, 19, 18, 17, 16, 15, 14, 13, 12, 12, 11,
10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 4689, 9378, 14067, 18756, 23445, 28134, 32823,
37512, 42201, 46890, 51579, 56268, 60957, 65646, 70335, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 70335, 65646, 60957,
56268, 51579, 46890, 42201, 37512, 32823, 28134, 23445, 18756, 14067, 14067, 14067, 14067, 18756,
23445, 28134, 32823, 37512, 42201, 46890, 51579, 56268, 60957, 65646, 70335, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 73233,
71442, 69651, 67860, 66069, 64278, 62487, 60696, 58905, 57114, 55323, 53532, 51741, 48843, 45945,
43047, 41940, 40833, 39726, 38619, 37512, 36405, 35298, 34191, 33084, 31977, 30186, 28395, 26604,
25920, 25236, 24552, 23868, 23184, 22499, 21815, 21131, 20447, 19763, 18656, 17549, 16442, 16019,
15596, 15174, 14751, 14328, 13905, 13482, 13060, 12637, 12214, 11530, 10846, 10162, 9900, 9639,
9378, 9116, 8855, 8594, 8332, 8071, 7810, 7548, 7126, 6703, 6280, 6119, 5957, 5796, 5634, 5473,
5311, 5150, 4988, 4827, 4665, 4404, 4142, 3881, 3781, 3681, 3582, 3482, 3382, 3282, 3182, 3083,
2983, 2883, 2721, 2560, 2398, 2337, 2275, 2213, 2152, 2090, 2028, 1967, 1905, 1843, 1782, 1682,
1582, 1482, 1444, 1406, 1368, 1330, 1292, 1253, 1215, 1177, 1139, 1101, 1039, 978, 916, 892, 869,
845, 822, 798, 774, 751, 727, 704, 680, 642, 604, 566, 551, 537, 522, 508, 493, 478, 464, 449, 435,
420, 397, 373, 350, 341, 332, 323, 314, 305, 296, 287, 278, 269, 260, 245, 230, 216, 210, 205, 199,
194, 188, 182, 177, 171, 166, 160, 151, 142, 133, 130, 126, 123, 119, 116, 113, 109, 106, 102, 99,
93, 88, 82, 80, 78, 76, 74, 72, 69, 67, 65, 63, 61, 57, 54, 51, 49, 48, 47, 45, 44, 43, 41, 40, 39,
37, 35, 33, 31, 30, 29, 29, 28, 27, 26, 25, 25, 24, 23, 22, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15,
15, 14, 13, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 4,
4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4689,
9378, 14067, 18756, 23445, 28134, 32823, 37512, 42201, 46890, 51579, 56268, 60957, 65646, 70335,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 70335, 65646, 60957, 56268, 51579, 46890, 42201, 37512, 32823, 28134, 23445,
18756, 14067, 9378, 4689, 0, 0, 0, 0, 0, 0, 4689, 9378, 14067, 18756, 23445, 28134, 32823, 37512,
42201, 46890, 51579, 56268, 60957, 65646, 70335, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025, 75025,
75025, 75025, 75025, 73233, 71442, 69651, 67860, 66069, 64278, 62487, 60696, 58905, 57114, 55323,
53532, 51741, 49950, 48159, 46368, 46368, 46368, 46368, 46368, 46368, 45261, 44154, 43047, 41940,
40833, 39726, 38619, 37512, 36405, 35298, 34191, 33084, 31977, 30870, 29763, 28657, 28657, 28657,
28657, 28657, 28657, 27972, 27288, 26604, 25920, 25236, 24552, 23868, 23184, 22499, 21815, 21131,
20447, 19763, 19079, 18395, 17711, 17711, 17711, 17711, 17711, 17711, 17288, 16865, 16442, 16019,
15596, 15174, 14751, 14328, 13905, 13482, 13060, 12637, 12214, 11791, 11368, 10946, 10946, 10946,
10946, 10946, 10946, 10684, 10423, 10162, 9900, 9639, 9378, 9116, 8855, 8594, 8332, 8071, 7810,
7548, 7287, 7026, 6765, 6765, 6765, 6765, 6765, 6765, 6603, 6442, 6280, 6119, 5957, 5796, 5634,
5473, 5311, 5150, 4988, 4827, 4665, 4504, 4342, 4181, 4181, 4181, 4181, 4181, 4181, 4081, 3981,
3881, 3781, 3681, 3582, 3482, 3382, 3282, 3182, 3083, 2983, 2883, 2783, 2683, 2584, 2584, 2584,
2584, 2584, 2584, 2522, 2460, 2398, 2337, 2275, 2213, 2152, 2090, 2028, 1967, 1905, 1843, 1782,
1720, 1658, 1597, 1597, 1597, 1597, 1597, 1597, 1558, 1520, 1482, 1444, 1406, 1368, 1330, 1292,
1253, 1215, 1177, 1139, 1101, 1063, 1025, 987, 987, 987, 987, 987, 987, 963, 939, 916, 892, 869,
845, 822, 798, 774, 751, 727, 704, 680, 657, 633, 610, 610, 610, 610, 610, 610, 595, 580, 566, 551,
537, 522, 508, 493, 478, 464, 449, 435, 420, 406, 391, 377, 377, 377, 377, 377, 377, 368, 359, 350,
341, 332, 323, 314, 305, 296, 287, 278, 269, 260, 251, 242, 233, 233, 233, 233, 233, 233, 227, 221,
216, 210, 205, 199, 194, 188, 182, 177, 171, 166, 160, 155, 149, 144, 144, 144, 144, 144, 144, 140,
137, 133, 130, 126, 123, 119, 116, 113, 109, 106, 102, 99, 95, 92, 89, 89, 89, 89, 89, 89, 86, 84,
82, 80, 78, 76, 74, 72, 69, 67, 65, 63, 61, 59, 57, 55, 55, 55, 55, 55, 55, 53, 52, 51, 49, 48, 47,
45, 44, 43, 41, 40, 39, 37, 36, 35, 34, 34, 34, 34, 34, 34, 33, 32, 31, 30, 29, 29, 28, 27, 26, 25,
25, 24, 23, 22, 21, 21, 21, 21, 21, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14,
13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8,
7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2500, 5000, 7500,
10000, 12500, 15000, 17500, 20000, 22500, 25000, 27500, 30000, 32500, 35000, 37500, 40000, 40000,
40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000,
40000]
def fib(n):
if n in (0, 1):
return n
prev, res = 0, 1
for _ in range(2, n + 1):
prev, res = res, prev + res
return res
v1 = [30000 for _ in range(settle_time)]
for duration in range(1, 9): # fib_1=1 to fib_8=21 for sample duration
for adc_sample in range(0, 26): # fib_0=0 to fib_25=75025 for sample value
v1.extend([fib(adc_sample) for _ in range(fib(duration))])
v1.extend([0 for _ in range(settle_time)])
v1.extend([fib(25) for _ in range(fib(duration))])
v1.extend([0 for _ in range(settle_time)])
for duration in range(1, 9): # fib_1=1 to fib_8=21 for sample duration
v1.extend([fib(25) for _ in range(settle_time)])
v1.extend([0 for _ in range(fib(duration))])
v1.extend([fib(25) for _ in range(settle_time)])
for adc_sample in range(25, -1, -1): # fib_0=0 to fib_25=75025 for sample value
v1.extend([fib(adc_sample) for _ in range(fib(duration))])
v1.extend([40000 for _ in range(settle_time)])
output = []
for v in v1:
filtered_voltage = v_filter.filter_value(v)
self.assertGreaterEqual(filtered_voltage, 0)
self.assertLessEqual(filtered_voltage, fib(25))
output.append(filtered_voltage)
if __debug__:
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.use('Qt5Agg')
plt.ion()
plt.plot(v1, label='Sample')
plt.plot(output, label='Averaged')
plt.grid()
plt.legend(loc="upper left")
self.assertEqual(output, expected)
if __name__ == '__main__':
unittest.main()