I am reading source code of an open source project recently. When the programmer wanted to convert a row vector like array([0, 1, 2])
to a column vector like array([[0], [1], [2]])
, np.reshape(x, (-1,1))
was used.
In the comment, it says reshape is necessary to preserve the data contiguity against vs [:, np.newaxis]
that does not.
I tried the two ways, it seems like they will return the same results. Then what does the data contiguity preservation mean here?