I am creating a numpy array using the following:
X = np.linspace(-5, 5, num=500)
This generates points evenly sampled 500 points between -5 and 5. The shape of the resulting array is: (500,). Now, I need to pass it to a function that expects a 2-D array. So, I can reshape it as:
X = X.reshape((500, 1))
However, I noticed that X = X[:, None] has the same effect. For the life of me though, I cannot understand what this syntax is doing. Hoping someone can shed some light on this.
Noneisnp.newaxis- this page on advanced indexing explains its use in a bit of detail and might be a useful reference.