-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnpy_load_in_shell.py
More file actions
41 lines (35 loc) · 1.07 KB
/
npy_load_in_shell.py
File metadata and controls
41 lines (35 loc) · 1.07 KB
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
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
"""
This script opens an interactive shell with the NPY file loaded as the array A.
If multiple files are passed, then it builds a dictionary of arrays,
where each array can be accessed in order : A[0], A[1], etc.
It also displays the array(s) and gives some statistics.
PyPlot is preloaded so that you don't have to type it.
"""
import os
import sys
print("Python version:",sys.version)
print("Python interpreter:",sys.executable)
try:
import numpy as np
except ImportError as error:
print(error)
input("Press any key to exit")
exit()
A = []
for i in range(0,len(sys.argv)-1):
file = sys.argv[i+1]
A.append(np.load(file))
print(os.path.basename(file)," :\n")
print(A[i])
print("shape \t=",A[i].shape)
print("min \t=",np.min(A[i]))
print("max \t=",np.max(A[i]))
print("abs_min\t=",np.min(np.abs(A[i])))
print("mean \t=",np.mean(A[i]))
print("median \t=",np.median(A[i]))
print("std_dev\t=",np.std(A[i]))
print("\n")
# If only one array is passed, don't use a dictionary
if len(sys.argv) == 2:
A = A[0]