Skip to content

Commit 29bdb59

Browse files
authored
Merge pull request #889 from yarikoptic/opt-h5py-import
RF: Delay import of h5py for Minc2 until needed
2 parents bcce691 + bb9cb15 commit 29bdb59

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

nibabel/minc2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
"""
2828
import numpy as np
2929

30-
from ._h5py_compat import h5py
31-
3230
from .minc1 import Minc1File, MincHeader, Minc1Image, MincError
3331

3432

@@ -158,6 +156,9 @@ class Minc2Image(Minc1Image):
158156

159157
@classmethod
160158
def from_file_map(klass, file_map, *, mmap=True, keep_file_open=None):
159+
# Import of h5py might take awhile for MPI-enabled builds
160+
# So we are importing it here "on demand"
161+
from ._h5py_compat import h5py
161162
holder = file_map['image']
162163
if holder.filename is None:
163164
raise MincError('MINC2 needs filename for load')

0 commit comments

Comments
 (0)