Commit 0b6a30c1 authored by Stephen Pearce's avatar Stephen Pearce Committed by Maxim Belkin
Browse files

code/readings_06.py: Harmonise with lesson text (#749)

parent 79df0eff
import sys import sys
import numpy import numpy
def main(): def main():
script = sys.argv[0] script = sys.argv[0]
action = sys.argv[1] action = sys.argv[1]
...@@ -11,23 +10,21 @@ def main(): ...@@ -11,23 +10,21 @@ def main():
if len(filenames) == 0: if len(filenames) == 0:
process(sys.stdin, action) process(sys.stdin, action)
else: else:
for f in filenames: for filename in filenames:
process(f, action) process(filename, action)
def process(filename, action): def process(filename, action):
data = numpy.loadtxt(filename, delimiter=',') data = numpy.loadtxt(filename, delimiter=',')
if action == '--min': if action == '--min':
values = data.min(axis=1) values = numpy.min(data, axis=1)
elif action == '--mean': elif action == '--mean':
values = data.mean(axis=1) values = numpy.mean(data, axis=1)
elif action == '--max': elif action == '--max':
values = data.max(axis=1) values = numpy.max(data, axis=1)
for m in values:
print(m)
for val in values:
print(val)
if __name__ == '__main__': if __name__ == '__main__':
main() main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment