Skip to content

E712 : Wrong fix suggested in presence of numpy.bool_ #4356

Closed as not planned
@kesinger-idexx

Description

@kesinger-idexx

Using ruff 0.0.265.

In this code, the two if-blocks are NOT equivalent:

def f(x):
    # x is a np.ndarray with at least 2 dimensions
    return x[0, 0] > 0

x = np.eye(2)
a = f(x)
if a == True:
    print("a==True")
if a is True:
    print("a is True")
    assert(False)

What's going on is type(a)==numpy.bool_ which can be compared to True/False via == but it is not referentially the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions