From b4910473b2eb26db7a09a44b8299fa298db85a44 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 2 Jun 2016 16:36:10 -0500 Subject: [PATCH] Throw ImportError if user has h5py 2.6.0. --- openmc/particle_restart.py | 5 +++++ openmc/statepoint.py | 5 +++++ openmc/summary.py | 4 ++++ openmc/tallies.py | 4 ++++ 4 files changed, 18 insertions(+) diff --git a/openmc/particle_restart.py b/openmc/particle_restart.py index 72bf3ac3de..7a27db2f60 100644 --- a/openmc/particle_restart.py +++ b/openmc/particle_restart.py @@ -37,6 +37,11 @@ class Particle(object): def __init__(self, filename): import h5py + if h5py.__version__ == '2.6.0': + raise ImportError("h5py 2.6.0 has a known bug which makes it " + "incompatible with OpenMC's HDF5 files. " + "Please switch to a different version.") + self._f = h5py.File(filename, 'r') # Ensure filetype and revision are correct diff --git a/openmc/statepoint.py b/openmc/statepoint.py index 14a48e7f6d..0baa631581 100644 --- a/openmc/statepoint.py +++ b/openmc/statepoint.py @@ -106,6 +106,11 @@ class StatePoint(object): def __init__(self, filename, autolink=True): import h5py + if h5py.__version__ == '2.6.0': + raise ImportError("h5py 2.6.0 has a known bug which makes it " + "incompatible with OpenMC's HDF5 files. " + "Please switch to a different version.") + self._f = h5py.File(filename, 'r') # Ensure filetype and revision are correct diff --git a/openmc/summary.py b/openmc/summary.py index 2af9b6be6f..d5259247fe 100644 --- a/openmc/summary.py +++ b/openmc/summary.py @@ -26,6 +26,10 @@ class Summary(object): # Python API so we'll only try to import h5py if the user actually inits # a Summary object. import h5py + if h5py.__version__ == '2.6.0': + raise ImportError("h5py 2.6.0 has a known bug which makes it " + "incompatible with OpenMC's HDF5 files. " + "Please switch to a different version.") openmc.reset_auto_ids() diff --git a/openmc/tallies.py b/openmc/tallies.py index 2313a61734..38aa0bf12c 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -314,6 +314,10 @@ class Tally(object): if not self._results_read: import h5py + if h5py.__version__ == '2.6.0': + raise ImportError("h5py 2.6.0 has a known bug which makes it " + "incompatible with OpenMC's HDF5 files. " + "Please switch to a different version.") # Open the HDF5 statepoint file f = h5py.File(self._sp_filename, 'r')