[Git][debian-gis-team/netcdf4-python][upstream] New upstream version 1.5.1.2

Bas Couwenberg gitlab at salsa.debian.org
Tue May 7 05:42:34 BST 2019



Bas Couwenberg pushed to branch upstream at Debian GIS Project / netcdf4-python


Commits:
bacca403 by Bas Couwenberg at 2019-05-07T04:24:00Z
New upstream version 1.5.1.2
- - - - -


7 changed files:

- Changelog
- README.md
- docs/netCDF4/index.html
- netCDF4/_netCDF4.pyx
- netCDF4/utils.py
- setup.py
- test/tst_slicing.py


Changes:

=====================================
Changelog
=====================================
@@ -1,3 +1,7 @@
+ 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).


=====================================
README.md
=====================================
@@ -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.


=====================================
docs/netCDF4/index.html
=====================================
@@ -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>


=====================================
netCDF4/_netCDF4.pyx
=====================================
@@ -1,5 +1,5 @@
 """
-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


=====================================
netCDF4/utils.py
=====================================
@@ -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


=====================================
setup.py
=====================================
@@ -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 at noaa.gov",


=====================================
test/tst_slicing.py
=====================================
@@ -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()



View it on GitLab: https://salsa.debian.org/debian-gis-team/netcdf4-python/commit/bacca4038582d2befdc3f379520842ef76ee685d

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/netcdf4-python/commit/bacca4038582d2befdc3f379520842ef76ee685d
You're receiving this email because of your account on salsa.debian.org.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20190507/35bbc996/attachment-0001.html>


More information about the Pkg-grass-devel mailing list