Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Change in bool type coersion? #16023

Closed
@LevN0

Description

@LevN0

In all past versions of NumPy dating back at least a decade, using astype(bool) on a str of '0' obtained False and on any other integer as True. Now the result is always True.

Reproducing code example:

import numpy as np

np.asarray(['0', '1']).astype('bool')

Before 1.18.3:
array([False, True], dtype=bool)

After 1.18.3:
array([True, True], dtype=bool)

Numpy/Python version information:

1.18.3 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)]

Other Thoughts

Seems to have been introduced by #15929. The prior behavior was logical, and saved execution time doing multiple type conversions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions