Commit c1bc917
authored
Improve resampler structure and performance (#1242)
This pull request splits the `resampling` module into many submodules as
it was getting very large
If also uses tuples internally to store and calculate samples, which
improves performance and simplifies the logic, as `Sample`s can have
`None` values, but the values in the internal buffer can never be
`None`, and we don't need to use a `Quantity` as we know we are always
working with the same units.
It also exposes the `ResamplingFunction` and `SourceProperties` types,
converts `ResamplingFunction` to a `Protocol`, and replaces `average` as
the default resampling function with Python's `statistics.fmean`, among
other small improvements and fixes.File tree
25 files changed
+558
-415
lines changed- benchmarks/timeseries
- examples
- src/frequenz/sdk
- actor
- microgrid
- _power_distributing
- _component_status
- _distribution_algorithm
- _power_managing
- timeseries
- _resampling
- _ringbuffer
- battery_pool
- tests
- microgrid
- timeseries
25 files changed
+558
-415
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
18 | 13 | | |
19 | 14 | | |
20 | 15 | | |
21 | | - | |
| 16 | + | |
22 | 17 | | |
23 | 18 | | |
24 | 19 | | |
| |||
43 | 38 | | |
44 | 39 | | |
45 | 40 | | |
| 41 | + | |
46 | 42 | | |
47 | 43 | | |
48 | | - | |
49 | | - | |
| 44 | + | |
| 45 | + | |
50 | 46 | | |
51 | 47 | | |
52 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | | - | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
122 | 124 | | |
123 | 125 | | |
124 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
597 | 597 | | |
598 | 598 | | |
599 | 599 | | |
600 | | - | |
| 600 | + | |
601 | 601 | | |
602 | 602 | | |
603 | 603 | | |
| |||
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | | - | |
398 | 397 | | |
| 398 | + | |
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
408 | 407 | | |
409 | 408 | | |
410 | 409 | | |
| |||
417 | 416 | | |
418 | 417 | | |
419 | 418 | | |
420 | | - | |
421 | 419 | | |
| 420 | + | |
422 | 421 | | |
423 | 422 | | |
424 | 423 | | |
| |||
439 | 438 | | |
440 | 439 | | |
441 | 440 | | |
442 | | - | |
443 | 441 | | |
444 | 442 | | |
445 | 443 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
461 | 461 | | |
462 | 462 | | |
463 | 463 | | |
464 | | - | |
| 464 | + | |
| 465 | + | |
465 | 466 | | |
466 | 467 | | |
467 | 468 | | |
| |||
470 | 471 | | |
471 | 472 | | |
472 | 473 | | |
473 | | - | |
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
| 36 | + | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
162 | 161 | | |
163 | 162 | | |
164 | 163 | | |
165 | 164 | | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
| |||
176 | 177 | | |
177 | 178 | | |
178 | 179 | | |
| 180 | + | |
179 | 181 | | |
180 | | - | |
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | 12 | | |
17 | 13 | | |
18 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
0 commit comments