From 337273acb6a9a0c73b43d54e6c83aedf60341c7c Mon Sep 17 00:00:00 2001 From: Simon Renblad Date: Mon, 19 Jun 2023 12:40:45 +0800 Subject: [PATCH] environment: add get_dataset_metadata --- artiq/language/environment.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/artiq/language/environment.py b/artiq/language/environment.py index bc5761feb..bc0229998 100644 --- a/artiq/language/environment.py +++ b/artiq/language/environment.py @@ -420,6 +420,24 @@ class HasEnvironment: else: return default + def get_dataset_metadata(self, key, default=NoDefault): + """Returns the metadata of a dataset. + + Returns dictionary with items describing the dataset, including the units, + scale and precision. + + This function is used to get additional information for displaying the dataset. + + See ``set_dataset`` for documentation of metadata items. + """ + try: + return self.__dataset_mgr.get_metadata(key) + except KeyError: + if default is NoDefault: + raise + else: + return default + def setattr_dataset(self, key, default=NoDefault, archive=True): """Sets the contents of a dataset as attribute. The names of the dataset and of the attribute are the same."""