Problem: I want to compare each element of a Numpy array with a float, returning an array with the smaller value. For example, using the inputs:
import numpy as np
input_a = 3
input_b = np.array([1,2,3,4,5])
the output should be
output = np.array([1,2,3,3,3])
My current solution is working by making a new np.array with only the constant, then using np.minimum().
c = np.copy(input_b)
c.fill(input_a)
output = np.minimum(input_b, c)
However, I am afraid that this is not the most efficient solution. Is there a more elegant / efficient way to achieve this?