2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 19:28:26 +08:00

environment: add unit feature

This commit is contained in:
Simon Renblad 2023-06-13 11:46:49 +08:00 committed by Sébastien Bourdeauducq
parent 833fd8760e
commit 748707e157

View File

@ -337,13 +337,21 @@ class HasEnvironment:
self.kernel_invariants = kernel_invariants | {key}
@rpc(flags={"async"})
def set_dataset(self, key, value,
def set_dataset(self, key, value, *,
unit=None, scale=None, precision=None,
broadcast=False, persist=False, archive=True):
"""Sets the contents and handling modes of a dataset.
Datasets must be scalars (``bool``, ``int``, ``float`` or NumPy scalar)
or NumPy arrays.
:param unit: A string representing the unit of the value.
:param scale: A numerical factor that is used to adjust the value of
the dataset to match the scale or units of the experiment's
reference frame when the value is displayed.
:param precision: The maximum number of digits to print after the
decimal point. Set ``precision=None`` to print as many digits as
necessary to uniquely specify the value. Uses IEEE unbiased rounding.
:param broadcast: the data is sent in real-time to the master, which
dispatches it.
:param persist: the master should store the data on-disk. Implies
@ -351,7 +359,14 @@ class HasEnvironment:
:param archive: the data is saved into the local storage of the current
run (archived as a HDF5 file).
"""
self.__dataset_mgr.set(key, value, broadcast, persist, archive)
metadata = {}
if unit is not None:
metadata["unit"] = unit
if scale is not None:
metadata["scale"] = scale
if precision is not None:
metadata["precision"] = precision
self.__dataset_mgr.set(key, value, metadata, broadcast, persist, archive)
@rpc(flags={"async"})
def mutate_dataset(self, key, index, value):