Skip to content

Commit

Permalink
Merge pull request #924 from Unidata/issue922
Browse files Browse the repository at this point in the history
fix for issue #922
  • Loading branch information
jswhit authored May 6, 2019
2 parents 9747532 + 5004e70 commit f7bd1d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
since version 1.5.1.1
==============================
* fix another slicing bug introduced by the fix to issue #906 (issue #922).

version 1.5.1.1 (tag v1.5.1.1rel)
==================================
* fixed __version__ attribute (was set incorrectly in 1.5.1 release).
Expand Down
19 changes: 12 additions & 7 deletions netCDF4/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,14 @@ def _StartCountStride(elem, shape, dimensions=None, grp=None, datashape=None,\
datashape = broadcasted_shape(shape, datashape)

# pad datashape with zeros for dimensions not being sliced (issue #906)
if datashape:
# only used when data covers slice over subset of dimensions
if datashape and len(datashape) != len(elem) and\
len(datashape) == sum(1 for e in elem if type(e) == slice):
datashapenew = (); i=0
for e in elem:
if type(e) != slice:
if type(e) != slice and not np.iterable(e): # scalar integer slice
datashapenew = datashapenew + (0,)
else:
else: # slice object
datashapenew = datashapenew + (datashape[i],)
i+=1
datashape = datashapenew
Expand Down Expand Up @@ -407,10 +409,13 @@ def _StartCountStride(elem, shape, dimensions=None, grp=None, datashape=None,\
if unlim and e.stop is not None and e.stop > shape[i]:
length = e.stop
elif unlim and e.stop is None and datashape != ():
if e.start is None:
length = datashape[i]
else:
length = e.start+datashape[i]
try:
if e.start is None:
length = datashape[i]
else:
length = e.start+datashape[i]
except IndexError:
raise IndexError("shape of data does not conform to slice")
else:
if unlim and datashape == () and len(dim) == 0:
# writing scalar along unlimited dimension using slicing
Expand Down

0 comments on commit f7bd1d2

Please # to comment.