Skip to content

Commit 4610505

Browse files
committed
python: quiet h5py missing
1 parent fea917b commit 4610505

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

tests/GetShape.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
inquire(file=fn, exist=exists)
2222
if (.not. exists) then
23-
write(stderr, '(A,A)'), fn, ' is not a file.'
23+
write(stderr, *) fn // ' is not a file.'
2424
error stop 77
2525
endif
2626

tests/GetShapes.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
import subprocess
44
import argparse
55
import sys
6-
import h5py
76
from pathlib import Path
7+
try:
8+
import h5py
9+
except ImportError:
10+
h5py = None
811

912

1013
p = argparse.ArgumentParser()
@@ -21,9 +24,10 @@
2124
print("h5ls tool:")
2225
subprocess.run(["h5ls", f"{fn}/{P.var}"])
2326

24-
with h5py.File(fn, "r") as f:
25-
print("h5py")
26-
print(f[P.var].shape)
27+
if h5py is not None:
28+
with h5py.File(fn, "r") as f:
29+
print("h5py")
30+
print(f[P.var].shape)
2731

2832

2933
if shutil.which("octave-cli"):

0 commit comments

Comments
 (0)