mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Allow Python API to be used without h5py
This commit is contained in:
parent
04e2c1960b
commit
8e197546ba
1 changed files with 10 additions and 5 deletions
|
|
@ -2,17 +2,22 @@ import numpy as np
|
|||
|
||||
import openmc
|
||||
|
||||
try:
|
||||
import h5py
|
||||
except ImportError:
|
||||
msg = 'Unable to import h5py which is needed by openmc.summary'
|
||||
raise ImportError(msg)
|
||||
|
||||
_h5_imported = False
|
||||
|
||||
|
||||
class Summary(object):
|
||||
|
||||
def __init__(self, filename):
|
||||
|
||||
if not _h5_imported:
|
||||
try:
|
||||
import h5py
|
||||
_h5_imported = True
|
||||
except ImportError:
|
||||
msg = 'Unable to import h5py which is needed by openmc.summary'
|
||||
raise ImportError(msg)
|
||||
|
||||
openmc.reset_auto_ids()
|
||||
|
||||
if not filename.endswith(('.h5', '.hdf5')):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue