Generate a NumPy array with powers of 2
You seem to be using NumPy, so why not just do this -
>>> 2 ** np.arange(4)
array([1, 2, 4, 8])
This is broadcasted exponentiation.
Maybe just:
l = [2**i for i in range(n)]
You seem to be using NumPy, so why not just do this -
>>> 2 ** np.arange(4)
array([1, 2, 4, 8])
This is broadcasted exponentiation.
Maybe just:
l = [2**i for i in range(n)]