Skip to content

np.unicode aliased to np.compat.long #18287

@invisiblefunnel

Description

@invisiblefunnel

It appears a bug was introduced in numpy when deprecating type aliases in #18230. The bug caused np.unicode to be aliased to np.compat.long which is an alias for int. This was quick to track down because of a typo in the deprecation message (unciode).

https://github.com/numpy/numpy/blob/v1.20.0/numpy/__init__.py#L209-L212

Reproducing code example:

import numpy as np
np.unicode("hello")

Error message:

<stdin>:1: DeprecationWarning: `np.unciode` is a deprecated alias for `np.compat.unciode`. To silence this warning, use `np.compat.unciode` by itself. In the likely event your code does not need to work on Python 2 you can use the builtin `str` for which `np.compat.unciode` is itself an alias. Doing this will not modify any behaviour and is safe. If you specifically wanted the numpy scalar type, use `np.str_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: 'hello'

NumPy/Python version information:

>>> import sys, numpy; print(numpy.__version__, sys.version)
1.20.0 3.8.2 (default, Nov  4 2020, 21:23:28) 
[Clang 12.0.0 (clang-1200.0.32.28)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions