Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -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)
================================
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])

Expand Down
8 changes: 3 additions & 5 deletions src/netCDF4/_netCDF4.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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):
"""
Expand Down