ภาพรวม
ใช้ numpy.issubdtype() ทดสอบว่า float type ขนาดต่างๆ (float16, float32, float64) เป็น subtype ของ class np.floating หรือไม่
ขั้นตอนการทำงาน
1. นำเข้า NumPy
import numpy as np
2. ทดสอบ issubdtype() กับ floating class
print("Result...", np.issubdtype(np.float16, np.floating))
print("Result...", np.issubdtype(np.float32, np.floating))
print("Result...", np.issubdtype(np.float64, np.floating))
ตัวอย่างโค้ดเต็ม
import numpy as np
print("Using the issubdtype() method in Numpy\n")
print("Result...", np.issubdtype(np.float16, np.floating))
print("Result...", np.issubdtype(np.float32, np.floating))
print("Result...", np.issubdtype(np.float64, np.floating))
ผลลัพธ์
Using the issubdtype() method in Numpy Result... True Result... True Result... True
สรุป: float16, float32, float64 ล้วนเป็น subtype ของ np.floating (abstract base class สำหรับ floating point ทุกขนาด)