From e16fd6b02e296c2a5d15a92551d9a25d4f43c2e6 Mon Sep 17 00:00:00 2001 From: Jeff Whitaker Date: Sun, 7 Apr 2019 15:22:06 -0600 Subject: [PATCH] fix for issue #906 --- netCDF4/utils.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/netCDF4/utils.py b/netCDF4/utils.py index 38204bc2b..ab90c78f6 100644 --- a/netCDF4/utils.py +++ b/netCDF4/utils.py @@ -139,7 +139,7 @@ def _StartCountStride(elem, shape, dimensions=None, grp=None, datashape=None,\ grp : netCDF Group The netCDF group to which the variable being set belongs to. datashape : sequence - The shape of the data that is being stored. Only needed by __setitime__ + The shape of the data that is being stored. Only needed by __setitem__ put : True|False (default False). If called from __setitem__, put is True. Returns @@ -342,6 +342,16 @@ def _StartCountStride(elem, shape, dimensions=None, grp=None, datashape=None,\ else: sdim.append(1) + # pad datashape with zeros for dimensions not being sliced + datashapenew = (); i=0 + for e in elem: + if type(e) != slice: + datashapenew = datashapenew + (0,) + else: + datashapenew = datashapenew + (datashape[i],) + i+=1 + datashape = datashapenew + # Create the start, count, stride and indices arrays. sdim.append(max(nDims, 1))