mirror of https://github.com/m-labs/artiq.git
gui: display numpy scalars in parameters
This commit is contained in:
parent
a64c6a321b
commit
2410ef79e5
|
@ -1,4 +1,5 @@
|
||||||
from quamash import QtCore
|
from quamash import QtCore
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
def elide(s, maxlen):
|
def elide(s, maxlen):
|
||||||
|
@ -21,11 +22,19 @@ 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 is int or t is float:
|
if t in _scalar_types:
|
||||||
return str(v)
|
return str(v)
|
||||||
elif t is str:
|
elif t is str:
|
||||||
return "\"" + elide(v, 15) + "\""
|
return "\"" + elide(v, 15) + "\""
|
||||||
|
|
Loading…
Reference in New Issue