From 2410ef79e5e33ebe276531991d3b078a4399775a Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 17 Aug 2015 23:03:18 +0800 Subject: [PATCH] gui: display numpy scalars in parameters --- artiq/gui/tools.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/artiq/gui/tools.py b/artiq/gui/tools.py index 7d673cc55..da94ae7e7 100644 --- a/artiq/gui/tools.py +++ b/artiq/gui/tools.py @@ -1,4 +1,5 @@ from quamash import QtCore +import numpy as np def elide(s, maxlen): @@ -21,11 +22,19 @@ def elide(s, maxlen): 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): if v is None: return "None" t = type(v) - if t is int or t is float: + if t in _scalar_types: return str(v) elif t is str: return "\"" + elide(v, 15) + "\""