gui/tools: better detection of scalar types

This commit is contained in:
Sebastien Bourdeauducq 2015-08-17 23:14:18 +08:00
parent 21b170ed32
commit e7d495cf2c
1 changed files with 1 additions and 9 deletions

View File

@ -22,19 +22,11 @@ def elide(s, maxlen):
return s return s
_scalar_types = {
int, float,
np.int8, np.int16, np.int32, np.int64,
np.uint8, np.uint16, np.uint32, np.uint64,
np.float16, np.float32, np.float64
}
def short_format(v): def short_format(v):
if v is None: if v is None:
return "None" return "None"
t = type(v) t = type(v)
if t in _scalar_types: if np.issubdtype(t, int) or np.issubdtype(t, float):
return str(v) return str(v)
elif t is str: elif t is str:
return "\"" + elide(v, 15) + "\"" return "\"" + elide(v, 15) + "\""