forked from BME1478H/Fall2022class
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.py
32 lines (25 loc) · 857 Bytes
/
stats.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
import sys
import numpy
def main():
script = sys.argv[0]
action = sys.argv[1]
filenames = sys.argv[2:]
assert action in ['--min', '--mean', '--max'], \
'Action is not one of --min, --mean, or --max: ' + action
if len(filenames) == 0:
stats_inflammation(sys.stdin, action)
else:
for filename in filenames:
stats_inflammation(filename, action)
def stats_inflammation(filename,action):
data = numpy.loadtxt(filename, delimiter=',')
if action == '--min':
values = numpy.min(data, axis=1)
elif action == '--mean':
values = numpy.mean(data, axis=1)
elif action == '--max':
values = numpy.max(data, axis=1)
for val in values:
print(val)
if __name__ == '__main__':
main()