diff --git a/Changelog b/Changelog index 55bc6b0db..a1de04ffa 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,7 @@ ================================= * Change default encoding for stringtochar/chartostring functions from 'utf-8' to 'utf-8'/'ascii' for dtype.kind='U'/'S' (issue #1464). + * Fix DeprecationWarning for assigning to numpy.ndarray.shape for numpy >= 2.5.0 (issue #1468). version 1.7.4 (tag v1.7.4rel) ================================ diff --git a/setup.py b/setup.py index c3b934606..8c10999ea 100644 --- a/setup.py +++ b/setup.py @@ -322,7 +322,7 @@ def _populate_hdf5_info(dirstosearch, inc_dirs, libs, lib_dirs): netCDF4_libdir = os.path.join(netCDF4_dir, 'lib') if sys.platform == 'win32': - libs.extend(['netcdf', 'zlib']) + libs.extend(['netcdf']) else: libs.extend(['netcdf', 'z']) diff --git a/src/netCDF4/_netCDF4.pyx b/src/netCDF4/_netCDF4.pyx index 2f5a133c9..3470d7a4c 100644 --- a/src/netCDF4/_netCDF4.pyx +++ b/src/netCDF4/_netCDF4.pyx @@ -5630,7 +5630,7 @@ cannot be safely cast to variable data type""" % attname # create a view so shape in caller is not modified (issue 90) try: # if extra singleton dims, just reshape data = data.view() - data.shape = tuple(datashape) + data = data.reshape(tuple(datashape)) except ValueError: # otherwise broadcast data = numpy.broadcast_to(data, datashape) @@ -6821,8 +6821,7 @@ and shape `a.shape + (N,)`, where N is the length of each string in a.""" if encoding in ['none','None','bytes']: b = numpy.array(tuple(a.tobytes()),'S1') elif encoding == 'ascii': - b = numpy.array(tuple(a.tobytes().decode(encoding)),dtype+'1') - b.shape = a.shape + (n_strlen,) + b = (numpy.array(tuple(a.tobytes().decode(encoding)),dtype+'1')).reshape(a.shape + (n_strlen,)) else: if not a.ndim: a = numpy.array([a]) @@ -6862,8 +6861,7 @@ returns a numpy string array with datatype `'UN'` (or `'SN'`) and shape a = numpy.array([bs[n1:n1+slen] for n1 in range(0,len(bs),slen)],'S'+repr(slen)) else: a = numpy.array([bs[n1:n1+slen].decode(encoding) for n1 in range(0,len(bs),slen)],'U'+repr(slen)) - a.shape = b.shape[:-1] - return a + return a.reshape(b.shape[:-1]) class MFDataset(Dataset): """