I was reading the official NumPy Documentation for the array creation function np.empty(). The page states that empty() takes a shape parameter, allowing the user to specify the shape of the array to be created. The description of the parameter is:
shape: int or tuple of int.
Shape of the empty array, e.g., (2, 3) or 2.
shape is explicitly stated to be an int or a tuple of int(s). Yet, at the bottom of the page is this example, where shape seems to be a list of ints:
>>> np.empty([2, 2]) # [2, 2] uses square brackets, so this is a list!
array([[ -9.74499359e+001, 6.69583040e-309], # array shape matches the list
[ 2.13182611e-314, 3.06959433e-309]]) # values are uninitialized
Running the example on my machine gave the same results; NumPy seems to allow using a list to specify the shape of an array. So, my questions are
- Is this intended behavior (allowing a list to be used as the shape of a NumPy array)?
- Is something else going on? For instance, is the list just being converted to a tuple?