From 279a3ca7bce7be138f1aec6b041c8a8ade2f1b2f Mon Sep 17 00:00:00 2001 From: limin Date: Wed, 18 Dec 2019 19:50:25 +0800 Subject: [PATCH] =?UTF-8?q?api:=20=E4=BF=AE=E6=94=B9=E5=AF=B9=20numpy=20?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B=E7=9A=84=E5=88=A4=E6=96=AD?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E8=A6=86=E7=9B=96=E6=9B=B4=E5=A4=9A=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 如 numpy.int 是 numpy.integer 下的子类型, 不能覆盖到与它在同一个类型层次中的类型.因此若要判断是否是整型,应使用 integer close #180 --- tqsdk/api.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tqsdk/api.py b/tqsdk/api.py index b06029c9..0e678736 100644 --- a/tqsdk/api.py +++ b/tqsdk/api.py @@ -1230,13 +1230,13 @@ def _update_serial_single(self, serial): array[0:serial["width"] - shift] = array[shift:serial["width"]] for ext in serial["extra_array"].values(): ext[0:serial["width"] - shift] = ext[shift:serial["width"]] - if ext.dtype == np.float: + if np.issubdtype(ext.dtype, np.floating): ext[serial["width"] - shift:] = np.nan - elif ext.dtype == np.object: + elif np.issubdtype(ext.dtype, np.object_): ext[serial["width"] - shift:] = None - elif ext.dtype == np.int: + elif np.issubdtype(ext.dtype, np.integer): ext[serial["width"] - shift:] = 0 - elif ext.dtype == np.bool: + elif np.issubdtype(ext.dtype, np.bool_): ext[serial["width"] - shift:] = False else: ext[serial["width"] - shift:] = np.nan