默认情况下,哪个浮点精度是 numpy 数组?

which float precision are numpy arrays by default?

我想知道默认情况下 numpy 数组中的浮点数是哪种格式。 (或者它们在声明 np.array 时甚至会转换吗?如果是这样,python 列表怎么样?) 例如float16、float32 还是 float64?

float64。你可以这样查看

>>> np.array([1, 2]).dtype
dtype('int64')
>>> np.array([1., 2]).dtype
dtype('float64')

如果您在创建数组时未指定数据类型,则 numpy 将根据 docs

推断类型

dtypedata-type, optional - The desired data-type for the array. If not given, then the type will be determined as the minimum type required to hold the objects in the sequence