Skip to content

Commit 4aba3d8

Browse files
author
Robert D. Vincent
committed
BF: Some NetCDF variables have no data allocated - they end up having a shape with a single element set to zero. Assigning an _empty_ shape triggers an exception in this case. We now harmlessly avoid the assignment in these cases.
1 parent 1fc32c3 commit 4aba3d8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

nibabel/externals/netcdf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,10 @@ def _read_var_array(self):
607607
pos = self.fp.tell()
608608
self.fp.seek(begin_)
609609
data = fromstring(self.fp.read(a_size), dtype=dtype_)
610-
data.shape = shape
610+
# Avoid exception for empty variables.
611+
if len(data.shape) != 1 or data.shape[0] != 0:
612+
data.shape = shape
613+
611614
self.fp.seek(pos)
612615

613616
# Add variable.

0 commit comments

Comments
 (0)