Skip to content

np.str deprecated in numpy 1.20 #20

@tremou

Description

@tremou

Hi,

I get the below error message while trying to read the SysPower table. It works if I use an old numpy version < 1.20 but it complains with newer numpy versions.

Thanks,
Lilia

>>> sdmpy.bintab.unpacker(mysdm['SysPower']).unpack()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/users/etremou/sdm/lib/python3.8/site-packages/sdmpy/bintab.py", line 169, in unpack
    self.row = numpy.recarray(1000, dtype=self.record_dtype)
  File "/users/etremou/sdm/lib/python3.8/site-packages/sdmpy/bintab.py", line 128, in record_dtype
    return [(str(col[0]), self._type_conv(col[2]), col[3]) for col in self.columns]
  File "/users/etremou/sdm/lib/python3.8/site-packages/sdmpy/bintab.py", line 128, in <listcomp>
    return [(str(col[0]), self._type_conv(col[2]), col[3]) for col in self.columns]
  File "/users/etremou/sdm/lib/python3.8/site-packages/sdmpy/bintab.py", line 122, in _type_conv
    return (numpy.str, int(dtype[1:]))
  File "/users/etremou/sdm/lib/python3.8/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'str'.
`np.str` was a deprecated alias for the builtin `str`. To avoid this error in existing code, use `str` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.str_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions