17 Feb 2024

Posted on:

26 Dec 2022

2

np.bool is not correct

np.bool won't work.

dtype = bool is the correct statement.

Posted on:

18 Feb 2023

2

https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations if you to go that like below the message error, it directs you to the solution that shoul be:

array_a = np.array([[1,2,3],[4,5,6]], dtype = np.bool_)
array_a

Just need to add the underscore after 'bool'.

The same goes for str (string).

Greetings

Posted on:

30 Mar 2023

0

Yes, underscore or just put it in quotation marks without the np. Theres a lot of ways to do this.

Posted on:

17 Feb 2024

0

Yes indeed, numpy.[type] is deprecated. You can add the underscore (ex: np.bool_), but you can just use the basic type bool

numpy.bool  bool  numpy.bool_
numpy.int int  numpy.int_ (default), numpy.int64, or numpy.int32
numpy.float float numpy.float64, numpy.float_, numpy.double (equivalent)
numpy.complex complex numpy.complex128, numpy.complex_, numpy.cdouble (equivalent)
numpy.object object numpy.object_
numpy.str str numpy.str_
numpy.long int numpy.int_ (C long), numpy.longlong (largest integer type)
numpy.unicode  str numpy.unicode_

AttributeError: module 'numpy' has no attribute 'bool'.
`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.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations