Commit e0d62f1f authored by Bas Couwenberg's avatar Bas Couwenberg

Merge tag 'upstream/1.5.1.2'

Upstream version 1.5.1.2
parents 6248662d bacca403
version 1.5.1.2 (tag v1.5.1.2rel)
==================================
* 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).
......
......@@ -10,7 +10,10 @@
## News
For details on the latest updates, see the [Changelog](https://github.com/Unidata/netcdf4-python/blob/master/Changelog).
05/02/2019: Version [1.5.1.1](https://pypi.python.org/pypi/netCDF4/1.5.1.1) released. Fixes incorrect __version__
05/06/2019: Version [1.5.1.2](https://pypi.python.org/pypi/netCDF4/1.5.1.2) released. Fixes another slicing
slicing regression ([issue #922)](https://github.com/Unidata/netcdf4-python/issues/922)) introduced in the 1.5.1 release.
05/02/2019: Version [1.5.1.1](https://pypi.python.org/pypi/netCDF4/1.5.1.1) released. Fixes incorrect `__version__`
module variable in 1.5.1 release, plus a slicing bug ([issue #919)](https://github.com/Unidata/netcdf4-python/issues/919)).
04/30/2019: Version [1.5.1](https://pypi.python.org/pypi/netCDF4/1.5.1) released. Bugfixes, no new features.
......
......@@ -4,7 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<title>netCDF4 API documentation</title>
<meta name="description" content="Version 1.5.1.1
<meta name="description" content="Version 1.5.1.2
---------------
- - -
......@@ -1280,7 +1280,7 @@ table {
<header id="section-intro">
<h1 class="title"><span class="name">netCDF4</span> module</h1>
<h2>Version 1.5.1.1</h2>
<h2>Version 1.5.1.2</h2>
<hr />
<h1>Introduction</h1>
<p>netcdf4-python is a Python interface to the netCDF C library.</p>
......
"""
Version 1.5.1.1
Version 1.5.1.2
---------------
- - -
......@@ -1190,7 +1190,7 @@ except ImportError:
# python3: zip is already python2's itertools.izip
pass
__version__ = "1.5.1.1"
__version__ = "1.5.1.2"
# Initialize numpy
import posixpath
......
......@@ -365,12 +365,14 @@ Boolean array must have the same shape as the data along this dimension."""
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
......@@ -407,10 +409,13 @@ Boolean array must have the same shape as the data along this dimension."""
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
......
......@@ -584,7 +584,7 @@ else:
setup(name="netCDF4",
cmdclass=cmdclass,
version="1.5.1.1",
version="1.5.1.2",
long_description="netCDF version 4 has many features not found in earlier versions of the library, such as hierarchical groups, zlib compression, multiple unlimited dimensions, and new data types. It is implemented on top of HDF5. This module implements most of the new features, and can read and write netCDF files compatible with older versions of the library. The API is modelled after Scientific.IO.NetCDF, and should be familiar to users of that module.\n\nThis project is hosted on a `GitHub repository <https://github.com/Unidata/netcdf4-python>`_ where you may access the most up-to-date source.",
author="Jeff Whitaker",
author_email="jeffrey.s.whitaker@noaa.gov",
......
......@@ -235,5 +235,19 @@ class VariablesTestCase(unittest.TestCase):
f['v1'][:] = arr
assert_array_equal(f['v1'][:],np.broadcast_to(arr,f['v1'].shape))
def test_issue922(self):
with Dataset(self.file,'w') as f:
f.createDimension('d1',3)
f.createDimension('d2',None)
f.createVariable('v1',np.int,('d2','d1',))
f['v1'][0] = np.arange(3,dtype=np.int)
f['v1'][1:3] = np.arange(3,dtype=np.int)
assert_array_equal(f['v1'][:], np.broadcast_to(np.arange(3),(3,3)))
f.createVariable('v2',np.int,('d1','d2',))
f['v2'][:,0] = np.arange(3,dtype=np.int)
f['v2'][:,1:3] = np.arange(6,dtype=np.int).reshape(3,2)
assert_array_equal(f['v2'][:,1:3],np.arange(6,dtype=np.int).reshape(3,2))
assert_array_equal(f['v2'][:,0],np.arange(3,dtype=np.int))
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment