Write a NumPy program to check element-wise True/False of a given array where signbit is set.
Sample array: [-4, -3, -2, -1, 0, 1, 2, 3, 4]
import numpy as np x = np.array([-4, -3, -2, -1, 0, 1, 2, 3, 4]) print("Original array: ") print(x) r1 = np.signbit(x) r2 = x < 0 assert np.array_equiv(r1, r2) print(r1)
Sample Output:
Original array: [-4 -3 -2 -1 0 1 2 3 4] [ True True True True False False False False False]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer