How to get constant function to keep shape in NumPy
Use x.fill(1). Make sure to return it properly as fill doesn't return a new variable, it modifies x
I have a NumPy array A with shape (m,n) and want to run all the elements through some function f. For a non-constant function such as for example f(x) = x or f(x) = x**2 broadcasting works perfectly fine and returns the expected result. For f(x) = 1, applying the function to my array A however just returns the scalar 1. 
Is there a way to force broadcasting to keep the shape, i.e. in this case to return an array of 1s?