'Assign integer value of choice to True / False values in a boolean other than 0 and 1
Is it possible to assign integer/ float values other than default 1 and 0 to the boolean True and False in array?
By default True converts to 1 and False to 0 from what I know. However when I try to assign '5.0' to True from a 2d array dtype=bool, the output still gives True and not the assigned integer value
#main_arr is a 3d array
main_arr = self.predictor(image)["instances"].pred_masks
#Taking the slice from 3d array based on 1st dimension
arr = np.asarray(main_arr[0,:,:])
#finding the non zero elements
row, col = np.nonzero(arr)
#assigning values to non zero elements
arr[row, col] = 5.0
print("The Non Zero value of element is :", arr[row[0]][col[0]])
The output is still True
The Non Zero value of element is : True
Whereas I would like to see something like
The Non Zero value of element is : 5.0
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
