Skip to content

BUG: redundant deprecation warning #23494

Description

@ghylander

Describe the issue:

Starting in v1.20, when calling a numpy built in type prints a warning:

FutureWarning: In the future 'np.bool' will be defined as the corresponding NumPy scalar. (This may have returned Python scalars in past versions.

It seems these types were dropped in v1.24, resulting in the exception:

AttributeError: module 'numpy' has no attribute 'bool'. Did you mean: 'bool_'?

However, the warning is still shown. It seems redundant or incorrect in its current form.
Only the exception should be shown, or the warning text should be changed.

Reproduce the code example:

import numpy as np

np.bool

Error message:

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 "C:\Users\user\miniconda3\envs\envName\Lib\site-packages\numpy\__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'bool'. Did you mean: 'bool_'?

Runtime information:

Not relevant

Context for the issue:

It's simply a confusing combination of contradicting warning and exception.
Judging by the warning type and text, it seems that the exception should not be raised (FutureWarning type and "in the future" text)

Activity

  1. rossbar commented on Apr 18, 2023

    @rossbar
    Contributor

    @seberg can correct me if I'm wrong, but I believe this is intentional. Some context is provided #22021 and the linked discussion on the mailing list. I agree it's a bit confusing without the additional context, but I'm not sure how best to improve the situation without getting too verbose.

  2. added
    57 - Close?Issues which may be closable unless discussion continued
    on Apr 18, 2023
  3. ghylander commented on Apr 18, 2023

    @ghylander
    Author

    @seberg can correct me if I'm wrong, but I believe this is intentional. Some context is provided #22021 and the linked discussion on the mailing list. I agree it's a bit confusing without the additional context, but I'm not sure how best to improve the situation without getting too verbose.

    Ah I see, thanks for the link

    I searched a bit for similar open issue before opening this one, but didnt go that far in time (that issue was opnened on July 21st 2022)
    I suppose it's perfectly OK to close this issue, as it's being already worked on from what I can see.
    Any discussion regarding this can be had there.

  4. seberg commented on Apr 18, 2023

    @seberg
    Member

    Yeah, I mind integrating the warning into the error message, but it was intentional to go via an error and not switch directly.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    00 - Bug57 - Close?Issues which may be closable unless discussion continued

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions