Skip to content

Commit

Permalink
api: 修改对 numpy 数据类型的判断,以覆盖更多类型
Browse files Browse the repository at this point in the history
如 numpy.int 是 numpy.integer 下的子类型, 不能覆盖到与它在同一个类型层次中的类型.因此若要判断是否是整型,应使用 integer

close #180
  • Loading branch information
shinny-limin committed Dec 19, 2019
1 parent 1f4ab5a commit 279a3ca
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tqsdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 279a3ca

Please sign in to comment.