ramonhagenaars / nptyping

💡 Type hints for Numpy and Pandas
MIT License
588 stars 29 forks source link

DeprecationWarning on use of np.unicode with numpy>=1.20 #47

Closed bskinn closed 3 years ago

bskinn commented 3 years ago

Per the "Deprecations" section here, certain type aliases like np.unicode are being deprecated; see the table at the link.

In a test module where I from nptyping import Float, NDArray (this is with nptyping 1.4.1, Python 3.9.4, Windows), I get the following warning traceback:

tests\test_fft.py:31: in <module>
    from ttrans_fft.fft import FFTOff, FFTOn
src\ttrans_fft\fft.py:34: in <module>
    from ttrans_fft.models import OffModelParams, OnModelParams
src\ttrans_fft\models.py:34: in <module>
    from ttrans_fft.types import FloatArray_1D
src\ttrans_fft\types.py:32: in <module>
    from nptyping import Float, NDArray
env\lib\site-packages\nptyping\__init__.py:2: in <module>
    from nptyping.functions._get_type import get_type
env\lib\site-packages\nptyping\functions\_get_type.py:29: in <module>
    from nptyping.types._unicode import Unicode
env\lib\site-packages\nptyping\types\_unicode.py:30: in <module>
    class Unicode(NPType, numpy.unicode, metaclass=_UnicodeMeta):     <=== `numpy.unicode`
env\lib\site-packages\numpy\__init__.py:287: in __getattr__
    warnings.warn(msg, DeprecationWarning, stacklevel=2)
E   DeprecationWarning: `np.unicode` is a deprecated alias for `np.compat.unicode`. To silence this warning, use `np.compat.unicode` 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.unicode` 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.
E   Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Sounds like it's as simple as searching for these deprecated aliases and replacing with the appropriate substitutions?