Skip to content

REGR: Comparing boolean array to True returns incorrect uint8 value with more than 32 values on 1.24.0 #22840

@phofl

Description

@phofl

Describe the issue:

When having an array with more than 31 boolean values and doing an equality comparison the underlying value seems off. Applying view("uint8") to the result returns 254 for every element instead of one. It works fine if n<= 31

Discovered in pandas-dev/pandas#50347

Reproduce the code example:

import numpy as np

n = 32
na = np.array([True] * n)
(na == True).view("uint8")

Error message:

[254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254
 254 254 254 254 254 254 254 254 254 254 254 254 254 254]

NumPy/Python version information:

1.24.0 3.8.15 | packaged by conda-forge | (default, Nov 22 2022, 08:49:06)
[Clang 14.0.6 ]

Context for the issue:

This seems off to me

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions