Skip to content

DOC: Clarify the type alias deprecation message#18230

Merged
charris merged 5 commits intonumpy:masterfrom
seberg:issue-17977
Jan 26, 2021
Merged

DOC: Clarify the type alias deprecation message#18230
charris merged 5 commits intonumpy:masterfrom
seberg:issue-17977

Conversation

@seberg
Copy link
Copy Markdown
Member

@seberg seberg commented Jan 25, 2021

This tries to clarify the type alias deprecation message slightly
to give more guidance on how to review the replacement (if desired).


The new messages are as follows:
In [1]: np.bool                                                                                                                                             
<ipython-input-1-190120470286>:1: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  np.bool
Out[1]: bool

In [2]: np.object                                                                                                                                           
<ipython-input-2-4921af820668>:1: DeprecationWarning: `np.object` is a deprecated alias for the builtin `object`. To silence this warning, use `object` by itself. Doing this will not modify any behavior and is safe. 
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  np.object
Out[2]: object

In [3]: np.str                                                                                                                                              
<ipython-input-3-15a72efb409b>:1: DeprecationWarning: `np.str` is a deprecated alias for the builtin `str`. To silence this warning, 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.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  np.str
Out[3]: str

In [4]: np.float                                                                                                                                            
<ipython-input-4-b3b46df38e48>:1: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  np.float
Out[4]: float

In [5]: np.complex                                                                                                                                          
<ipython-input-5-087dad13a955>:1: DeprecationWarning: `np.complex` is a deprecated alias for the builtin `complex`. To silence this warning, use `complex` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.complex128` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  np.complex
Out[5]: complex

In [6]: np.int                                                                                                                                              
<ipython-input-6-5dcbb6b27796>:1: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  np.int
Out[6]: int

In [7]: np.long                                                                                                                                             
<ipython-input-7-2567cec2f44b>:1: DeprecationWarning: `np.long` is a deprecated alias for `np.compat.long`. To silence this warning, use `np.compat.long` by itself. In the likely event your code does not need to work on Python 2 you can use the builtin `int` for which `np.compat.long` is itself an alias. Doing this will not modify any behaviour and is safe. When replacing `np.long`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  np.long
Out[7]: int

In [8]: np.unicode                                                                                                                                          
<ipython-input-8-a16bff60575c>: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
  np.unicode

@seberg
Copy link
Copy Markdown
Member Author

seberg commented Jan 25, 2021

I tried to give some more details about integers in the release notes, and mention the precision version float64 rather than float_ in the message. So hopefully it is a bit more clear, it may be slightly opinionated.

@charris
Copy link
Copy Markdown
Member

charris commented Jan 26, 2021

What was the reason to change the 1.20.0 release note?

@seberg
Copy link
Copy Markdown
Member Author

seberg commented Jan 26, 2021

Thanks, have to try how to fix that reference. Will fix (maybe tomorrow morning). There was some discussion that this release note/deprecation is maybe a bit unclear. I hope this is a bit clearer (and "recipe style"), so the idea was to change it before the release.

This tries to clarify the type alias deprecation message slightly
to give more guidance on how to review the replacement (if desired).
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@eric-wieser
Copy link
Copy Markdown
Member

This looks great, thanks @seberg!

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
seberg and others added 2 commits January 26, 2021 13:07
@seberg
Copy link
Copy Markdown
Member Author

seberg commented Jan 26, 2021

Thanks Eric and Ross for figuring out how to correctly link the user guide... applied the changes, so should be good to go (assuming CI passes now).

@charris charris merged commit 6d47dd7 into numpy:master Jan 26, 2021
@charris
Copy link
Copy Markdown
Member

charris commented Jan 26, 2021

Thanks sebastian.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants