Scale Numpy array to certain range
<p>Similar to <a href="https://stackoverflow.com/questions/1735025/how-to-normalize-a-numpy-array-to-within-a-certain-range/35993695#35993695">this question</a>, I want to fit a Numpy array into a certain range, however unlike the linked question I don't want to normalise it. How can I do this efficiently? Is there a built-in method in Numpy?</p>

<p>To clarify with an example, where <code>my_scale</code> is the function I'm looking for and <code>out_range</code> defines the output range:</p>

<pre><code>res = my_scale(np.array([-3, -2, -1], dtype=np.float), out_range)
assert res == [-1, 0, 1]
assert res != [-1, -2/3, -1/3]
</code></pre>