forked from M-Labs/artiq
dashboard/datasets: fix CreateEditDialog datatype cast (#2176)
This commit is contained in:
parent
9556ca53de
commit
01d777c977
|
@ -78,10 +78,11 @@ class CreateEditDialog(QtWidgets.QDialog):
|
||||||
|
|
||||||
if metadata is not None:
|
if metadata is not None:
|
||||||
scale = scale_from_metadata(metadata)
|
scale = scale_from_metadata(metadata)
|
||||||
value = pyon.decode(value)
|
decoded_value = pyon.decode(value)
|
||||||
t = type(value)
|
if scale == 1:
|
||||||
if np.issubdtype(t, np.number) or t is np.ndarray:
|
self.value_widget.setText(value)
|
||||||
self.value_widget.setText(pyon.encode(value / scale))
|
else:
|
||||||
|
self.value_widget.setText(pyon.encode(decoded_value / scale))
|
||||||
self.unit_widget.setText(metadata.get('unit', ''))
|
self.unit_widget.setText(metadata.get('unit', ''))
|
||||||
self.scale_widget.setText(str(metadata.get('scale', '')))
|
self.scale_widget.setText(str(metadata.get('scale', '')))
|
||||||
self.precision_widget.setText(str(metadata.get('precision', '')))
|
self.precision_widget.setText(str(metadata.get('precision', '')))
|
||||||
|
@ -104,8 +105,9 @@ class CreateEditDialog(QtWidgets.QDialog):
|
||||||
metadata['precision'] = int(precision)
|
metadata['precision'] = int(precision)
|
||||||
scale = scale_from_metadata(metadata)
|
scale = scale_from_metadata(metadata)
|
||||||
value = pyon.decode(value)
|
value = pyon.decode(value)
|
||||||
t = type(value)
|
t = value.dtype if value is np.ndarray else type(value)
|
||||||
if np.issubdtype(t, np.number) or t is np.ndarray:
|
is_floating = scale != 1 or np.issubdtype(t, np.floating)
|
||||||
|
if is_floating:
|
||||||
value = value * scale
|
value = value * scale
|
||||||
if self.key and self.key != key:
|
if self.key and self.key != key:
|
||||||
asyncio.ensure_future(exc_to_warning(rename(self.key, key, value, metadata, persist, self.dataset_ctl)))
|
asyncio.ensure_future(exc_to_warning(rename(self.key, key, value, metadata, persist, self.dataset_ctl)))
|
||||||
|
|
Loading…
Reference in New Issue