Commit 6c6b6f65 authored by Stephen Pearce's avatar Stephen Pearce Committed by Maxim Belkin

code/readings_07.py: Harmonise with lesson text (#750)

parent 0b6a30c1
import sys
import numpy
def main():
script = sys.argv[0]
action = sys.argv[1]
......@@ -11,23 +10,21 @@ def main():
if len(filenames) == 0:
process(sys.stdin, action)
else:
for f in filenames:
process(f, action)
for filename in filenames:
process(filename, action)
def process(filename, action):
data = numpy.loadtxt(filename, delimiter=',')
if action == '-n':
values = data.min(axis=1)
values = numpy.min(data, axis=1)
elif action == '-m':
values = data.mean(axis=1)
values = numpy.mean(data, axis=1)
elif action == '-x':
values = data.max(axis=1)
for m in values:
print(m)
values = numpy.max(data, axis=1)
for val in values:
print(val)
if __name__ == '__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