Inspect npz
This commit is contained in:
26
.bashrc.kuba
26
.bashrc.kuba
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user