Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the use of removed numpy types #6495

Merged
merged 1 commit into from
Jan 23, 2023

Conversation

bwroblew
Copy link
Contributor

@bwroblew bwroblew commented Jan 23, 2023

Both np.bool and np.unicode were deprecated in numpy 1.20.0 and removed in numpy 1.24.0.
Since release notes of 1.20.0 say that np.bool is identical to bool and np.unicode is identical to str, I changed them that way.

Confirmed using numpy 1.23.5:

>>> np.__version__
'1.23.5'
>>> np.unicode is str
<stdin>:1: 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.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
True
>>> np.bool is bool
<stdin>: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
True

In numpy 1.24.0 both types don't exist anymore:

>>> np.__version__
'1.24.0'
>>> np.unicode       
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "[...]/python3.8/site-packages/numpy/__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'unicode'
>>> np.bool
<stdin>:1: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.  (This may have returned Python scalars in past versions.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "[...]/python3.8/site-packages/numpy/__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'bool'

@bwroblew bwroblew force-pushed the fix_deprecated_np_types branch from 8a2cd4f to 15d4c2f Compare January 23, 2023 14:26
@bwroblew bwroblew changed the title Fix removed numpy types Fix the use of removed numpy types Jan 23, 2023
@codecov
Copy link

codecov bot commented Jan 23, 2023

Codecov Report

Merging #6495 (15d4c2f) into master (cc596b8) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #6495   +/-   ##
=======================================
  Coverage   85.64%   85.64%           
=======================================
  Files         405      405           
  Lines       22450    22450           
=======================================
  Hits        19227    19227           
  Misses       3223     3223           
Impacted Files Coverage Δ
torch_geometric/data/dataset.py 91.77% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@rusty1s rusty1s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, thank you!

@rusty1s rusty1s merged commit e2f6d46 into pyg-team:master Jan 23, 2023
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.

2 participants