知识卡片

结构图卡 · 6353.a

类型类别不同于精确dtype

理解等级:中级

issubdtype可判断dtype是否属于整数或浮点等类别,而精确dtype比较区分位宽和其他细节。np.float64是标量类型类,其mro列出floating、inexact、number、generic等父类;dtype对象描述数组元素解释,不能把它与该标量类型类当同一对象。分类检查不代表不同位宽数值精度相同。下图只画原文float64.mro()中的NumPy父类链;mro是类型对象可调用的继承入口,并非声称由float64自行实现。

结构图:

classDiagram
 generic <|-- number
 number <|-- inexact
 inexact <|-- floating
 floating <|-- float64
 class float64 {
  +mro() list
 }
这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      np.issubdtype函数结合使用: In [10]: ints = np.ones(10, dtype=np.uint16) In [11]: floats = np.ones(10, dtype=np.float32) In [12]: np.issubdtype(ints.dtype, np.integer) Out[12]: True In [1

    参考来源

    - 位置:《利用Python进行数据分析》第12章《NumPy数据类型体系》(spine322;extracted/OReilly精品图书系列共21册(《Javascript权威指南》、《机器学习:实用案例解析》、《编写可读代码的艺术》、《算法精解》等)/_epub-src/text/part0308.html;u264-ch12-007)。 - 结论依据:原文在“np.issubdtype”附近的定义、例子或代码支撑本卡核心说明:issubdtype可判断dtype是否属于整数或浮点等类别,而精确dtype比较区分位宽和其他细节。边界按已读前提解释;示例未执行。 - 原始内容:np.issubdtype函数结合使用: In [10]: ints = np.ones(10, dtype=np.uint16) In [11]: floats = np.ones(10, dtype=np.float32) In [12]: np.issubdtype(ints.dtype, np.integer) Out[12]: True In [1