Inspect npz

This commit is contained in:
2021-06-28 11:07:52 +02:00
parent e698ad9319
commit ef68cae1c0

View File

@@ -24,6 +24,32 @@ alias ls='ls --color=auto'
# Define a OS X-like open command
open() { command xdg-open "$@" > /dev/null 2>&1 & }
# Inspect .npz files
npz_py_str="$(cat << EOM
from sys import argv
class Wrap:
def __init__(self, fname):
import numpy as np
n = np.load(fname, allow_pickle=True)
files = n.files
print('Contains files', files)
for f in files:
setattr(self, f, n[f])
d = Wrap(argv[1])
EOM
)"
npz_preview() {
if [ $# -lt 1 ]; then
echo "Please specify file to open as argument"
return
fi
python -ic "$npz_py_str" "$1"
}
# Source git prompt
source_existing ~/scripts/git-prompt.sh
source_existing ~/.bash_prompt.kuba