I have a set of numbers arranged in a numpy array:
large_set = np.array([5, 6, 7, 8, 9])
I have three smaller sets:
small_set_1 = np.array([4.65, 4.66, 4.88])
small_set_2 = np.array([6.32, 6.77, 6.98, 7.46])
small_set_3 = np.array([9.75, 9.99, 10.34])
Is there any direct way to determine in python that small_set_x
falls within large_set
or not?
I did like this but its not very direct:
if (min(small_set_1) > min(large_set) or min(small_set_1) > max(large_set)):
pass
elif (min(small_set_1) < min(large_set) or min(small_set_1) < max(large_set)):
pass
elif (max(small_set_1) > min(large_set) or max(small_set_1) > max(large_set)):
pass
elif (max(small_set_1) < min(large_set) or max(small_set_1) < max(large_set)):
pass
In the end, I should simply print("The small set is within the large set")
. If possible, it can be nice to be able to print something like 'The small range doesn't lie in the large set, they are at the beginning of the large_set'
(matches small_set_1
in this case).