|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import logging |
4 | | -from typing import TYPE_CHECKING, cast |
| 4 | +from typing import TYPE_CHECKING, Literal, overload |
5 | 5 |
|
6 | 6 | from opentelemetry import trace |
7 | 7 |
|
8 | | -from qcodes import config |
9 | | -from qcodes.parameters import ParameterBase |
| 8 | +from .do_nd import DondKWargs, dond |
10 | 9 |
|
11 | | -from ..descriptions.detect_shapes import detect_shape_of_measurement |
12 | | -from ..measurements import Measurement |
13 | | -from ..threading import process_params_meas |
14 | | -from .do_nd_utils import _handle_plotting, _register_parameters, _set_write_period |
| 10 | +if TYPE_CHECKING: |
| 11 | + from typing_extensions import Unpack |
| 12 | + |
| 13 | + from .do_nd_utils import ( |
| 14 | + AxesTupleListWithDataSet, |
| 15 | + MultiAxesTupleListWithDataSet, |
| 16 | + ParamMeasT, |
| 17 | + ) |
15 | 18 |
|
16 | 19 | LOG = logging.getLogger(__name__) |
17 | 20 | TRACER = trace.get_tracer(__name__) |
18 | 21 |
|
19 | | -if TYPE_CHECKING: |
20 | | - from ..descriptions.versioning.rundescribertypes import Shapes |
21 | | - from ..experiment_container import Experiment |
22 | | - from .do_nd_utils import AxesTupleListWithDataSet, ParamMeasT |
| 22 | + |
| 23 | +@overload |
| 24 | +def do0d( |
| 25 | + *param_meas: ParamMeasT, squeeze: Literal[False], **kwargs: Unpack[DondKWargs] |
| 26 | +) -> MultiAxesTupleListWithDataSet: ... |
| 27 | + |
| 28 | + |
| 29 | +@overload |
| 30 | +def do0d( |
| 31 | + *param_meas: ParamMeasT, squeeze: Literal[True], **kwargs: Unpack[DondKWargs] |
| 32 | +) -> AxesTupleListWithDataSet | MultiAxesTupleListWithDataSet: ... |
| 33 | + |
| 34 | + |
| 35 | +@overload |
| 36 | +def do0d( |
| 37 | + *param_meas: ParamMeasT, squeeze: bool = True, **kwargs: Unpack[DondKWargs] |
| 38 | +) -> AxesTupleListWithDataSet | MultiAxesTupleListWithDataSet: ... |
23 | 39 |
|
24 | 40 |
|
25 | 41 | @TRACER.start_as_current_span("qcodes.dataset.do0d") |
26 | 42 | def do0d( |
27 | | - *param_meas: ParamMeasT, |
28 | | - write_period: float | None = None, |
29 | | - measurement_name: str = "", |
30 | | - exp: Experiment | None = None, |
31 | | - do_plot: bool | None = None, |
32 | | - use_threads: bool | None = None, |
33 | | - log_info: str | None = None, |
34 | | -) -> AxesTupleListWithDataSet: |
| 43 | + *param_meas: ParamMeasT, squeeze: bool = True, **kwargs: Unpack[DondKWargs] |
| 44 | +) -> AxesTupleListWithDataSet | MultiAxesTupleListWithDataSet: |
35 | 45 | """ |
36 | 46 | Perform a measurement of a single parameter. This is probably most |
37 | | - useful for an ArrayParameter that already returns an array of data points |
| 47 | + useful for a ParameterWithSetpoints that already returns an array of data points. |
38 | 48 |
|
39 | 49 | Args: |
40 | 50 | *param_meas: Parameter(s) to measure at each step or functions that |
41 | 51 | will be called at each step. The function should take no arguments. |
42 | 52 | The parameters and functions are called in the order they are |
43 | 53 | supplied. |
44 | | - write_period: The time after which the data is actually written to the |
45 | | - database. |
46 | | - measurement_name: Name of the measurement. This will be passed down to |
47 | | - the dataset produced by the measurement. If not given, a default |
48 | | - value of 'results' is used for the dataset. |
49 | | - exp: The experiment to use for this measurement. |
50 | | - do_plot: should png and pdf versions of the images be saved after the |
51 | | - run. If None the setting will be read from ``qcodesrc.json`` |
52 | | - use_threads: If True measurements from each instrument will be done on |
53 | | - separate threads. If you are measuring from several instruments |
54 | | - this may give a significant speedup. |
55 | | - log_info: Message that is logged during the measurement. If None a default |
56 | | - message is used. |
| 54 | + squeeze: If True, will return a tuple of QCoDeS DataSet, Matplotlib axis, |
| 55 | + Matplotlib colorbar if only one group of measurements was performed |
| 56 | + and a tuple of tuples of these if more than one group of measurements |
| 57 | + was performed. If False, will always return a tuple where the first |
| 58 | + member is a tuple of QCoDeS DataSet(s) and the second member is a tuple |
| 59 | + of Matplotlib axis(es) and the third member is a tuple of Matplotlib |
| 60 | + colorbar(s). |
| 61 | + **kwargs: kwargs are the same as for dond and forwarded directly to dond. |
57 | 62 |
|
58 | 63 | Returns: |
59 | 64 | The QCoDeS dataset. |
60 | 65 |
|
61 | 66 | """ |
62 | | - if do_plot is None: |
63 | | - do_plot = cast("bool", config.dataset.dond_plot) |
64 | | - meas = Measurement(name=measurement_name, exp=exp) |
65 | | - if log_info is not None: |
66 | | - meas._extra_log_info = log_info |
67 | | - else: |
68 | | - meas._extra_log_info = "Using 'qcodes.dataset.do0d'" |
69 | | - |
70 | | - measured_parameters = tuple( |
71 | | - param for param in param_meas if isinstance(param, ParameterBase) |
| 67 | + return dond( |
| 68 | + *param_meas, |
| 69 | + squeeze=squeeze, |
| 70 | + **kwargs, |
72 | 71 | ) |
73 | | - |
74 | | - try: |
75 | | - shapes: Shapes | None = detect_shape_of_measurement( |
76 | | - measured_parameters, |
77 | | - ) |
78 | | - except TypeError: |
79 | | - LOG.exception( |
80 | | - f"Could not detect shape of {measured_parameters} " |
81 | | - f"falling back to unknown shape." |
82 | | - ) |
83 | | - shapes = None |
84 | | - |
85 | | - _register_parameters(meas, param_meas, shapes=shapes) |
86 | | - _set_write_period(meas, write_period) |
87 | | - |
88 | | - with meas.run() as datasaver: |
89 | | - datasaver.add_result(*process_params_meas(param_meas, use_threads=use_threads)) |
90 | | - dataset = datasaver.dataset |
91 | | - |
92 | | - return _handle_plotting(dataset, do_plot) |
0 commit comments