np.bool code example
Example 1: 16 bit floating point numpy
# to create an x-bit point with numpy, use np.intx
# to create an unsigned x-bit point with numpy, use np.uintx
# examples:
import numpy as np
a = np.int16(10000) # 10000 stored as a 16-bit number (can store numbers from -32768 to 32767)
b = np.uint(10000) # 10000 stored as an unsigned 16-bit number (can store numbers from 0 to 65535)
Example 2: numpy boolean array
arr_1 = np.random.randn(3, 3)
arr_2 = np.random.randn(3, 3)
bool_arr = arr_1 < 0.5
print(bool_arr.dtype)
# output: bool
bool_arr = arr_1 < arr_2
print(bool_arr.dtype)
# output: bool