Codebase list netcdf4-python / dcc12f4
Update upstream source from tag 'upstream/1.5.8' Update to upstream version '1.5.8' with Debian dir 79a19b5b2ab1c3112ed87030aadf9f651c249dfa Bas Couwenberg 2 years ago
15 changed file(s) with 56 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
99 NETCDF_DIR: ${{ github.workspace }}/..
1010 NETCDF_EXTRA_CONFIG: --enable-pnetcdf
1111 CC: mpicc.mpich
12 # NO_NET: 1
12 #NO_NET: 1
1313 strategy:
1414 matrix:
1515 python-version: ["3.9"]
77 jobs:
88 run-serial:
99 runs-on: ${{ matrix.os }}
10 #env:
11 # NO_NET: 1
1012 strategy:
1113 matrix:
12 python-version: ["3.6", "3.7", "3.8", "3.9"]
14 python-version: ["3.6", "3.7", "3.8", "3.9", "3.10" ]
1315 os: [windows-latest, ubuntu-latest, macos-latest]
1416 platform: [x64, x32]
1517 exclude:
7577 export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH"
7678 which mpirun
7779 mpirun --version
78 mpirun --oversubscribe -np 4 python mpi_example.py
80 mpirun -np 4 python mpi_example.py
7981 if [ $? -ne 0 ] ; then
8082 echo "hdf5 mpi test failed!"
8183 exit 1
0 version 1.5.8 (tag v1.5.8rel)
1 ==============================
2 * Fix Enum bug (issue #1128): the enum_dict member of an EnumType read from a file
3 contains invalid values when the enum is large enough (more than 127 or 255
4 members).
5 * Binary wheels for aarch64 and python 3.10.
6
07 version 1.5.7 (tag v1.5.7rel)
18 ==============================
29 * don't try to mask vlens with default _FillValue, since vlens don't have a default _FillValue.
88
99 ## News
1010 For details on the latest updates, see the [Changelog](https://github.com/Unidata/netcdf4-python/blob/master/Changelog).
11
12 10/31/2021: Version [1.5.8](https://pypi.python.org/pypi/netCDF4/1.5.8) released. Fix Enum bug, add binary wheels for aarch64 and python 3.10.
1113
1214 6/22/2021: Version [1.5.7](https://pypi.python.org/pypi/netCDF4/1.5.7) released.
1315 Fixed OverflowError on Windows when reading data with dimension sizes greater than 2**32-1.
5759 10/26/2018: Version [1.4.2](https://pypi.python.org/pypi/netCDF4/1.4.2) released. Minor bugfixes, added `Variable.get_dims()` method and `master_file` kwarg for `MFDataset.__init__`.
5860
5961 08/10/2018: Version [1.4.1](https://pypi.python.org/pypi/netCDF4/1.4.1) released. The old slicing behavior
60 (numpy array returned unless missing values are present, otherwise masked array returned) is renabled
62 (numpy array returned unless missing values are present, otherwise masked array returned) is re-enabled
6163 via `set_always_mask(False)`.
6264
6365 05/11/2018: Version [1.4.0](https://pypi.python.org/pypi/netCDF4/1.4.0) released. The netcdftime package is no longer
2727
2828 ### Triggering a build
2929
30 You will need write permision to the github repository to trigger new builds
30 You will need write permission to the github repository to trigger new builds
3131 on the travis-ci interface. Contact us on the mailing list if you need this.
3232
3333 You can trigger a build by:
22 import numpy as np
33 import matplotlib.pyplot as plt
44
5 # use real data from CFS reanlysis.
5 # use real data from CFS reanalysis.
66 # note: we're reading GRIB2 data!
77 URL="http://nomads.ncdc.noaa.gov/thredds/dodsC/modeldata/cmd_flxf/2010/201007/20100701/flxf00.gdas.2010070100.grb2"
88 nc = netCDF4.Dataset(URL)
00 """
1 Version 1.5.7
1 Version 1.5.8
22 -------------
33
44 # Introduction
12031203 # Python 3.7+ guarantees order; older versions need OrderedDict
12041204 from collections import OrderedDict
12051205
1206 __version__ = "1.5.7"
1206 __version__ = "1.5.8"
12071207
12081208 # Initialize numpy
12091209 import posixpath
24672467
24682468 def isopen(self):
24692469 """
2470 **`close(self)`**
2471
2472 is the Dataset open or closed?
2470 **`isopen(self)`**
2471
2472 Is the Dataset open or closed?
24732473 """
24742474 return bool(self._isopen)
24752475
59785978 # then use that to create a EnumType instance.
59795979 # called by _get_types, _get_vars.
59805980 cdef int ierr, _grpid, nmem
5981 cdef char enum_val
5981 cdef ndarray enum_val
59825982 cdef nc_type base_xtype
59835983 cdef char enum_namstring[NC_MAX_NAME+1]
59845984 cdef size_t nmembers
59975997 raise KeyError("unsupported component type for ENUM")
59985998 # loop over members, build dict.
59995999 enum_dict = {}
6000 enum_val = numpy.empty(1,dt)
60006001 for nmem from 0 <= nmem < nmembers:
60016002 with nogil:
60026003 ierr = nc_inq_enum_member(_grpid, xtype, nmem, \
6003 enum_namstring, &enum_val)
6004 enum_namstring,PyArray_DATA(enum_val))
60046005 _ensure_nc_success(ierr)
60056006 name = enum_namstring.decode('utf-8')
6006 enum_dict[name] = int(enum_val)
6007 enum_dict[name] = enum_val.item()
60076008 return EnumType(group, dt, enum_name, enum_dict, typeid=xtype)
60086009
60096010 cdef _strencode(pystr,encoding=None):
234234 unlim = False
235235 # convert boolean index to integer array.
236236 if np.iterable(ea) and ea.dtype.kind =='b':
237 # check that boolen array not too long
237 # check that boolean array not too long
238238 if not unlim and shape[i] != len(ea):
239239 msg="""
240240 Boolean array must have the same shape as the data along this dimension."""
538538 sys.stderr.write(usage)
539539 sys.exit(0)
540540
541 # filename passed as last argumenbt
541 # filename passed as last argument
542542 try:
543543 filename = pargs[-1]
544544 except IndexError:
99 integer data stored with a signed integer type in netcdf-3.
1010 If _Unsigned=True, a view to the data as unsigned integers is returned.
1111 set_autoscale can be used to turn this off (default is on)
12 See issue #656 (pull reqeust #658).
12 See issue #656 (pull request #658).
1313 """
1414 def test_unsigned(self):
1515 f = netCDF4.Dataset("ubyte.nc")
4242 f = netCDF4.Dataset(self.file,'w')
4343 # try to set a dataset attribute with one of the reserved names.
4444 f.setncattr('file_format','netcdf4_format')
45 # test attribute renameing
45 # test attribute renaming
4646 f.stratt_tmp = STRATT
4747 f.renameAttribute('stratt_tmp','stratt')
4848 f.emptystratt = EMPTYSTRATT
6262 assert_array_equal(data.mask, datain_masked.mask)
6363 f.close()
6464
65 class EnumDictTestCase(unittest.TestCase):
66 # issue 1128
67 def setUp(self):
68 DT = np.int16; BITS = 8
69 self.STORED_VAL = DT(2**BITS)
70 self.VAL_MAP = {f'bits_{n}': DT(2**n) for n in range(1,BITS+1)}
71 self.VAL_MAP['invalid'] = 0
72 self.file = tempfile.NamedTemporaryFile(suffix='.nc', delete=False).name
73 with netCDF4.Dataset(file, 'w') as nc:
74 # The enum is created with dtype=int16, so it will allow BITS values up to 15
75 et = nc.createEnumType(DT, 'etype', self.VAL_MAP)
76 ev = nc.createVariable('evar', et)
77 # Succeeds because the created EnumType does keep the correct dict
78 ev[...] = self.STORED_VAL
79 def tearDown(self):
80 os.remove(self.file)
81 def runTest(self):
82 with netCDF4.Dataset(file, 'r') as nc:
83 read_var = nc['evar']
84 assert(read_var[...] == self.STORED_VAL)
85 assert(read_et.enum_dict == self.VAL_MAP)
86
6587 if __name__ == '__main__':
6688 unittest.main()
5555 # integer array slice.
5656 v[:,i,:] = -100
5757 self.data[:,i,:] = -100
58 # boolen array slice.
58 # boolean array slice.
5959 v[ib2] = -200
6060 self.data[ib2] = -200
6161 v[ib3,:,:] = -300
2525
2626 def test_no_such_file_raises(self):
2727 fname = 'not_a_nc_file.nc'
28 with self.assertRaisesRegexp(IOError, fname):
28 with self.assertRaisesRegex(IOError, fname):
2929 netCDF4.Dataset(fname, 'r')
3030
3131
9595 self.assertTrue(np.all(self.v_ma.mask == v.mask))
9696 self.assertTrue(np.all(self.v_ma.mask == v2.mask))
9797 # treating _FillValue as valid_min/valid_max was
98 # too suprising, revert to old behaviour (issue #761)
98 # too surprising, revert to old behaviour (issue #761)
9999 #self.assertTrue(np.all(self.v_ma.mask == v3.mask))
100100 # check that underlying data is same as in netcdf file
101101 v = f.variables['v']
2323
2424 def runTest(self):
2525 """test for issue 90 (array shape should not be modified by
26 assigment to netCDF variable)"""
26 assignment to netCDF variable)"""
2727 f = Dataset(self.file, 'a')
2828 v = f.variables['data']
2929 v[0] = data