In my PyCharm IDE if I open up a Python Console (Interpreter) and attempt to instantiate a numpy.ndarray with initial shape [1] I get the following result:
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.
PyDev console: using IPython 8.4.0
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
import numpy as np
np.ndarray([1])
Out[3]: array([0.0078125])
This default value seems relatively (>>) larger than I expected. I would expect something close to 0.0 or essentially 0.0 (i.e. 1.234e+178). Given it's the size of the value it does not seem to be some sort of rounding error.
Checking the documentation it looks like users are not really intended to make an instance of ndarray directly, but rather rely on array. Though, the documentation even provides an example of instantiating a (2, 2) shaped array.
Relatedly interesting, it seems that the default value seems to change "suddenly" after instantiating different sized ndarray. If I keep playing around in the same terminal from above I get the following behavior
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.
PyDev console: using IPython 8.4.0
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
import numpy as np
np.ndarray([1])
Out[3]: array([0.0078125])
np.ndarray([1, 2])
Out[4]: array([[1.02724393e-188, 6.85721358e+215]])
np.ndarray(1)
Out[5]: array([6.85721358e+215])
np.ndarray([1])
Out[6]: array([6.85721358e+215])
Various online Python interactive terminals produce the same behavior.
Why is the default value for numpy.ndarray([1]) equal to such a large value?
Is it that the default value of the buffer is somehow equal to this value "by default" for a size (1) array?..
Note: 1/128 = 0.0078125