David Blume commited on 2020-12-30 22:07:01
Showing 1 changed files, with 8 additions and 6 deletions.
| ... | ... |
@@ -7,6 +7,7 @@ import operator |
| 7 | 7 |
import subprocess |
| 8 | 8 |
import platform |
| 9 | 9 |
import webbrowser |
| 10 |
+from typing import List, Tuple |
|
| 10 | 11 |
|
| 11 | 12 |
|
| 12 | 13 |
html = """<html> |
| ... | ... |
@@ -47,7 +48,7 @@ html = """<html> |
| 47 | 48 |
</html>""" |
| 48 | 49 |
|
| 49 | 50 |
|
| 50 |
-def calculate_median_mean_stddev_from_samples(values): |
|
| 51 |
+def calculate_median_mean_stddev_from_samples(values: List[int]) -> Tuple[float, float, float]: |
|
| 51 | 52 |
""" returns the median, mean, and standard deviation of values """ |
| 52 | 53 |
# Calculate the median |
| 53 | 54 |
values.sort() |
| ... | ... |
@@ -70,7 +71,7 @@ def calculate_median_mean_stddev_from_samples(values): |
| 70 | 71 |
return median, mean, std_dev |
| 71 | 72 |
|
| 72 | 73 |
|
| 73 |
-def calculate_median_mean_stddev(x, y): |
|
| 74 |
+def calculate_median_mean_stddev(x: List[float], y: List[int]) -> Tuple[float, float, float]: |
|
| 74 | 75 |
""" returns the median, mean, and standard deviation given |
| 75 | 76 |
an array of values, x, and an array of counts of those values, y. """ |
| 76 | 77 |
# Median: Walk the sample counts (y) halfway to the sum of sample counts. |
| ... | ... |
@@ -91,7 +92,7 @@ def calculate_median_mean_stddev(x, y): |
| 91 | 92 |
return median, mean, std_dev |
| 92 | 93 |
|
| 93 | 94 |
|
| 94 |
-def remove_outliers_by_idx(x, y, outlier_count, idx): |
|
| 95 |
+def remove_outliers_by_idx(x: List[float], y: List[int], outlier_count: int, idx: int) -> None: |
|
| 95 | 96 |
"""Removes outlier_count samples from idx side of the buckets.""" |
| 96 | 97 |
cur_count = 0 |
| 97 | 98 |
while cur_count + y[idx] < outlier_count: |
| ... | ... |
@@ -102,7 +103,7 @@ def remove_outliers_by_idx(x, y, outlier_count, idx): |
| 102 | 103 |
y[idx] = y[idx] - (outlier_count - cur_count) |
| 103 | 104 |
|
| 104 | 105 |
|
| 105 |
-def remove_outliers(x, y, outlier_percentile): |
|
| 106 |
+def remove_outliers(x: List[float], y: List[int], outlier_percentile: int) -> None: |
|
| 106 | 107 |
"""Removes outlier_percentile samples from the beginning and end |
| 107 | 108 |
of the sample set.""" |
| 108 | 109 |
outlier_count = sum(y) * outlier_percentile // 100 |
| ... | ... |
@@ -110,7 +111,8 @@ def remove_outliers(x, y, outlier_percentile): |
| 110 | 111 |
remove_outliers_by_idx(x, y, outlier_count, -1) |
| 111 | 112 |
|
| 112 | 113 |
|
| 113 |
-def acquire_data(buckets): |
|
| 114 |
+def acquire_data(buckets: int) -> Tuple[List[float], List[float], List[int]]: |
|
| 115 |
+ """Manufactures some fake data.""" |
|
| 114 | 116 |
x = [i*10 for i in range(1,buckets+1)] |
| 115 | 117 |
y = [] |
| 116 | 118 |
for i in range(0, buckets // 4): |
| ... | ... |
@@ -125,7 +127,7 @@ def acquire_data(buckets): |
| 125 | 127 |
return samples, x, y |
| 126 | 128 |
|
| 127 | 129 |
|
| 128 |
-def main(renderer): |
|
| 130 |
+def main(renderer: str) -> None: |
|
| 129 | 131 |
buckets = 20 |
| 130 | 132 |
samples, x, y = acquire_data(buckets) |
| 131 | 133 |
|
| 132 | 134 |