From 09a2bfc7fb9d4530d1f2fb00eafca3f59f018aa8 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Thu, 6 Jan 2022 10:53:36 +0100 Subject: [PATCH 01/31] add plotting to dataset public api --- qcodes/dataset/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qcodes/dataset/__init__.py b/qcodes/dataset/__init__.py index 81978223550..c06ff9711d8 100644 --- a/qcodes/dataset/__init__.py +++ b/qcodes/dataset/__init__.py @@ -21,6 +21,7 @@ new_experiment, ) from .measurements import Measurement +from .plotting import plot_by_id, plot_dataset from .sqlite.database import ( initialise_database, initialise_or_create_database_at, From 79972e2fca1884396f51605c8c87707fcc822d15 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Thu, 6 Jan 2022 11:09:10 +0100 Subject: [PATCH 02/31] define a public api for the dataset --- qcodes/dataset/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qcodes/dataset/__init__.py b/qcodes/dataset/__init__.py index c06ff9711d8..58965982c81 100644 --- a/qcodes/dataset/__init__.py +++ b/qcodes/dataset/__init__.py @@ -46,6 +46,8 @@ "load_or_create_experiment", "new_experiment", "Measurement", + "plot_by_id", + "plot_dataset", "initialise_database", "initialise_or_create_database_at", "initialised_database_at", From cb88a89080ca9ba99982f1617265bee79474572e Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Mon, 28 Feb 2022 16:28:40 +0100 Subject: [PATCH 03/31] try to break circular import by lazily importing plotting into dond --- qcodes/utils/dataset/doNd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/utils/dataset/doNd.py b/qcodes/utils/dataset/doNd.py index 8b812a1680c..bf3a4d1da2b 100644 --- a/qcodes/utils/dataset/doNd.py +++ b/qcodes/utils/dataset/doNd.py @@ -17,7 +17,6 @@ from qcodes.dataset.descriptions.versioning.rundescribertypes import Shapes from qcodes.dataset.experiment_container import Experiment from qcodes.dataset.measurements import Measurement -from qcodes.dataset.plotting import plot_dataset from qcodes.instrument.parameter import _BaseParameter from qcodes.utils.threading import ( SequentialParamsCaller, @@ -1032,6 +1031,7 @@ def plot( save_pdf: Save figure in pdf format. save_png: Save figure in png format. """ + from qcodes.dataset.plotting import plot_dataset dataid = data.captured_run_id axes, cbs = plot_dataset(data) mainfolder = config.user.mainfolder From d7489c9e6f7129ca0f0031b6e2975981d9261ef5 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Fri, 4 Mar 2022 15:09:01 +0100 Subject: [PATCH 04/31] move dond to dataset module --- qcodes/{utils => }/dataset/doNd.py | 54 ++++++++++++++++-------------- 1 file changed, 29 insertions(+), 25 deletions(-) rename qcodes/{utils => }/dataset/doNd.py (96%) diff --git a/qcodes/utils/dataset/doNd.py b/qcodes/dataset/doNd.py similarity index 96% rename from qcodes/utils/dataset/doNd.py rename to qcodes/dataset/doNd.py index bf3a4d1da2b..8121d603379 100644 --- a/qcodes/utils/dataset/doNd.py +++ b/qcodes/dataset/doNd.py @@ -267,7 +267,6 @@ def do1d( _set_write_period(meas, write_period) _register_actions(meas, enter_actions, exit_actions) - if use_threads is None: use_threads = config.dataset.use_threads @@ -808,7 +807,10 @@ def dond( for setpoints in tqdm(nested_setpoints, disable=not show_progress): active_actions, delays = _select_active_actions_delays( - post_actions, post_delays, setpoints, previous_setpoints, + post_actions, + post_delays, + setpoints, + previous_setpoints, ) previous_setpoints = setpoints @@ -859,25 +861,26 @@ def dond( def _parse_dond_arguments( - *params: Union[AbstractSweep, Union[ParamMeasT, Sequence[ParamMeasT]]] - ) -> Tuple[List[AbstractSweep], List[Union[ParamMeasT, Sequence[ParamMeasT]]]]: - """ - Parse supplied arguments into sweep objects and measurement parameters - and their callables. - """ - sweep_instances: List[AbstractSweep] = [] - params_meas: List[Union[ParamMeasT, Sequence[ParamMeasT]]] = [] - for par in params: - if isinstance(par, AbstractSweep): - sweep_instances.append(par) - else: - params_meas.append(par) - return sweep_instances, params_meas + *params: Union[AbstractSweep, Union[ParamMeasT, Sequence[ParamMeasT]]] +) -> Tuple[List[AbstractSweep], List[Union[ParamMeasT, Sequence[ParamMeasT]]]]: + """ + Parse supplied arguments into sweep objects and measurement parameters + and their callables. + """ + sweep_instances: List[AbstractSweep] = [] + params_meas: List[Union[ParamMeasT, Sequence[ParamMeasT]]] = [] + for par in params: + if isinstance(par, AbstractSweep): + sweep_instances.append(par) + else: + params_meas.append(par) + return sweep_instances, params_meas def _conditional_parameter_set( - parameter: _BaseParameter, value: Union[float, complex], - ) -> None: + parameter: _BaseParameter, + value: Union[float, complex], +) -> None: """ Reads the cache value of the given parameter and set the parameter to the given value if the value is different from the cache value. @@ -887,13 +890,13 @@ def _conditional_parameter_set( def _make_nested_setpoints(sweeps: List[AbstractSweep]) -> np.ndarray: - """Create the cartesian product of all the setpoint values.""" - if len(sweeps) == 0: - return np.array([[]]) # 0d sweep (do0d) - setpoint_values = [sweep.get_setpoints() for sweep in sweeps] - setpoint_grids = np.meshgrid(*setpoint_values, indexing="ij") - flat_setpoint_grids = [np.ravel(grid, order="C") for grid in setpoint_grids] - return np.vstack(flat_setpoint_grids).T + """Create the cartesian product of all the setpoint values.""" + if len(sweeps) == 0: + return np.array([[]]) # 0d sweep (do0d) + setpoint_values = [sweep.get_setpoints() for sweep in sweeps] + setpoint_grids = np.meshgrid(*setpoint_values, indexing="ij") + flat_setpoint_grids = [np.ravel(grid, order="C") for grid in setpoint_grids] + return np.vstack(flat_setpoint_grids).T def _select_active_actions_delays( @@ -1032,6 +1035,7 @@ def plot( save_png: Save figure in png format. """ from qcodes.dataset.plotting import plot_dataset + dataid = data.captured_run_id axes, cbs = plot_dataset(data) mainfolder = config.user.mainfolder From 1313ce0f97d9c81de440f4a34636fd15f89ccb94 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Fri, 4 Mar 2022 15:09:23 +0100 Subject: [PATCH 05/31] Add donds to public dataset api --- qcodes/dataset/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qcodes/dataset/__init__.py b/qcodes/dataset/__init__.py index 58965982c81..01dd78c6d62 100644 --- a/qcodes/dataset/__init__.py +++ b/qcodes/dataset/__init__.py @@ -12,6 +12,7 @@ from .data_set_in_memory import load_from_netcdf from .data_set_protocol import DataSetProtocol, DataSetType from .descriptions.param_spec import ParamSpec +from .doNd import AbstractSweep, ArraySweep, LinSweep, LogSweep, do0d, do1d, do2d, dond from .experiment_container import ( experiments, load_experiment, @@ -39,6 +40,14 @@ "DataSetProtocol", "DataSetType", "ParamSpec", + "do0d", + "do1d", + "do2d", + "dond", + "AbstractSweep", + "ArraySweep", + "LinSweep", + "LogSweep", "experiments", "load_experiment", "load_experiment_by_name", From c88ac7b960bb13a3f1010f1fca5184a0472bf7be Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Fri, 4 Mar 2022 15:17:26 +0100 Subject: [PATCH 06/31] Add shim for backwards compatibility --- qcodes/utils/dataset/doNd.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 qcodes/utils/dataset/doNd.py diff --git a/qcodes/utils/dataset/doNd.py b/qcodes/utils/dataset/doNd.py new file mode 100644 index 00000000000..d04064f0307 --- /dev/null +++ b/qcodes/utils/dataset/doNd.py @@ -0,0 +1,21 @@ +from qcodes.dataset.doNd import ( + AbstractSweep, + ArraySweep, + LinSweep, + LogSweep, + do0d, + do1d, + do2d, + dond, +) + +__all__ = [ + "do0d", + "do1d", + "do2d", + "dond", + "AbstractSweep", + "ArraySweep", + "LinSweep", + "LogSweep", +] From 387c4a00e2135ebc9dc53a233374f7b6c2dd9a22 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Fri, 4 Mar 2022 15:22:18 +0100 Subject: [PATCH 07/31] fix incorrect imports --- qcodes/dataset/doNd.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qcodes/dataset/doNd.py b/qcodes/dataset/doNd.py index 8121d603379..54e69c82795 100644 --- a/qcodes/dataset/doNd.py +++ b/qcodes/dataset/doNd.py @@ -6,7 +6,8 @@ from contextlib import ExitStack, contextmanager from typing import Callable, Dict, Iterator, List, Optional, Sequence, Tuple, Union -import matplotlib +import matplotlib.axes +import matplotlib.colorbar import numpy as np from tqdm.auto import tqdm from typing_extensions import TypedDict From 6e214406b1c50e030efaaf2e76e4e0092ba14412 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Fri, 4 Mar 2022 15:31:43 +0100 Subject: [PATCH 08/31] update test imports for new location --- qcodes/tests/dataset/test_database_extract_runs.py | 2 +- qcodes/tests/dataset/test_doNd.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qcodes/tests/dataset/test_database_extract_runs.py b/qcodes/tests/dataset/test_database_extract_runs.py index 14a5ffdbf51..02663bf31f8 100644 --- a/qcodes/tests/dataset/test_database_extract_runs.py +++ b/qcodes/tests/dataset/test_database_extract_runs.py @@ -22,6 +22,7 @@ load_by_run_spec, ) from qcodes.dataset.database_extract_runs import extract_runs_into_db +from qcodes.dataset.doNd import do1d, do2d from qcodes.dataset.experiment_container import ( Experiment, load_experiment_by_name, @@ -34,7 +35,6 @@ from qcodes.dataset.sqlite.queries import get_experiments from qcodes.tests.common import error_caused_by from qcodes.tests.instrument_mocks import DummyInstrument -from qcodes.utils.dataset.doNd import do1d, do2d @contextmanager diff --git a/qcodes/tests/dataset/test_doNd.py b/qcodes/tests/dataset/test_doNd.py index 8227af3c51f..53b1280d74d 100644 --- a/qcodes/tests/dataset/test_doNd.py +++ b/qcodes/tests/dataset/test_doNd.py @@ -11,6 +11,7 @@ from qcodes import config from qcodes.dataset import new_experiment from qcodes.dataset.data_set import DataSet +from qcodes.dataset.doNd import ArraySweep, LinSweep, LogSweep, do0d, do1d, do2d, dond from qcodes.instrument.parameter import Parameter, _BaseParameter from qcodes.tests.instrument_mocks import ( ArraySetPointParam, @@ -19,7 +20,6 @@ MultiSetPointParam, ) from qcodes.utils import validators -from qcodes.utils.dataset.doNd import ArraySweep, LinSweep, LogSweep, do0d, do1d, do2d, dond from qcodes.utils.validators import Arrays from .conftest import ArrayshapedParam From 9bb1ff228e203593245e305b48026d8475c9a6ba Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Fri, 4 Mar 2022 15:50:50 +0100 Subject: [PATCH 09/31] move plot and save function to the module where it belongs and give more descriptive name Readd an alias in the old location --- qcodes/dataset/doNd.py | 43 ++---------------------------------- qcodes/dataset/plotting.py | 41 ++++++++++++++++++++++++++++++++++ qcodes/utils/dataset/doNd.py | 2 ++ 3 files changed, 45 insertions(+), 41 deletions(-) diff --git a/qcodes/dataset/doNd.py b/qcodes/dataset/doNd.py index 54e69c82795..9575735ff52 100644 --- a/qcodes/dataset/doNd.py +++ b/qcodes/dataset/doNd.py @@ -18,6 +18,7 @@ from qcodes.dataset.descriptions.versioning.rundescribertypes import Shapes from qcodes.dataset.experiment_container import Experiment from qcodes.dataset.measurements import Measurement +from qcodes.dataset.plotting import plot_and_save_image from qcodes.instrument.parameter import _BaseParameter from qcodes.utils.threading import ( SequentialParamsCaller, @@ -1009,7 +1010,7 @@ def _handle_plotting( """ if do_plot: - res = plot(data) + res = plot_and_save_image(data) else: res = data, [None], [None] @@ -1017,43 +1018,3 @@ def _handle_plotting( raise interrupted return res - - -def plot( - data: DataSetProtocol, save_pdf: bool = True, save_png: bool = True -) -> Tuple[ - DataSetProtocol, - List[matplotlib.axes.Axes], - List[Optional[matplotlib.colorbar.Colorbar]], -]: - """ - The utility function to plot results and save the figures either in pdf or - png or both formats. - - Args: - data: The QCoDeS dataset to be plotted. - save_pdf: Save figure in pdf format. - save_png: Save figure in png format. - """ - from qcodes.dataset.plotting import plot_dataset - - dataid = data.captured_run_id - axes, cbs = plot_dataset(data) - mainfolder = config.user.mainfolder - experiment_name = data.exp_name - sample_name = data.sample_name - storage_dir = os.path.join(mainfolder, experiment_name, sample_name) - os.makedirs(storage_dir, exist_ok=True) - png_dir = os.path.join(storage_dir, "png") - pdf_dif = os.path.join(storage_dir, "pdf") - os.makedirs(png_dir, exist_ok=True) - os.makedirs(pdf_dif, exist_ok=True) - for i, ax in enumerate(axes): - if save_pdf: - full_path = os.path.join(pdf_dif, f"{dataid}_{i}.pdf") - ax.figure.savefig(full_path, dpi=500) - if save_png: - full_path = os.path.join(png_dir, f"{dataid}_{i}.png") - ax.figure.savefig(full_path, dpi=500) - res = data, axes, cbs - return res diff --git a/qcodes/dataset/plotting.py b/qcodes/dataset/plotting.py index 2c7c8d6d1e5..b8dd0ba8c68 100644 --- a/qcodes/dataset/plotting.py +++ b/qcodes/dataset/plotting.py @@ -5,6 +5,7 @@ import inspect import logging +import os from contextlib import contextmanager from functools import partial from typing import Any, List, Optional, Sequence, Tuple, Union, cast @@ -306,6 +307,46 @@ def plot_dataset( return axeslist, new_colorbars +def plot_and_save_image( + data: DataSetProtocol, save_pdf: bool = True, save_png: bool = True +) -> Tuple[ + DataSetProtocol, + List[matplotlib.axes.Axes], + List[Optional[matplotlib.colorbar.Colorbar]], +]: + """ + The utility function to plot results and save the figures either in pdf or + png or both formats. + + Args: + data: The QCoDeS dataset to be plotted. + save_pdf: Save figure in pdf format. + save_png: Save figure in png format. + """ + from qcodes import config + + dataid = data.captured_run_id + axes, cbs = plot_dataset(data) + mainfolder = config.user.mainfolder + experiment_name = data.exp_name + sample_name = data.sample_name + storage_dir = os.path.join(mainfolder, experiment_name, sample_name) + os.makedirs(storage_dir, exist_ok=True) + png_dir = os.path.join(storage_dir, "png") + pdf_dif = os.path.join(storage_dir, "pdf") + os.makedirs(png_dir, exist_ok=True) + os.makedirs(pdf_dif, exist_ok=True) + for i, ax in enumerate(axes): + if save_pdf: + full_path = os.path.join(pdf_dif, f"{dataid}_{i}.pdf") + ax.figure.savefig(full_path, dpi=500) + if save_png: + full_path = os.path.join(png_dir, f"{dataid}_{i}.png") + ax.figure.savefig(full_path, dpi=500) + res = data, axes, cbs + return res + + def plot_by_id( run_id: int, axes: Optional[Union[matplotlib.axes.Axes, Sequence[matplotlib.axes.Axes]]] = None, diff --git a/qcodes/utils/dataset/doNd.py b/qcodes/utils/dataset/doNd.py index d04064f0307..7e9e5150a62 100644 --- a/qcodes/utils/dataset/doNd.py +++ b/qcodes/utils/dataset/doNd.py @@ -8,6 +8,7 @@ do2d, dond, ) +from qcodes.dataset.plotting import plot_and_save_image as plot __all__ = [ "do0d", @@ -18,4 +19,5 @@ "ArraySweep", "LinSweep", "LogSweep", + "plot", ] From a453cd2964721e6f78450b95b2b8aa6ba84bca13 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Fri, 4 Mar 2022 15:55:25 +0100 Subject: [PATCH 10/31] update log message module location --- qcodes/dataset/doNd.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qcodes/dataset/doNd.py b/qcodes/dataset/doNd.py index 9575735ff52..c902b1174ca 100644 --- a/qcodes/dataset/doNd.py +++ b/qcodes/dataset/doNd.py @@ -150,7 +150,7 @@ def do0d( if log_info is not None: meas._extra_log_info = log_info else: - meas._extra_log_info = "Using 'qcodes.utils.dataset.doNd.do0d'" + meas._extra_log_info = "Using 'qcodes.dataset.do0d'" measured_parameters = tuple( param for param in param_meas if isinstance(param, _BaseParameter) @@ -247,7 +247,7 @@ def do1d( if log_info is not None: meas._extra_log_info = log_info else: - meas._extra_log_info = "Using 'qcodes.utils.dataset.doNd.do1d'" + meas._extra_log_info = "Using 'qcodes.dataset.do1d'" all_setpoint_params = (param_set,) + tuple(s for s in additional_setpoints) @@ -396,7 +396,7 @@ def do2d( if log_info is not None: meas._extra_log_info = log_info else: - meas._extra_log_info = "Using 'qcodes.utils.dataset.doNd.do2d'" + meas._extra_log_info = "Using 'qcodes.dataset.do2d'" all_setpoint_params = ( param_set1, param_set2, @@ -938,7 +938,7 @@ def _create_measurements( if log_info is not None: _extra_log_info = log_info else: - _extra_log_info = "Using 'qcodes.utils.dataset.doNd.dond'" + _extra_log_info = "Using 'qcodes.dataset.dond'" for group in grouped_parameters.values(): meas_name = group["meas_name"] meas_params = group["params"] From d64c7c5fc1fcfe227ec99fa8cea64a50aa61e3e5 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Fri, 4 Mar 2022 16:49:55 +0100 Subject: [PATCH 11/31] fix docstring formatting --- qcodes/dataset/doNd.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qcodes/dataset/doNd.py b/qcodes/dataset/doNd.py index c902b1174ca..389e71ac7cd 100644 --- a/qcodes/dataset/doNd.py +++ b/qcodes/dataset/doNd.py @@ -207,7 +207,7 @@ def do1d( stop: End point of sweep num_points: Number of points in sweep delay: Delay after setting parameter before measurement is performed - *param_meas: Parameter(s) to measure at each step or functions that + param_meas: Parameter(s) to measure at each step or functions that will be called at each step. The function should take no arguments. The parameters and functions are called in the order they are supplied. @@ -349,7 +349,7 @@ def do2d( stop2: End point of sweep in the inner loop num_points2: Number of points to measure in the inner loop delay2: Delay after setting parameter before measurement is performed - *param_meas: Parameter(s) to measure at each step or functions that + param_meas: Parameter(s) to measure at each step or functions that will be called at each step. The function should take no arguments. The parameters and functions are called in the order they are supplied. @@ -690,7 +690,7 @@ def dond( as sweep objects, and after them the parameters to measure should be passed. Args: - *params: Instances of n sweep classes and m measurement parameters, + params: Instances of n sweep classes and m measurement parameters, e.g. if linear sweep is considered: .. code-block:: From da995d7b8ac68d2ed7d2491e3bed60dd604bf6ac Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Mon, 7 Mar 2022 10:29:26 +0100 Subject: [PATCH 12/31] Fix incorrect literal str formatting --- qcodes/dataset/doNd.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qcodes/dataset/doNd.py b/qcodes/dataset/doNd.py index 389e71ac7cd..640d2946158 100644 --- a/qcodes/dataset/doNd.py +++ b/qcodes/dataset/doNd.py @@ -224,12 +224,12 @@ def do1d( value of 'results' is used for the dataset. exp: The experiment to use for this measurement. do_plot: should png and pdf versions of the images be saved after the - run. If None the setting will be read from ``qcodesrc.json` + run. If None the setting will be read from ``qcodesrc.json`` use_threads: If True measurements from each instrument will be done on separate threads. If you are measuring from several instruments this may give a significant speedup. show_progress: should a progress bar be displayed during the - measurement. If None the setting will be read from ``qcodesrc.json` + measurement. If None the setting will be read from ``qcodesrc.json`` log_info: Message that is logged during the measurement. If None a default message is used. break_condition: Callable that takes no arguments. If returned True, @@ -377,7 +377,7 @@ def do2d( separate threads. If you are measuring from several instruments this may give a significant speedup. show_progress: should a progress bar be displayed during the - measurement. If None the setting will be read from ``qcodesrc.json` + measurement. If None the setting will be read from ``qcodesrc.json`` log_info: Message that is logged during the measurement. If None a default message is used. break_condition: Callable that takes no arguments. If returned True, @@ -722,7 +722,7 @@ def dond( are shown after the run. If None the setting will be read from ``qcodesrc.json`` show_progress: should a progress bar be displayed during the - measurement. If None the setting will be read from ``qcodesrc.json` + measurement. If None the setting will be read from ``qcodesrc.json`` use_threads: If True, measurements from each instrument will be done on separate threads. If you are measuring from several instruments this may give a significant speedup. From 51520af0b0008e788e5f6d38096655c28353d76a Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Mon, 7 Mar 2022 11:08:03 +0100 Subject: [PATCH 13/31] remove unused import --- qcodes/dataset/doNd.py | 1 - 1 file changed, 1 deletion(-) diff --git a/qcodes/dataset/doNd.py b/qcodes/dataset/doNd.py index 640d2946158..abceabe2d64 100644 --- a/qcodes/dataset/doNd.py +++ b/qcodes/dataset/doNd.py @@ -1,5 +1,4 @@ import logging -import os import sys import time from abc import ABC, abstractmethod From 345a47fd636fb3cda2df70143a93e490aac30a50 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Mon, 7 Mar 2022 11:08:19 +0100 Subject: [PATCH 14/31] temp disable old location --- qcodes/utils/dataset/doNd.py | 46 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/qcodes/utils/dataset/doNd.py b/qcodes/utils/dataset/doNd.py index 7e9e5150a62..76e8deb9cc5 100644 --- a/qcodes/utils/dataset/doNd.py +++ b/qcodes/utils/dataset/doNd.py @@ -1,23 +1,23 @@ -from qcodes.dataset.doNd import ( - AbstractSweep, - ArraySweep, - LinSweep, - LogSweep, - do0d, - do1d, - do2d, - dond, -) -from qcodes.dataset.plotting import plot_and_save_image as plot - -__all__ = [ - "do0d", - "do1d", - "do2d", - "dond", - "AbstractSweep", - "ArraySweep", - "LinSweep", - "LogSweep", - "plot", -] +# from qcodes.dataset.doNd import ( +# AbstractSweep, +# ArraySweep, +# LinSweep, +# LogSweep, +# do0d, +# do1d, +# do2d, +# dond, +# ) +# from qcodes.dataset.plotting import plot_and_save_image as plot +# +# __all__ = [ +# "do0d", +# "do1d", +# "do2d", +# "dond", +# "AbstractSweep", +# "ArraySweep", +# "LinSweep", +# "LogSweep", +# "plot", +# ] From bf8f02ddb7bea7ad3e0519f11b03aad5891c2f28 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Mon, 7 Mar 2022 11:23:15 +0100 Subject: [PATCH 15/31] make utils import independent of qcodes To hopefully break circular imports --- qcodes/utils/installation.py | 4 ++-- qcodes/utils/plotting.py | 9 +++++---- qcodes/utils/slack.py | 11 ++++++----- qcodes/utils/threading.py | 26 +++++++++++++------------- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/qcodes/utils/installation.py b/qcodes/utils/installation.py index 6b23cd2661e..99a8eac047a 100644 --- a/qcodes/utils/installation.py +++ b/qcodes/utils/installation.py @@ -1,10 +1,9 @@ """This module contains helper scripts to make certain installation tasks easier.""" +import json import os import sys -import json -from qcodes.station import SCHEMA_PATH, STATION_YAML_EXT, update_config_schema def register_station_schema_with_vscode() -> None: @@ -26,6 +25,7 @@ def register_station_schema_with_vscode() -> None: For more information consult `qcodes/docs/examples/Station.ipynb`. """ + from qcodes.station import SCHEMA_PATH, STATION_YAML_EXT, update_config_schema if sys.platform != 'win32': raise RuntimeError( 'This script is only supported on Windows platforms.\n ' diff --git a/qcodes/utils/plotting.py b/qcodes/utils/plotting.py index 311c8f79e8b..b246d247c2a 100644 --- a/qcodes/utils/plotting.py +++ b/qcodes/utils/plotting.py @@ -6,13 +6,13 @@ """ import copy import logging -from typing import Tuple, Union, Optional, Any, cast, Set, Dict from collections import OrderedDict -import numpy as np +from typing import Any, Dict, Optional, Set, Tuple, Union, cast + import matplotlib -import matplotlib.colorbar import matplotlib.collections -import qcodes +import matplotlib.colorbar +import numpy as np log = logging.getLogger(__name__) @@ -253,6 +253,7 @@ def auto_color_scale_from_config(colorbar: matplotlib.colorbar.Colorbar, by the lower limit. Default value is read from ``config.plotting.auto_color_scale.color_under``. """ + import qcodes if colorbar is None: log.warning('"auto_color_scale_from_config" did not receive a colorbar ' 'for scaling. Are you trying to scale a plot without ' diff --git a/qcodes/utils/slack.py b/qcodes/utils/slack.py index 4a93d79d729..399e1a48df9 100644 --- a/qcodes/utils/slack.py +++ b/qcodes/utils/slack.py @@ -56,11 +56,6 @@ from requests.packages.urllib3.exceptions import ReadTimeoutError from slack_sdk import WebClient -from qcodes import config as qc_config -from qcodes.instrument.parameter import _BaseParameter -from qcodes.loops import active_data_set, active_loop -from qcodes.plots.base import BasePlot - class SlackTimeoutWarning(UserWarning): pass @@ -123,6 +118,7 @@ def __init__(self, interval=3, config=None, auto_start=True, **commands): auto_start (bool): Defaults to True. """ + from qcodes import config as qc_config if config is not None: self.config = config else: @@ -328,6 +324,7 @@ def handle_messages(self, messages): Performs commands depending on messages. This includes adding tasks to be performed during each update. """ + from qcodes.instrument.parameter import _BaseParameter for user, user_messages in messages.items(): for message in user_messages: if message.get('user', None) != self.users[user]['id']: @@ -409,6 +406,8 @@ def upload_latest_plot(self, channel, **kwargs): Returns: None. """ + from qcodes.plots.base import BasePlot + # Create temporary filename temp_filename = tempfile.mktemp(suffix='.jpg') # Retrieve latest plot @@ -436,6 +435,7 @@ def print_measurement_information(self, channel, **kwargs): Returns: None. """ + from qcodes.loops import active_data_set dataset = active_data_set() if dataset is not None: self.slack.chat_postMessage( @@ -459,6 +459,7 @@ def check_msmt_finished(self, channel, **kwargs): Returns: bool: True if measurement is finished, False otherwise. """ + from qcodes.loops import active_loop if active_loop() is None: self.slack.chat_postMessage( text='Measurement complete', diff --git a/qcodes/utils/threading.py b/qcodes/utils/threading.py index 4b9ae9ec999..4451897af4b 100644 --- a/qcodes/utils/threading.py +++ b/qcodes/utils/threading.py @@ -11,6 +11,7 @@ from functools import partial from types import TracebackType from typing import ( + TYPE_CHECKING, Any, Callable, Dict, @@ -25,13 +26,12 @@ from typing_extensions import Protocol -from qcodes import config -from qcodes.dataset.measurements import res_type -from qcodes.instrument.parameter import ParamDataType, _BaseParameter +if TYPE_CHECKING: + from qcodes.dataset.measurements import res_type + from qcodes.instrument.parameter import ParamDataType, _BaseParameter -ParamMeasT = Union[_BaseParameter, Callable[[], None]] - -OutType = List[res_type] +ParamMeasT = Union["_BaseParameter", Callable[[], None]] +OutType = List["res_type"] T = TypeVar("T") @@ -121,11 +121,11 @@ def thread_map( class _ParamCaller: - def __init__(self, *parameters: _BaseParameter): + def __init__(self, *parameters: "_BaseParameter"): self._parameters = parameters - def __call__(self) -> Tuple[Tuple[_BaseParameter, ParamDataType], ...]: + def __call__(self) -> Tuple[Tuple["_BaseParameter", "ParamDataType"], ...]: output = [] for param in self._parameters: output.append((param, param.get())) @@ -138,12 +138,12 @@ def __repr__(self) -> str: def _instrument_to_param( params: Sequence[ParamMeasT] -) -> Dict[Optional[str], Tuple[_BaseParameter, ...]]: - +) -> Dict[Optional[str], Tuple["_BaseParameter", ...]]: + from qcodes.instrument.parameter import _BaseParameter real_parameters = [param for param in params if isinstance(param, _BaseParameter)] - output: Dict[Optional[str], Tuple[_BaseParameter, ...]] = defaultdict(tuple) + output: Dict[Optional[str], Tuple["_BaseParameter", ...]] = defaultdict(tuple) for param in real_parameters: if param.underlying_instrument: output[param.underlying_instrument.full_name] += (param,) @@ -185,7 +185,7 @@ def call_params_threaded(param_meas: Sequence[ParamMeasT]) -> OutType: def _call_params(param_meas: Sequence[ParamMeasT]) -> OutType: - + from qcodes.instrument.parameter import _BaseParameter output: OutType = [] for parameter in param_meas: @@ -201,7 +201,7 @@ def process_params_meas( param_meas: Sequence[ParamMeasT], use_threads: Optional[bool] = None ) -> OutType: - + from qcodes import config if use_threads is None: use_threads = config.dataset.use_threads From 1f1a23defc99da768e69b75bfb2eeed40018346d Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 8 Jun 2022 15:25:13 +0200 Subject: [PATCH 16/31] Move slask and installation into new ext module --- qcodes/extensions/__init__.py | 4 + qcodes/{utils => extensions}/installation.py | 32 ++-- qcodes/{utils => extensions}/slack.py | 154 +++++++++---------- 3 files changed, 94 insertions(+), 96 deletions(-) create mode 100644 qcodes/extensions/__init__.py rename qcodes/{utils => extensions}/installation.py (63%) rename qcodes/{utils => extensions}/slack.py (75%) diff --git a/qcodes/extensions/__init__.py b/qcodes/extensions/__init__.py new file mode 100644 index 00000000000..a1c6d152242 --- /dev/null +++ b/qcodes/extensions/__init__.py @@ -0,0 +1,4 @@ +""" +The extensions module contains smaller modules that extend the functionality of QCoDeS. +These modules may import from all of QCoDeS but do not them self get imported into QCoDeS. +""" diff --git a/qcodes/utils/installation.py b/qcodes/extensions/installation.py similarity index 63% rename from qcodes/utils/installation.py rename to qcodes/extensions/installation.py index 99a8eac047a..1334a052d64 100644 --- a/qcodes/utils/installation.py +++ b/qcodes/extensions/installation.py @@ -5,6 +5,8 @@ import os import sys +from qcodes.station import SCHEMA_PATH, STATION_YAML_EXT, update_config_schema + def register_station_schema_with_vscode() -> None: """This function registeres the qcodes station schema with vscode. @@ -25,30 +27,32 @@ def register_station_schema_with_vscode() -> None: For more information consult `qcodes/docs/examples/Station.ipynb`. """ - from qcodes.station import SCHEMA_PATH, STATION_YAML_EXT, update_config_schema - if sys.platform != 'win32': + if sys.platform != "win32": raise RuntimeError( - 'This script is only supported on Windows platforms.\n ' - 'Please consult docstring for more information.') + "This script is only supported on Windows platforms.\n " + "Please consult docstring for more information." + ) if not os.path.exists(SCHEMA_PATH): update_config_schema() config_path = os.path.expandvars( - os.path.join('%APPDATA%', 'Code', 'User', 'settings.json')) - config_backup_path = config_path + '_backup' + os.path.join("%APPDATA%", "Code", "User", "settings.json") + ) + config_backup_path = config_path + "_backup" if not os.path.exists(config_path): raise RuntimeError( - 'Could not find the user settings file of vscode. \n' - 'Please refer to the station.ipynb notebook to learn how to ' - 'set the settings manually.') - with open(config_path, 'r+') as f: + "Could not find the user settings file of vscode. \n" + "Please refer to the station.ipynb notebook to learn how to " + "set the settings manually." + ) + with open(config_path, "r+") as f: data = json.load(f) - data.setdefault( - 'yaml.schemas', {} - )[r'file:\\' + os.path.splitdrive(SCHEMA_PATH)[1]] = STATION_YAML_EXT + data.setdefault("yaml.schemas", {})[ + r"file:\\" + os.path.splitdrive(SCHEMA_PATH)[1] + ] = STATION_YAML_EXT os.replace(config_path, config_backup_path) - with open(config_path, 'w') as f: + with open(config_path, "w") as f: json.dump(data, f, indent=4) diff --git a/qcodes/utils/slack.py b/qcodes/extensions/slack.py similarity index 75% rename from qcodes/utils/slack.py rename to qcodes/extensions/slack.py index 399e1a48df9..ffb6bcd18fb 100644 --- a/qcodes/utils/slack.py +++ b/qcodes/extensions/slack.py @@ -56,6 +56,11 @@ from requests.packages.urllib3.exceptions import ReadTimeoutError from slack_sdk import WebClient +from qcodes import config as qc_config +from qcodes.instrument.parameter import _BaseParameter +from qcodes.loops import active_data_set, active_loop +from qcodes.plots.base import BasePlot + class SlackTimeoutWarning(UserWarning): pass @@ -77,16 +82,16 @@ def try_convert_str(string): return string # Format text to lowercase, and remove trailing whitespaces - text = text.lower().rstrip(' ') - command, *args_str = text.split(' ') + text = text.lower().rstrip(" ") + command, *args_str = text.split(" ") # Convert string args to floats/kwargs args = [] kwargs = {} for arg in args_str: - if '=' in arg: + if "=" in arg: # arg is a kwarg - key, val = arg.split('=') + key, val = arg.split("=") # Try to convert into a float val = try_convert_str(val) kwargs[key] = val @@ -99,7 +104,6 @@ def try_convert_str(string): class Slack(threading.Thread): - def __init__(self, interval=3, config=None, auto_start=True, **commands): """ Initializes Slack bot, including auto-updating widget if in notebook @@ -118,24 +122,25 @@ def __init__(self, interval=3, config=None, auto_start=True, **commands): auto_start (bool): Defaults to True. """ - from qcodes import config as qc_config if config is not None: self.config = config else: self.config = qc_config.user.slack - self.slack = WebClient(token=self.config['token']) - self.users = self.get_users(self.config['names']) + self.slack = WebClient(token=self.config["token"]) + self.users = self.get_users(self.config["names"]) self.get_im_ids(self.users) - self.commands = {'plot': self.upload_latest_plot, - 'msmt': self.print_measurement_information, - 'measurement': self.print_measurement_information, - 'notify': self.add_task, - 'help': self.help_message, - 'task': self.add_task, - **commands} - self.task_commands = {'finished': self.check_msmt_finished} + self.commands = { + "plot": self.upload_latest_plot, + "msmt": self.print_measurement_information, + "measurement": self.print_measurement_information, + "notify": self.add_task, + "help": self.help_message, + "task": self.add_task, + **commands, + } + self.task_commands = {"finished": self.check_msmt_finished} self.interval = interval self.tasks = [] @@ -201,7 +206,7 @@ def user_from_id(self, user_id): Returns: dict: User information. """ - return self.slack.users_info(user=user_id)['user'] + return self.slack.users_info(user=user_id)["user"] def get_users(self, usernames): """ @@ -214,13 +219,12 @@ def get_users(self, usernames): """ users = {} response = self.slack.users_list() - for member in response['members']: - if member['name'] in usernames: - users[member['name']] = member + for member in response["members"]: + if member["name"] in usernames: + users[member["name"]] = member if len(users) != len(usernames): remaining_names = [name for name in usernames if name not in users] - raise RuntimeError( - f'Could not find names {remaining_names}') + raise RuntimeError(f"Could not find names {remaining_names}") return users def get_im_ids(self, users): @@ -233,18 +237,18 @@ def get_im_ids(self, users): Returns: None. """ - response = self.slack.conversations_list(types='im') - user_ids = {username: user['id'] for username, user in users.items()} - im_ids = {chan['user']: chan['id'] for chan in response['channels']} + response = self.slack.conversations_list(types="im") + user_ids = {username: user["id"] for username, user in users.items()} + im_ids = {chan["user"]: chan["id"] for chan in response["channels"]} for username, user_id in user_ids.items(): if user_id in im_ids.keys(): - users[username]['im_id'] = im_ids[user_id] + users[username]["im_id"] = im_ids[user_id] # update last ts messages = self.get_im_messages(username=username, limit=1) if messages: - users[username]['last_ts'] = float(messages[0]['ts']) + users[username]["last_ts"] = float(messages[0]["ts"]) else: - users[username]['last_ts'] = None + users[username]["last_ts"] = None def get_im_messages(self, username, **kwargs): """ @@ -259,16 +263,15 @@ def get_im_messages(self, username, **kwargs): # provide backward compatibility with 'count' keyword. It still works, # but is undocumented. 'count' likely does the same as 'limit', but # 'limit' takes precedence - if 'limit' not in kwargs.keys(): - kwargs['limit'] = kwargs.pop('count', None) + if "limit" not in kwargs.keys(): + kwargs["limit"] = kwargs.pop("count", None) - channel = self.users[username].get('im_id', None) + channel = self.users[username].get("im_id", None) if channel is None: return [] else: - response = self.slack.conversations_history(channel=channel, - **kwargs) - return response['messages'] + response = self.slack.conversations_history(channel=channel, **kwargs) + return response["messages"] def get_new_im_messages(self): """ @@ -279,15 +282,13 @@ def get_new_im_messages(self): """ im_messages = {} for username, user in self.users.items(): - last_ts = user.get('last_ts', None) - new_messages = self.get_im_messages(username=username, - oldest=last_ts) + last_ts = user.get("last_ts", None) + new_messages = self.get_im_messages(username=username, oldest=last_ts) # Kwarg 'oldest' sometimes also returns message with ts==last_ts - new_messages = [m for m in new_messages if - float(m['ts']) != last_ts] + new_messages = [m for m in new_messages if float(m["ts"]) != last_ts] im_messages[username] = new_messages if new_messages: - self.users[username]['last_ts'] = float(new_messages[0]['ts']) + self.users[username]["last_ts"] = float(new_messages[0]["ts"]) return im_messages def update(self): @@ -309,8 +310,7 @@ def update(self): new_messages = self.get_new_im_messages() except (ReadTimeout, HTTPError, ConnectTimeout, ReadTimeoutError) as e: # catch any timeouts caused by network delays - warnings.warn('error retrieving slack messages', - SlackTimeoutWarning) + warnings.warn("error retrieving slack messages", SlackTimeoutWarning) logging.info(e) self.handle_messages(new_messages) @@ -324,21 +324,20 @@ def handle_messages(self, messages): Performs commands depending on messages. This includes adding tasks to be performed during each update. """ - from qcodes.instrument.parameter import _BaseParameter for user, user_messages in messages.items(): for message in user_messages: - if message.get('user', None) != self.users[user]['id']: + if message.get("user", None) != self.users[user]["id"]: # Filter out bot messages continue - channel = self.users[user]['im_id'] + channel = self.users[user]["im_id"] # Extract command (first word) and possible args - command, args, kwargs = convert_command(message['text']) + command, args, kwargs = convert_command(message["text"]) if command in self.commands: - msg = f'Executing {command}' + msg = f"Executing {command}" if args: - msg += f' {args}' + msg += f" {args}" if kwargs: - msg += f' {kwargs}' + msg += f" {kwargs}" self.slack.chat_postMessage(text=msg, channel=channel) func = self.commands[command] @@ -349,26 +348,26 @@ def handle_messages(self, messages): # Only add channel and Slack if they are explicit # kwargs func_sig = inspect.signature(func) - if 'channel' in func_sig.parameters: - kwargs['channel'] = channel - if 'slack' in func_sig.parameters: - kwargs['slack'] = self + if "channel" in func_sig.parameters: + kwargs["channel"] = channel + if "slack" in func_sig.parameters: + kwargs["slack"] = self results = func(*args, **kwargs) if results is not None: self.slack.chat_postMessage( - text=f'Results: {results}', - channel=channel) + text=f"Results: {results}", channel=channel + ) except Exception: self.slack.chat_postMessage( - text=f'Error: {traceback.format_exc()}', - channel=channel) + text=f"Error: {traceback.format_exc()}", channel=channel + ) else: self.slack.chat_postMessage( - text='Command {} not understood. Try `help`'.format( - command), - channel=channel) + text=f"Command {command} not understood. Try `help`", + channel=channel, + ) def add_task(self, command, *args, channel, **kwargs): """ @@ -383,15 +382,13 @@ def add_task(self, command, *args, channel, **kwargs): None. """ if command in self.task_commands: - self.slack.chat_postMessage( - text=f'Added task "{command}"', - channel=channel) + self.slack.chat_postMessage(text=f'Added task "{command}"', channel=channel) func = self.task_commands[command] self.tasks.append(partial(func, *args, channel=channel, **kwargs)) else: self.slack.chat_postMessage( - text=f'Task command {command} not understood', - channel=channel) + text=f"Task command {command} not understood", channel=channel + ) def upload_latest_plot(self, channel, **kwargs): """ @@ -406,10 +403,9 @@ def upload_latest_plot(self, channel, **kwargs): Returns: None. """ - from qcodes.plots.base import BasePlot # Create temporary filename - temp_filename = tempfile.mktemp(suffix='.jpg') + temp_filename = tempfile.mktemp(suffix=".jpg") # Retrieve latest plot latest_plot = BasePlot.latest_plot if latest_plot is not None: @@ -419,8 +415,7 @@ def upload_latest_plot(self, channel, **kwargs): self.slack.files_upload(file=temp_filename, channels=channel) os.remove(temp_filename) else: - self.slack.chat_postMessage(text='No latest plot', - channel=channel) + self.slack.chat_postMessage(text="No latest plot", channel=channel) def print_measurement_information(self, channel, **kwargs): """ @@ -435,19 +430,17 @@ def print_measurement_information(self, channel, **kwargs): Returns: None. """ - from qcodes.loops import active_data_set dataset = active_data_set() if dataset is not None: self.slack.chat_postMessage( - text='Measurement is {:.0f}% complete'.format( - 100 * dataset.fraction_complete()), - channel=channel) - self.slack.chat_postMessage( - text=repr(dataset), channel=channel) + text="Measurement is {:.0f}% complete".format( + 100 * dataset.fraction_complete() + ), + channel=channel, + ) + self.slack.chat_postMessage(text=repr(dataset), channel=channel) else: - self.slack.chat_postMessage( - text='No latest dataset found', - channel=channel) + self.slack.chat_postMessage(text="No latest dataset found", channel=channel) def check_msmt_finished(self, channel, **kwargs): """ @@ -459,11 +452,8 @@ def check_msmt_finished(self, channel, **kwargs): Returns: bool: True if measurement is finished, False otherwise. """ - from qcodes.loops import active_loop if active_loop() is None: - self.slack.chat_postMessage( - text='Measurement complete', - channel=channel) + self.slack.chat_postMessage(text="Measurement complete", channel=channel) return True else: return False From 7fa8c5da1c0e1aeedf383154763f4ec3ca8d9d89 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 8 Jun 2022 15:32:14 +0200 Subject: [PATCH 17/31] update slack tests to use new location --- qcodes/tests/test_slack.py | 40 ++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/qcodes/tests/test_slack.py b/qcodes/tests/test_slack.py index ba833b08eb1..a1cc359a769 100644 --- a/qcodes/tests/test_slack.py +++ b/qcodes/tests/test_slack.py @@ -45,16 +45,18 @@ def setup_slack(): 'token': '123', 'names': ['dummyuser'] } - import qcodes.utils.slack # pylint: disable=import-outside-toplevel - slack = qcodes.utils.slack.Slack(config=slack_config, auto_start=False) + import qcodes.extensions.slack # pylint: disable=import-outside-toplevel + + slack = qcodes.extensions.slack.Slack(config=slack_config, auto_start=False) return slack def test_convert_command_should_convert_floats(): - import qcodes.utils.slack # pylint: disable=import-outside-toplevel - cmd, arg, kwarg = qcodes.utils.slack.convert_command('comm 0.234 key=0.1') - assert cmd == 'comm' + import qcodes.extensions.slack # pylint: disable=import-outside-toplevel + + cmd, arg, kwarg = qcodes.extensions.slack.convert_command("comm 0.234 key=0.1") + assert cmd == "comm" assert arg == [pytest.approx(0.234)] assert kwarg == {'key': pytest.approx(0.1)} @@ -71,8 +73,9 @@ def test_slack_instance_should_get_config_from_qc_config(): 'names': ['dummyuser'] } cf.add(key='slack', value=slack_config) - import qcodes.utils.slack # pylint: disable=import-outside-toplevel - slack = qcodes.utils.slack.Slack(config=None, auto_start=False) + import qcodes.extensions.slack # pylint: disable=import-outside-toplevel + + slack = qcodes.extensions.slack.Slack(config=None, auto_start=False) assert 'dummyuser' in slack.users.keys() @@ -83,8 +86,9 @@ def test_slack_instance_should_start(mocker): 'names': ['dummyuser'] } mock_thread_start = mocker.patch('threading.Thread.start') - import qcodes.utils.slack # pylint: disable=import-outside-toplevel - _ = qcodes.utils.slack.Slack(config=slack_config) + import qcodes.extensions.slack # pylint: disable=import-outside-toplevel + + _ = qcodes.extensions.slack.Slack(config=slack_config) mock_thread_start.assert_called() @@ -98,8 +102,9 @@ def test_slack_instance_should_not_start_when_already_started(mocker): mock_thread_start = mocker.patch('threading.Thread.start') mock_thread_start.side_effect = RuntimeError - import qcodes.utils.slack # pylint: disable=import-outside-toplevel - _ = qcodes.utils.slack.Slack(config=slack_config) + import qcodes.extensions.slack # pylint: disable=import-outside-toplevel + + _ = qcodes.extensions.slack.Slack(config=slack_config) mock_thread_start.assert_called() @@ -112,8 +117,9 @@ def test_slack_instance_should_start_and_stop(mocker): } mocker.patch('threading.Thread.start') - import qcodes.utils.slack # pylint: disable=import-outside-toplevel - slack = qcodes.utils.slack.Slack(config=slack_config, interval=0) + import qcodes.extensions.slack # pylint: disable=import-outside-toplevel + + slack = qcodes.extensions.slack.Slack(config=slack_config, interval=0) slack.stop() assert not slack._is_active @@ -244,7 +250,7 @@ def test_slack_instance_should_update_with_task_returning_false(slack): def test_slack_instance_should_update_with_task_returning_true(slack, mocker): - mocker.patch('qcodes.utils.slack.active_loop', return_value=not None) + mocker.patch("qcodes.extensions.slack.active_loop", return_value=not None) slack.add_task('finished', channel='CH234') slack.update() @@ -254,7 +260,7 @@ def test_slack_instance_should_update_with_task_returning_true(slack, mocker): def test_slack_instance_should_update_with_exception(slack, mocker): - method_name = 'qcodes.utils.slack.Slack.get_new_im_messages' + method_name = "qcodes.extensions.slack.Slack.get_new_im_messages" mock_get_new_im_messages = mocker.patch(method_name) mocker.patch('warnings.warn') mocker.patch('logging.info') @@ -324,7 +330,7 @@ def test_slack_inst_should_add_unknown_task_command(mock_webclient, slack): def test_slack_inst_should_upload_latest_plot(mock_webclient, slack, mocker): - method_name = 'qcodes.utils.slack.BasePlot.latest_plot' + method_name = "qcodes.extensions.slack.BasePlot.latest_plot" mocker.patch(method_name, return_value=not None) mocker.patch('os.remove') slack.upload_latest_plot(channel='CH234') @@ -341,7 +347,7 @@ def test_slack_inst_should_not_fail_upl_latest_wo_plot(mock_webclient, slack): def test_slack_inst_should_print_measurement(mock_webclient, slack, mocker): dataset = mocker.MagicMock() dataset.fraction_complete.return_value = 0.123 - mocker.patch('qcodes.utils.slack.active_data_set', return_value=dataset) + mocker.patch("qcodes.extensions.slack.active_data_set", return_value=dataset) slack.print_measurement_information(channel='CH234') From 57596d49d53592bfc119c768f198bb8d1c1decf5 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 8 Jun 2022 15:49:14 +0200 Subject: [PATCH 18/31] move slack api docs --- docs/api/extensions/index.rst | 7 +++++++ docs/api/utils/slack.rst | 5 ----- 2 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 docs/api/extensions/index.rst delete mode 100644 docs/api/utils/slack.rst diff --git a/docs/api/extensions/index.rst b/docs/api/extensions/index.rst new file mode 100644 index 00000000000..6e4d6714fac --- /dev/null +++ b/docs/api/extensions/index.rst @@ -0,0 +1,7 @@ +.. _extensions_api : + +qcodes.extensions +================= + +.. automodule:: qcodes.extensions + :autosummary: diff --git a/docs/api/utils/slack.rst b/docs/api/utils/slack.rst deleted file mode 100644 index f16caf967c7..00000000000 --- a/docs/api/utils/slack.rst +++ /dev/null @@ -1,5 +0,0 @@ -qcodes.utils.slack ------------------- - -.. automodule:: qcodes.utils.slack - :members: From 2463047b0642a4dc3334be5770f070e075feabe9 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 8 Jun 2022 15:49:25 +0200 Subject: [PATCH 19/31] move slack mypy config --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c704cb37677..3bb91c63357 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ module = [ "qcodes.plots.*", "qcodes.tests.*", "qcodes.utils.magic", - "qcodes.utils.slack", + "qcodes.extensions.slack", ] disallow_untyped_defs = false From 45149e6fcfe8a75e0fa5cd49cf69b18432894af0 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 8 Jun 2022 16:24:47 +0200 Subject: [PATCH 20/31] minimal update to api docs to pass --- docs/api/index.rst | 1 + docs/api/utils/index.rst | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/index.rst b/docs/api/index.rst index 54ba9c3706b..dd2fb784a6c 100644 --- a/docs/api/index.rst +++ b/docs/api/index.rst @@ -18,6 +18,7 @@ QCoDeS API configuration/index dataset/index + extensions/index instrument/index parameters/index logger/index diff --git a/docs/api/utils/index.rst b/docs/api/utils/index.rst index e16246c5908..1b3d48ff8df 100644 --- a/docs/api/utils/index.rst +++ b/docs/api/utils/index.rst @@ -29,6 +29,5 @@ qcodes.utils magic metadata plotting - slack threading validators From 4cbb40420834cf810537a31d5610d4042839d375 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 8 Jun 2022 16:37:55 +0200 Subject: [PATCH 21/31] convert dataset api to toplevel --- docs/api/dataset/database_extract_runs.rst | 5 ----- docs/api/dataset/index.rst | 22 +--------------------- docs/api/dataset/legacy_import.rst | 5 ----- docs/api/dataset/measurements.rst | 5 ----- docs/api/dataset/plotting.rst | 5 ----- 5 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 docs/api/dataset/database_extract_runs.rst delete mode 100644 docs/api/dataset/legacy_import.rst delete mode 100644 docs/api/dataset/measurements.rst delete mode 100644 docs/api/dataset/plotting.rst diff --git a/docs/api/dataset/database_extract_runs.rst b/docs/api/dataset/database_extract_runs.rst deleted file mode 100644 index bd52199dbd6..00000000000 --- a/docs/api/dataset/database_extract_runs.rst +++ /dev/null @@ -1,5 +0,0 @@ -qcodes.dataset.database_extract_runs ------------------------------------- - -.. automodule:: qcodes.dataset.database_extract_runs - :members: diff --git a/docs/api/dataset/index.rst b/docs/api/dataset/index.rst index 439e72dd2d6..7081de14b06 100644 --- a/docs/api/dataset/index.rst +++ b/docs/api/dataset/index.rst @@ -4,25 +4,5 @@ qcodes.dataset ============== -.. autosummary:: - - qcodes.dataset - qcodes.dataset.measurements - qcodes.dataset.plotting - qcodes.dataset.data_set - qcodes.dataset.database_extract_runs - qcodes.dataset.legacy_import - - .. automodule:: qcodes.dataset - - -.. toctree:: - :maxdepth: 4 - :hidden: - - measurements - plotting - data_set - database_extract_runs - legacy_import + :autosummary: diff --git a/docs/api/dataset/legacy_import.rst b/docs/api/dataset/legacy_import.rst deleted file mode 100644 index e0301d93c86..00000000000 --- a/docs/api/dataset/legacy_import.rst +++ /dev/null @@ -1,5 +0,0 @@ -qcodes.dataset.legacy_import ----------------------------- - -.. automodule:: qcodes.dataset.legacy_import - :members: diff --git a/docs/api/dataset/measurements.rst b/docs/api/dataset/measurements.rst deleted file mode 100644 index 5d2db602e32..00000000000 --- a/docs/api/dataset/measurements.rst +++ /dev/null @@ -1,5 +0,0 @@ -qcodes.dataset.measurements ---------------------------- - -.. automodule:: qcodes.dataset.measurements - :members: diff --git a/docs/api/dataset/plotting.rst b/docs/api/dataset/plotting.rst deleted file mode 100644 index f19d8e60aed..00000000000 --- a/docs/api/dataset/plotting.rst +++ /dev/null @@ -1,5 +0,0 @@ -qcodes.dataset.plotting ------------------------ - -.. automodule:: qcodes.dataset.plotting - :members: From 83179198d2f7899348146f69df1fe33cdb9a6507 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 8 Jun 2022 17:15:18 +0200 Subject: [PATCH 22/31] Add fallback modules for moved modules --- qcodes/extensions/__init__.py | 4 +++ qcodes/utils/dataset/doNd.py | 53 ++++++++++++++++++++--------------- qcodes/utils/installation.py | 10 +++++++ qcodes/utils/slack.py | 10 +++++++ 4 files changed, 54 insertions(+), 23 deletions(-) create mode 100644 qcodes/utils/installation.py create mode 100644 qcodes/utils/slack.py diff --git a/qcodes/extensions/__init__.py b/qcodes/extensions/__init__.py index a1c6d152242..5d812f60f65 100644 --- a/qcodes/extensions/__init__.py +++ b/qcodes/extensions/__init__.py @@ -2,3 +2,7 @@ The extensions module contains smaller modules that extend the functionality of QCoDeS. These modules may import from all of QCoDeS but do not them self get imported into QCoDeS. """ +from .installation import register_station_schema_with_vscode +from .slack import Slack, SlackTimeoutWarning + +__all__ = ["register_station_schema_with_vscode", "Slack", "SlackTimeoutWarning"] diff --git a/qcodes/utils/dataset/doNd.py b/qcodes/utils/dataset/doNd.py index 76e8deb9cc5..adb017f3ea5 100644 --- a/qcodes/utils/dataset/doNd.py +++ b/qcodes/utils/dataset/doNd.py @@ -1,23 +1,30 @@ -# from qcodes.dataset.doNd import ( -# AbstractSweep, -# ArraySweep, -# LinSweep, -# LogSweep, -# do0d, -# do1d, -# do2d, -# dond, -# ) -# from qcodes.dataset.plotting import plot_and_save_image as plot -# -# __all__ = [ -# "do0d", -# "do1d", -# "do2d", -# "dond", -# "AbstractSweep", -# "ArraySweep", -# "LinSweep", -# "LogSweep", -# "plot", -# ] +import warnings + +from qcodes.dataset.doNd import ( + AbstractSweep, + ArraySweep, + LinSweep, + LogSweep, + do0d, + do1d, + do2d, + dond, +) +from qcodes.dataset.plotting import plot_and_save_image as plot + +warnings.warn( + "qcodes.utils.dataset.doNd module is deprecated. " + "Please update to import from qcodes.dataset" +) + +__all__ = [ + "do0d", + "do1d", + "do2d", + "dond", + "AbstractSweep", + "ArraySweep", + "LinSweep", + "LogSweep", + "plot", +] diff --git a/qcodes/utils/installation.py b/qcodes/utils/installation.py new file mode 100644 index 00000000000..b7b8e64a169 --- /dev/null +++ b/qcodes/utils/installation.py @@ -0,0 +1,10 @@ +import warnings + +from qcodes.extensions.installation import register_station_schema_with_vscode + +warnings.warn( + "qcodes.utils.installation module is deprecated. " + "Please update to import from qcodes.extensions" +) + +__all__ = ["register_station_schema_with_vscode"] diff --git a/qcodes/utils/slack.py b/qcodes/utils/slack.py new file mode 100644 index 00000000000..cbc4780f181 --- /dev/null +++ b/qcodes/utils/slack.py @@ -0,0 +1,10 @@ +import warnings + +from qcodes.extensions.slack import Slack, SlackTimeoutWarning, convert_command + +warnings.warn( + "qcodes.utils.slack module is deprecated. " + "Please update to import from qcodes.extensions" +) + +__all__ = ["Slack", "SlackTimeoutWarning", "convert_command"] From 9bc70fb701cbc2e17f8c8d69ad57b76f9c6566c8 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 8 Jun 2022 17:49:52 +0200 Subject: [PATCH 23/31] remove old dataset api docs --- docs/api/dataset/data_set.rst | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 docs/api/dataset/data_set.rst diff --git a/docs/api/dataset/data_set.rst b/docs/api/dataset/data_set.rst deleted file mode 100644 index abba9f2cdb9..00000000000 --- a/docs/api/dataset/data_set.rst +++ /dev/null @@ -1,8 +0,0 @@ -qcodes.dataset.data_set ------------------------ - -.. automodule:: qcodes.dataset.data_set - :members: - -.. automodule:: qcodes.dataset.data_set_cache - :members: From 8edccdf345fb9cc2b12136cf39a68ec38805ef32 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Thu, 9 Jun 2022 09:39:20 +0200 Subject: [PATCH 24/31] sort dataset __all__ --- qcodes/dataset/__init__.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/qcodes/dataset/__init__.py b/qcodes/dataset/__init__.py index 01dd78c6d62..26e6fcb2b5e 100644 --- a/qcodes/dataset/__init__.py +++ b/qcodes/dataset/__init__.py @@ -31,34 +31,34 @@ from .sqlite.settings import SQLiteSettings __all__ = [ - "load_by_counter", - "load_by_guid", - "load_by_id", - "load_by_run_spec", - "new_data_set", - "load_from_netcdf", + "AbstractSweep", + "ArraySweep", "DataSetProtocol", "DataSetType", + "LinSweep", + "LogSweep", + "Measurement", "ParamSpec", + "SQLiteSettings", "do0d", "do1d", "do2d", "dond", - "AbstractSweep", - "ArraySweep", - "LinSweep", - "LogSweep", "experiments", + "initialise_database", + "initialise_or_create_database_at", + "initialised_database_at", + "load_by_counter", + "load_by_guid", + "load_by_id", + "load_by_run_spec", "load_experiment", "load_experiment_by_name", + "load_from_netcdf", "load_last_experiment", "load_or_create_experiment", + "new_data_set", "new_experiment", - "Measurement", "plot_by_id", "plot_dataset", - "initialise_database", - "initialise_or_create_database_at", - "initialised_database_at", - "SQLiteSettings", ] From bf6b3186cc37dcc0279a7f90b6cec84e95696b13 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Thu, 9 Jun 2022 09:40:00 +0200 Subject: [PATCH 25/31] sort extensions all --- qcodes/extensions/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/extensions/__init__.py b/qcodes/extensions/__init__.py index 5d812f60f65..4b6ec0f9b19 100644 --- a/qcodes/extensions/__init__.py +++ b/qcodes/extensions/__init__.py @@ -5,4 +5,4 @@ from .installation import register_station_schema_with_vscode from .slack import Slack, SlackTimeoutWarning -__all__ = ["register_station_schema_with_vscode", "Slack", "SlackTimeoutWarning"] +__all__ = ["Slack", "SlackTimeoutWarning", "register_station_schema_with_vscode"] From e0ff5b9cd01491d2b603527610df0cf9362c9303 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Thu, 9 Jun 2022 10:59:48 +0200 Subject: [PATCH 26/31] add missing methods to dataset public api --- qcodes/dataset/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qcodes/dataset/__init__.py b/qcodes/dataset/__init__.py index 26e6fcb2b5e..eaeca91cab1 100644 --- a/qcodes/dataset/__init__.py +++ b/qcodes/dataset/__init__.py @@ -11,6 +11,7 @@ ) from .data_set_in_memory import load_from_netcdf from .data_set_protocol import DataSetProtocol, DataSetType +from .database_extract_runs import extract_runs_into_db from .descriptions.param_spec import ParamSpec from .doNd import AbstractSweep, ArraySweep, LinSweep, LogSweep, do0d, do1d, do2d, dond from .experiment_container import ( @@ -21,6 +22,8 @@ load_or_create_experiment, new_experiment, ) +from .experiment_settings import get_default_experiment_id, reset_default_experiment_id +from .legacy_import import import_dat_file from .measurements import Measurement from .plotting import plot_by_id, plot_dataset from .sqlite.database import ( @@ -45,6 +48,9 @@ "do2d", "dond", "experiments", + "extract_runs_into_db", + "get_default_experiment_id", + "import_dat_file", "initialise_database", "initialise_or_create_database_at", "initialised_database_at", @@ -61,4 +67,5 @@ "new_experiment", "plot_by_id", "plot_dataset", + "reset_default_experiment_id", ] From 6e23eba8b8a3047c16b17fd7166a3344485b8d68 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Thu, 9 Jun 2022 11:13:20 +0200 Subject: [PATCH 27/31] disable warnings until new api is in release --- qcodes/utils/dataset/doNd.py | 9 +++++---- qcodes/utils/installation.py | 9 +++++---- qcodes/utils/slack.py | 9 +++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/qcodes/utils/dataset/doNd.py b/qcodes/utils/dataset/doNd.py index adb017f3ea5..4569f16ebe8 100644 --- a/qcodes/utils/dataset/doNd.py +++ b/qcodes/utils/dataset/doNd.py @@ -12,10 +12,11 @@ ) from qcodes.dataset.plotting import plot_and_save_image as plot -warnings.warn( - "qcodes.utils.dataset.doNd module is deprecated. " - "Please update to import from qcodes.dataset" -) +# todo enable warning once new api is in release +# warnings.warn( +# "qcodes.utils.dataset.doNd module is deprecated. " +# "Please update to import from qcodes.dataset" +# ) __all__ = [ "do0d", diff --git a/qcodes/utils/installation.py b/qcodes/utils/installation.py index b7b8e64a169..5d35b7765d1 100644 --- a/qcodes/utils/installation.py +++ b/qcodes/utils/installation.py @@ -2,9 +2,10 @@ from qcodes.extensions.installation import register_station_schema_with_vscode -warnings.warn( - "qcodes.utils.installation module is deprecated. " - "Please update to import from qcodes.extensions" -) +# todo enable warning once new api is in release +# warnings.warn( +# "qcodes.utils.installation module is deprecated. " +# "Please update to import from qcodes.extensions" +# ) __all__ = ["register_station_schema_with_vscode"] diff --git a/qcodes/utils/slack.py b/qcodes/utils/slack.py index cbc4780f181..1c3b371cbeb 100644 --- a/qcodes/utils/slack.py +++ b/qcodes/utils/slack.py @@ -2,9 +2,10 @@ from qcodes.extensions.slack import Slack, SlackTimeoutWarning, convert_command -warnings.warn( - "qcodes.utils.slack module is deprecated. " - "Please update to import from qcodes.extensions" -) +# todo enable warning once new api is in release +# warnings.warn( +# "qcodes.utils.slack module is deprecated. " +# "Please update to import from qcodes.extensions" +# ) __all__ = ["Slack", "SlackTimeoutWarning", "convert_command"] From 65c8d6630b890b3c36ee9fb64444bde2f9306676 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Fri, 10 Jun 2022 13:08:44 +0200 Subject: [PATCH 28/31] Update qcodes/extensions/__init__.py Co-authored-by: Mikhail Astafev --- qcodes/extensions/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/extensions/__init__.py b/qcodes/extensions/__init__.py index 4b6ec0f9b19..4cc004be837 100644 --- a/qcodes/extensions/__init__.py +++ b/qcodes/extensions/__init__.py @@ -1,6 +1,6 @@ """ The extensions module contains smaller modules that extend the functionality of QCoDeS. -These modules may import from all of QCoDeS but do not them self get imported into QCoDeS. +These modules may import from all of QCoDeS but do not themselves get imported into QCoDeS. """ from .installation import register_station_schema_with_vscode from .slack import Slack, SlackTimeoutWarning From 61bd0062c832d0cc2d48a66e6e98787e7eb372d0 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Mon, 13 Jun 2022 09:34:15 +0200 Subject: [PATCH 29/31] Add complete api (including private functions) to utils for backwards compat --- qcodes/utils/dataset/doNd.py | 52 +++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/qcodes/utils/dataset/doNd.py b/qcodes/utils/dataset/doNd.py index 4569f16ebe8..34488725c84 100644 --- a/qcodes/utils/dataset/doNd.py +++ b/qcodes/utils/dataset/doNd.py @@ -2,9 +2,31 @@ from qcodes.dataset.doNd import ( AbstractSweep, + ActionsT, ArraySweep, + AxesTuple, + AxesTupleList, + AxesTupleListWithDataSet, + BreakConditionInterrupt, + BreakConditionT, LinSweep, LogSweep, + MeasInterruptT, + MultiAxesTupleListWithDataSet, + ParameterGroup, + ParamMeasT, + UnsafeThreadingException, + _catch_interrupts, + _conditional_parameter_set, + _create_measurements, + _extract_paramters_by_type_and_group, + _handle_plotting, + _make_nested_setpoints, + _parse_dond_arguments, + _register_actions, + _register_parameters, + _select_active_actions_delays, + _set_write_period, do0d, do1d, do2d, @@ -19,13 +41,35 @@ # ) __all__ = [ - "do0d", - "do1d", - "do2d", - "dond", "AbstractSweep", + "ActionsT", "ArraySweep", + "AxesTuple", + "AxesTupleList", + "AxesTupleListWithDataSet", + "BreakConditionInterrupt", + "BreakConditionT", "LinSweep", "LogSweep", + "MeasInterruptT", + "MultiAxesTupleListWithDataSet", + "ParamMeasT", + "ParameterGroup", + "UnsafeThreadingException", + "_catch_interrupts", + "_conditional_parameter_set", + "_create_measurements", + "_extract_paramters_by_type_and_group", + "_handle_plotting", + "_make_nested_setpoints", + "_parse_dond_arguments", + "_register_actions", + "_register_parameters", + "_select_active_actions_delays", + "_set_write_period", + "do0d", + "do1d", + "do2d", + "dond", "plot", ] From db083e4627b42977391333d1bfe9c5a20f6d9c43 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Mon, 13 Jun 2022 09:51:25 +0200 Subject: [PATCH 30/31] rename dond module --- qcodes/dataset/{doNd.py => do_nd.py} | 0 qcodes/utils/dataset/doNd.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename qcodes/dataset/{doNd.py => do_nd.py} (100%) diff --git a/qcodes/dataset/doNd.py b/qcodes/dataset/do_nd.py similarity index 100% rename from qcodes/dataset/doNd.py rename to qcodes/dataset/do_nd.py diff --git a/qcodes/utils/dataset/doNd.py b/qcodes/utils/dataset/doNd.py index 34488725c84..1aa0c40031e 100644 --- a/qcodes/utils/dataset/doNd.py +++ b/qcodes/utils/dataset/doNd.py @@ -1,6 +1,6 @@ import warnings -from qcodes.dataset.doNd import ( +from qcodes.dataset.do_nd import ( AbstractSweep, ActionsT, ArraySweep, From 33c81432ff4656de5c28714b2f134989e9fe443d Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Mon, 13 Jun 2022 10:17:11 +0200 Subject: [PATCH 31/31] update import --- qcodes/dataset/__init__.py | 2 +- qcodes/tests/dataset/test_database_extract_runs.py | 2 +- qcodes/tests/dataset/test_doNd.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qcodes/dataset/__init__.py b/qcodes/dataset/__init__.py index eaeca91cab1..97289cde5ac 100644 --- a/qcodes/dataset/__init__.py +++ b/qcodes/dataset/__init__.py @@ -13,7 +13,7 @@ from .data_set_protocol import DataSetProtocol, DataSetType from .database_extract_runs import extract_runs_into_db from .descriptions.param_spec import ParamSpec -from .doNd import AbstractSweep, ArraySweep, LinSweep, LogSweep, do0d, do1d, do2d, dond +from .do_nd import AbstractSweep, ArraySweep, LinSweep, LogSweep, do0d, do1d, do2d, dond from .experiment_container import ( experiments, load_experiment, diff --git a/qcodes/tests/dataset/test_database_extract_runs.py b/qcodes/tests/dataset/test_database_extract_runs.py index 02663bf31f8..cad6b3d9f0b 100644 --- a/qcodes/tests/dataset/test_database_extract_runs.py +++ b/qcodes/tests/dataset/test_database_extract_runs.py @@ -22,7 +22,7 @@ load_by_run_spec, ) from qcodes.dataset.database_extract_runs import extract_runs_into_db -from qcodes.dataset.doNd import do1d, do2d +from qcodes.dataset.do_nd import do1d, do2d from qcodes.dataset.experiment_container import ( Experiment, load_experiment_by_name, diff --git a/qcodes/tests/dataset/test_doNd.py b/qcodes/tests/dataset/test_doNd.py index 53b1280d74d..84851741197 100644 --- a/qcodes/tests/dataset/test_doNd.py +++ b/qcodes/tests/dataset/test_doNd.py @@ -11,7 +11,7 @@ from qcodes import config from qcodes.dataset import new_experiment from qcodes.dataset.data_set import DataSet -from qcodes.dataset.doNd import ArraySweep, LinSweep, LogSweep, do0d, do1d, do2d, dond +from qcodes.dataset.do_nd import ArraySweep, LinSweep, LogSweep, do0d, do1d, do2d, dond from qcodes.instrument.parameter import Parameter, _BaseParameter from qcodes.tests.instrument_mocks import ( ArraySetPointParam,