python - 使用 2 位 Dtype 指定 NumPy 数组

标签 python numpy numpy-dtype

根据文档,可以指定不同的数组数据类型:

dt = np.dtype('u1')   # 8-bit unsigned integer
dt = np.dtype('i4')   # 32-bit signed integer
dt = np.dtype('f8')   # 64-bit floating-point number
dt = np.dtype('c16')  # 128-bit complex floating-point number
dt = np.dtype('a25')  # 25-length zero-terminated bytes
dt = np.dtype('U25')  # 25-character string

但是,最小的无符号整数 dtype 是 8 位。有没有办法创建 2 位无符号整数数据类型?

最佳答案

根据NumPy mailing list from November 2009 ,NumPy 具有 1 字节原子性,因此 8 位是最小单位。甚至 bool dtype 也使用单个字节。

关于python - 使用 2 位 Dtype 指定 NumPy 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53999299/

相关文章:

python - QGraphicsItem 在悬停输入事件时发出信号

python - 使用pcolormesh时如何设置网格

python - numpy svd : is there a way to find only the first singular vectors instead of doing full svd?

python - pickle scipy 的 SuperLU 类用于不完全 LU 分解

python - numpy 包含多个 dtype 时如何确定数组数据类型?

python - numpy 中 str 类输入的默认 dtype 是什么?

python - string.format 与 css 标签冲突 : { } 's

python - 使用 windows python 2.3 传入 poplib 重构

python - 如何在 Python 的另一个函数中找出特定函数参数的默认值?