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

Stop using numpy type aliases that were deprecated in 1.20 and later removed #81

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

musicinmybrain
Copy link

@musicinmybrain musicinmybrain commented Dec 16, 2024

The types np.object and np.int were just aliases for the built-in object and int, respectively, so use those instead.

In older numpy releases, numpy.bool was the same as Python bool. This was deprecated in 1.20 and later removed for 1.x, then the name numpy.bool was reintroduced in numpy 2.x as an alias for numpy.bool_, a Boolean value stored as a byte. By using numpy.bool_ everywhere, we get the same data type on all Python versions.

Fixes:

E           AttributeError: module 'numpy' has no attribute 'object'.
E           `np.object` was a deprecated alias for the builtin `object`. To avoid this error in existing code, use `object` by itself. Doing this will not modify any behavior and is safe.
E           The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
E               https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
E           AttributeError: module 'numpy' has no attribute 'int'.
E           `np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, 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.
E           The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
E               https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

(Only on numpy 1.x; numpy.bool works on 2.x, but with a different meaning):

E           AttributeError: module 'numpy' has no attribute 'bool'.
E           `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, 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.
E           The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
E               https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?

It was just an alias for the built-in object, so use that instead.
@musicinmybrain musicinmybrain changed the title Stop using numpy.object, deprecated in 1.20 and later removed Stop using numpy.object/numpy.int, deprecated in 1.20 and later removed Dec 16, 2024
It was just an alias for the built-in int, so use that instead.
In older numpy releases, numpy.bool was the same as Python bool. This was deprecated in 1.20 and later removed for 1.x, then the name numpy.bool was reintroduced in numpy 2.x as an alias for numpy.bool_, a Boolean value stored as a byte. By using numpy.bool_, we get the same data type on all Python versions.
@musicinmybrain musicinmybrain changed the title Stop using numpy.object/numpy.int, deprecated in 1.20 and later removed Stop using numpy type aliases that were deprecated in 1.20 and later removed Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant