Fix code to aggregate stats
Change-Id: I9f64aad7bb9f3961cf116d2f324e15818e140616
(cherry picked from commit 87461eaa6ecdfc247d3068abb0c1e1c5353794e2)
diff --git a/tools/aggregate_entropy_stats.py b/tools/aggregate_entropy_stats.py
index 7cb4d18..44a34c4 100644
--- a/tools/aggregate_entropy_stats.py
+++ b/tools/aggregate_entropy_stats.py
@@ -21,19 +21,19 @@
import numpy as np
def main():
- dir = sys.argv[1]
- sum = []
- for fn in os.listdir(dir):
- if sys.argv[2] in fn:
- stats = np.fromfile(dir + fn, dtype=np.int32)
- if len(sum) == 0:
- sum = stats
- else:
- sum = np.add(sum, stats)
- if len(sum) == 0:
- print("No stats file is found. Double-check directory and keyword?")
- else:
- sum.tofile(dir+sys.argv[3])
+ dir = sys.argv[1]
+ sum = []
+ for fn in os.listdir(dir):
+ if sys.argv[2] in fn:
+ stats = np.fromfile(os.path.join(dir, fn), dtype=np.int32)
+ if len(sum) == 0:
+ sum = stats
+ else:
+ sum = np.add(sum, stats)
+ if len(sum) == 0:
+ print("No stats file is found. Double-check directory and keyword?")
+ else:
+ sum.tofile(sys.argv[3])
if __name__ == '__main__':
main()