I have a numpy matrix in the middle of a running program (let's say it's name is rdy
). I found that reshape it into a one-dimensional matrix gives me a two-dimensional matrix. But if I try the same thing in the interactive shell, I get the expected results. Like the following ipython logs. I'm wondering which aspect of the matrix rdy cause it to behave differently when reshaping?
# This is expected:
In [191]: np.random.rand(512, 1).reshape(-1).shape
Out[191]: (512,)
# This is unexpected:
In [192]: rdy.reshape(-1).shape
Out[192]: (1, 512)
# The following are the different aspects of the rdy matrix:
In [193]: rdy.shape
Out[193]: (512, 1)
In [194]: rdy.flags
Out[194]:
C_CONTIGUOUS : True
F_CONTIGUOUS : False
OWNDATA : False
WRITEABLE : True
ALIGNED : True
UPDATEIFCOPY : False
In [195]: rdy.data
Out[195]: <read-write buffer for 0xeae6488, size 4096, offset 0 at 0x2ff95e70>