Skip to content

netCDF4.stringtochar broken in 1.7.4 #1464

@valeriupredoi

Description

@valeriupredoi

Hi folks, please see the MRE below:

import netCDF4 as nc
import numpy as np

# should work as per https://unidata.github.io/netcdf4-python/#netCDF4.stringtochar
months = np.array(["January", "February", "March", "April"], dtype="S8")
print(nc.stringtochar(months))
# but I get:
# Traceback (most recent call last):
#   File "/home/valeriu/netcdf4_MRE.py", line 5, in <module>
#     print(nc.stringtochar(months))
#           ~~~~~~~~~~~~~~~^^^^^^^^
#   File "src/netCDF4/_netCDF4.pyx", line 6824, in netCDF4._netCDF4.stringtochar
# AttributeError: 'numpy.bytes_' object has no attribute 'encode'. Did you mean: 'decode'?
# with
# Name                     Version          Build                    Channel
# netcdf4                    1.7.4            nompi_py314h4ae7121_101  conda-forge
# everything OK with netCDF4==1.7.3
# on a generic Ubuntu machine

stringtochar is not working anymore in 1.7.4. Apologies for bugging you here, but am not sure how to let the netCDF4-C folks know about it, it's clearly an issue in the C layer, perhaps you can ping them about it? Very many thanks in advance! Cheers 🍻

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions