import numpy as np
np.array([], ndmin=2)
The resulting array has shape (1, 0). But why not (0, 0), if the input array has length 0? Is there a better way to create an array of shape (0, 0) than explicitely call np.zeros((0, 0))?
From the documentation for numpy.array:
ndmin : int, optional -- Specifies the minimum number of dimensions that the resulting array should have. Ones will be pre-pended to the shape as needed to meet this requirement
You're giving it a shape (0,) array-like, so it prepends a 1 to make the shape size 2.
np.zeros((0, 0)) is fine.
[] case special. np.array( np.ones(n), ndmin=2) becomes (1,n) shape regardless whether n is 0 or 10. Consistency like that is nice.[] is a shape (0,) array-like, and you tell it that your requirement is a shape (x,y) array-like, so it appends a 1 before the 0 to give you an array with shape (1,0).
(0, 0), verify for yourself by assigning that shape to it, or usingreshape. The behavior of the constructor is to append1suntil the number of dimensions has been satisfied.