diff --git a/docs/changes/newsfragments/6480.breaking b/docs/changes/newsfragments/6480.breaking new file mode 100644 index 00000000000..ab402503f91 --- /dev/null +++ b/docs/changes/newsfragments/6480.breaking @@ -0,0 +1,2 @@ +The deprecated `qcodes.tests` module has been removed. Mock instruments can be found in `qcodes.instrument_drivers.mock_instruments` and +DriverTestCase as `qcodes.extensions.DriverTestCase`. diff --git a/pyproject.toml b/pyproject.toml index 4ecc6f6dd15..1b159648916 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -129,7 +129,6 @@ log_exported_ds = "qcodes.extensions:log_dataset_export_info" omit = [ "src/qcodes/__init__.py", "*/__init__.py", - "src/qcodes/tests/*", ] [tool.coverage.report] exclude_lines = [ @@ -171,7 +170,6 @@ strict_equality = true [[tool.mypy.overrides]] module = [ "tests.*", - "qcodes.tests.*", "qcodes.instrument.mockers.ami430", "qcodes.instrument_drivers.Harvard.*", "qcodes.instrument_drivers.Keysight.keysightb1500.message_builder.*", @@ -295,9 +293,7 @@ known-first-party = ["qcodes"] # TID253 these imports are fine at module level # in tests and examples -# D417 no need to fix in deprecated module "docs/*" = ["TID253"] -"src/qcodes/tests/*" = ["TID253", "D417"] "tests/*" = ["TID253"] [tool.ruff.lint.flake8-tidy-imports] diff --git a/src/qcodes/tests/__init__.py b/src/qcodes/tests/__init__.py deleted file mode 100644 index dda3aa164b2..00000000000 --- a/src/qcodes/tests/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from qcodes.utils import issue_deprecation_warning - -issue_deprecation_warning( - "`qcodes.tests` module", - "tests are no longer shipped with QCoDeS", - "`qcodes.instrument_drivers.mock_instruments` and `qcodes.extensions.DriverTestCase`", -) diff --git a/src/qcodes/tests/common.py b/src/qcodes/tests/common.py deleted file mode 100644 index 1e1d7a2a7fa..00000000000 --- a/src/qcodes/tests/common.py +++ /dev/null @@ -1,244 +0,0 @@ -from __future__ import annotations - -import cProfile -import os -from functools import wraps -from time import sleep -from typing import TYPE_CHECKING, Any, TypeVar - -import pytest -from typing_extensions import ParamSpec - -from qcodes.metadatable import MetadatableWithName - -if TYPE_CHECKING: - from collections.abc import Callable, Mapping, Sequence - from pathlib import Path - - from pytest import ExceptionInfo - - -def strip_qc( - d: dict[str, Any], keys: Sequence[str] = ("instrument", "__class__") -) -> dict[str, Any]: - # depending on how you run the tests, __module__ can either - # have qcodes on the front or not. Just strip it off. - for key in keys: - if key in d: - d[key] = d[key].replace("qcodes.tests.", "tests.") - return d - - -T = TypeVar("T") -P = ParamSpec("P") - - -def retry_until_does_not_throw( - exception_class_to_expect: type[Exception] = AssertionError, - tries: int = 5, - delay: float = 0.1, -) -> Callable[[Callable[P, T]], Callable[P, T]]: - """ - Call the decorated function given number of times with given delay between - the calls until it does not throw an exception of a given class. - - If the function throws an exception of a different class, it gets propagated - outside (i.e. the function is not called anymore). - - Usage: - >> x = False # let's assume that another thread has access to "x", - # and it is going to change "x" to "True" very soon - >> @retry_until_does_not_throw() ... - def assert_x_is_true(): ... - assert x, "x is still False..." ... - >> assert_x_is_true() # depending on the settings of - # "retry_until_does_not_throw", it will keep - # calling the function (with breaks in between) - # until either it does not throw or - # the number of tries is exceeded. - - Args: - exception_class_to_expect - Only in case of this exception the function will be called again - tries - Number of times to retry calling the function before giving up - delay - Delay between retries of the function call, in seconds - - Returns: - A callable that runs the decorated function until it does not throw - a given exception - - """ - - def retry_until_passes_decorator(func: Callable[P, T]) -> Callable[P, T]: - @wraps(func) - def func_retry(*args: P.args, **kwargs: P.kwargs) -> T: - tries_left = tries - 1 - while tries_left > 0: - try: - return func(*args, **kwargs) - except exception_class_to_expect: - tries_left -= 1 - sleep(delay) - # the very last attempt to call the function is outside - # the "try-except" clause, so that the exception can propagate - # up the call stack - return func(*args, **kwargs) - - return func_retry - - return retry_until_passes_decorator - - -def profile(func: Callable[P, T]) -> Callable[P, T]: - """ - Decorator that profiles the wrapped function with cProfile. - - It produces a '.prof' file in the current working directory - that has the name of the executed function. - - Use the 'Stats' class from the 'pstats' module to read the file, - analyze the profile data (for example, 'p.sort_stats('tottime')' - where 'p' is an instance of the 'Stats' class), and print the data - (for example, 'p.print_stats()'). - """ - - def wrapper(*args: P.args, **kwargs: P.kwargs) -> T: - profile_filename = func.__name__ + ".prof" - profiler = cProfile.Profile() - result = profiler.runcall(func, *args, **kwargs) - profiler.dump_stats(profile_filename) - return result - - return wrapper - - -def error_caused_by(excinfo: ExceptionInfo[Any], cause: str) -> bool: - """ - Helper function to figure out whether an exception was caused by another - exception with the message provided. - - Args: - excinfo: the output of with pytest.raises() as excinfo - cause: the error message or a substring of it - - """ - - exc_repr = excinfo.getrepr() - - chain = getattr(exc_repr, "chain", None) - - if chain is not None: - # first element of the chain is info about the root exception - error_location = chain[0][1] - root_traceback = chain[0][0] - # the error location is the most reliable data since - # it only contains the location and the error raised. - # however there are cases where this is empty - # in such cases fall back to the traceback - if error_location is not None: - return cause in str(error_location) - else: - return cause in str(root_traceback) - else: - return False - - -def skip_if_no_fixtures(dbname: str | Path) -> None: - if not os.path.exists(dbname): - pytest.skip( - "No db-file fixtures found. " - "Make sure that your git clone of qcodes has submodules " - "This can be done by executing: `git submodule update --init`" - ) - - -class DummyComponent(MetadatableWithName): - """Docstring for DummyComponent.""" - - def __init__(self, name: str): - super().__init__() - self.name = name - - def __str__(self) -> str: - return self.full_name - - def set(self, value: float) -> float: - value = value * 2 - return value - - @property - def short_name(self) -> str: - return self.name - - @property - def full_name(self) -> str: - return self.full_name - - -def compare_dictionaries( - dict_1: Mapping[Any, Any], - dict_2: Mapping[Any, Any], - dict_1_name: str | None = "d1", - dict_2_name: str | None = "d2", - path: str = "", -) -> tuple[bool, str]: - """ - Compare two dictionaries recursively to find non matching elements. - - Args: - dict_1: First dictionary to compare. - dict_2: Second dictionary to compare. - dict_1_name: Optional name of the first dictionary used in the - differences string. - dict_2_name: Optional name of the second dictionary used in the - differences string. - - Returns: - Tuple: Are the dicts equal and the difference rendered as - a string. - - """ - err = "" - key_err = "" - value_err = "" - old_path = path - for k in dict_1.keys(): - path = old_path + f"[{k}]" - if k not in dict_2.keys(): - key_err += f"Key {dict_1_name}{path} not in {dict_2_name}\n" - elif isinstance(dict_1[k], dict) and isinstance(dict_2[k], dict): - err += compare_dictionaries( - dict_1[k], dict_2[k], dict_1_name, dict_2_name, path - )[1] - else: - match = dict_1[k] == dict_2[k] - - # if values are equal-length numpy arrays, the result of - # "==" is a bool array, so we need to 'all' it. - # In any other case "==" returns a bool - # TODO(alexcjohnson): actually, if *one* is a numpy array - # and the other is another sequence with the same entries, - # this will compare them as equal. Do we want this, or should - # we require exact type match? - if hasattr(match, "all"): - match = match.all() - - if not match: - value_err += ( - f'Value of "{dict_1_name}{path}" ("{dict_1[k]}", type"{type(dict_1[k])}") not same as\n' - f' "{dict_2_name}{path}" ("{dict_2[k]}", type"{type(dict_2[k])}")\n\n' - ) - - for k in dict_2.keys(): - path = old_path + f"[{k}]" - if k not in dict_1.keys(): - key_err += f"Key {dict_2_name}{path} not in {dict_1_name}\n" - - dict_differences = key_err + value_err + err - if len(dict_differences) == 0: - dicts_equal = True - else: - dicts_equal = False - return dicts_equal, dict_differences diff --git a/src/qcodes/tests/conftest.py b/src/qcodes/tests/conftest.py deleted file mode 100644 index c3454d3db56..00000000000 --- a/src/qcodes/tests/conftest.py +++ /dev/null @@ -1,190 +0,0 @@ -from __future__ import annotations - -import copy -import gc -import os -import sys -from typing import TYPE_CHECKING - -import pytest -from hypothesis import settings - -import qcodes as qc -from qcodes.configuration import Config -from qcodes.dataset import initialise_database, new_data_set -from qcodes.dataset.descriptions.dependencies import InterDependencies_ -from qcodes.dataset.descriptions.param_spec import ParamSpecBase -from qcodes.dataset.experiment_container import Experiment, new_experiment -from qcodes.instrument import Instrument -from qcodes.station import Station - -settings.register_profile("ci", deadline=1000) - -n_experiments = 0 - -if TYPE_CHECKING: - from collections.abc import Generator - from pathlib import Path - - from qcodes.configuration import DotDict - from qcodes.dataset.data_set import DataSet - - -def pytest_configure(config: pytest.Config) -> None: - config.addinivalue_line("markers", "win32: tests that only run under windows") - - -def pytest_runtest_setup(item: pytest.Item) -> None: - ALL = set("darwin linux win32".split()) - supported_platforms = ALL.intersection(mark.name for mark in item.iter_markers()) - if supported_platforms and sys.platform not in supported_platforms: - pytest.skip(f"cannot run on platform {sys.platform}") - - -@pytest.fixture(scope="session", autouse=True) -def default_session_config( - tmp_path_factory: pytest.TempPathFactory, -) -> Generator[None, None, None]: - """ - Set the config for the test session to be the default config. - Making sure that that user config does not influence the tests and - that tests cannot write to the user config. - """ - home_file_name = Config.home_file_name - schema_home_file_name = Config.schema_home_file_name - env_file_name = Config.env_file_name - schema_env_file_name = Config.schema_env_file_name - cwd_file_name = Config.cwd_file_name - schema_cwd_file_name = Config.schema_cwd_file_name - - old_config: DotDict | None = copy.deepcopy(qc.config.current_config) - qc.config.current_config = copy.deepcopy(qc.config.defaults) - - tmp_path = tmp_path_factory.mktemp("qcodes_tests") - - file_name = str(tmp_path / "user_config.json") - file_name_schema = str(tmp_path / "user_config_schema.json") - - qc.config.home_file_name = file_name - qc.config.schema_home_file_name = file_name_schema - qc.config.env_file_name = "" - qc.config.schema_env_file_name = "" - qc.config.cwd_file_name = "" - qc.config.schema_cwd_file_name = "" - - # set any config that we want to be different from the default - # for the test session here - # also set the default db path here - qc.config.logger.start_logging_on_import = "never" - qc.config.telemetry.enabled = False - qc.config.subscription.default_subscribers = [] - qc.config.core.db_location = str(tmp_path / "temp.db") - - try: - yield - finally: - qc.config.home_file_name = home_file_name - qc.config.schema_home_file_name = schema_home_file_name - qc.config.env_file_name = env_file_name - qc.config.schema_env_file_name = schema_env_file_name - qc.config.cwd_file_name = cwd_file_name - qc.config.schema_cwd_file_name = schema_cwd_file_name - - qc.config.current_config = old_config - - -@pytest.fixture(scope="function", autouse=True) -def reset_state_on_exit() -> Generator[None, None, None]: - """ - Fixture to clean any shared state on exit - - Currently this resets the config to the default config, - closes the default station and closes all instruments. - """ - default_config_obj: DotDict | None = copy.deepcopy(qc.config.current_config) - - try: - yield - finally: - qc.config.current_config = default_config_obj - Instrument.close_all() - Station.default = None - - -@pytest.fixture(scope="function", name="empty_temp_db") -def _make_empty_temp_db(tmp_path: Path) -> Generator[None, None, None]: - global n_experiments - n_experiments = 0 - # create a temp database for testing - try: - qc.config["core"]["db_location"] = str(tmp_path / "temp.db") - if os.environ.get("QCODES_SQL_DEBUG"): - qc.config["core"]["db_debug"] = True - else: - qc.config["core"]["db_debug"] = False - initialise_database() - yield - finally: - # there is a very real chance that the tests will leave open - # connections to the database. These will have gone out of scope at - # this stage but a gc collection may not have run. The gc - # collection ensures that all connections belonging to now out of - # scope objects will be closed - gc.collect() - - -# note that you cannot use mark.usefixtures in a fixture -# so empty_temp_db needs to be passed to this fixture -# even if unused https://github.com/pytest-dev/pytest/issues/3664 -@pytest.fixture(scope="function", name="experiment") -def _make_experiment(empty_temp_db: None) -> Generator[Experiment, None, None]: - e = new_experiment("test-experiment", sample_name="test-sample") - try: - yield e - finally: - e.conn.close() - - -@pytest.fixture(scope="function", name="dataset") -def _make_dataset(experiment: Experiment) -> Generator[DataSet, None, None]: - dataset = new_data_set("test-dataset") - try: - yield dataset - finally: - dataset.unsubscribe_all() - dataset.conn.close() - - -@pytest.fixture(name="standalone_parameters_dataset") -def _make_standalone_parameters_dataset( - dataset: DataSet, -) -> Generator[DataSet, None, None]: - n_params = 3 - n_rows = 10**3 - params_indep = [ - ParamSpecBase(f"param_{i}", "numeric", label=f"param_{i}", unit="V") - for i in range(n_params) - ] - - param_dep = ParamSpecBase( - f"param_{n_params}", "numeric", label=f"param_{n_params}", unit="Ohm" - ) - - params_all = params_indep + [param_dep] - - idps = InterDependencies_( - dependencies={param_dep: tuple(params_indep[0:1])}, - standalones=tuple(params_indep[1:]), - ) - - dataset.set_interdependencies(idps) - - dataset.mark_started() - dataset.add_results( - [ - {p.name: int(n_rows * 10 * pn + i) for pn, p in enumerate(params_all)} - for i in range(n_rows) - ] - ) - dataset.mark_completed() - yield dataset diff --git a/src/qcodes/tests/dataset/__init__.py b/src/qcodes/tests/dataset/__init__.py deleted file mode 100644 index e84b76a8706..00000000000 --- a/src/qcodes/tests/dataset/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -import pytest - -pytest.register_assert_rewrite("qcodes.tests.dataset.helper_functions") diff --git a/src/qcodes/tests/dataset/conftest.py b/src/qcodes/tests/dataset/conftest.py deleted file mode 100644 index 73af940316f..00000000000 --- a/src/qcodes/tests/dataset/conftest.py +++ /dev/null @@ -1,737 +0,0 @@ -from __future__ import annotations - -import gc -import os -import shutil -import tempfile -from contextlib import contextmanager -from typing import TYPE_CHECKING - -import numpy as np -import pytest -from pytest import FixtureRequest - -import qcodes as qc -from qcodes.dataset.data_set import DataSet -from qcodes.dataset.descriptions.dependencies import InterDependencies_ -from qcodes.dataset.descriptions.param_spec import ParamSpec, ParamSpecBase -from qcodes.dataset.measurements import Measurement -from qcodes.dataset.sqlite.database import connect -from qcodes.instrument_drivers.mock_instruments import ( - ArraySetPointParam, - DummyChannelInstrument, - DummyInstrument, - Multi2DSetPointParam, - Multi2DSetPointParam2Sizes, - setpoint_generator, -) -from qcodes.parameters import ArrayParameter, Parameter, ParameterWithSetpoints -from qcodes.validators import Arrays, ComplexNumbers, Numbers - -if TYPE_CHECKING: - from collections.abc import Generator, Iterator - - -@pytest.fixture(scope="function", name="non_created_db") -def _make_non_created_db(tmp_path) -> Generator[None, None, None]: - # set db location to a non existing file - try: - qc.config["core"]["db_location"] = str(tmp_path / "temp.db") - if os.environ.get("QCODES_SQL_DEBUG"): - qc.config["core"]["db_debug"] = True - else: - qc.config["core"]["db_debug"] = False - yield - finally: - # there is a very real chance that the tests will leave open - # connections to the database. These will have gone out of scope at - # this stage but a gc collection may not have run. The gc - # collection ensures that all connections belonging to now out of - # scope objects will be closed - gc.collect() - - -@pytest.fixture(scope="function") -def empty_temp_db_connection(tmp_path): - """ - Yield connection to an empty temporary DB file. - """ - path = str(tmp_path / "source.db") - conn = connect(path) - try: - yield conn - finally: - conn.close() - # there is a very real chance that the tests will leave open - # connections to the database. These will have gone out of scope at - # this stage but a gc collection may not have run. The gc - # collection ensures that all connections belonging to now out of - # scope objects will be closed - gc.collect() - - -@pytest.fixture(scope="function") -def two_empty_temp_db_connections(tmp_path): - """ - Yield connections to two empty files. Meant for use with the - test_database_extract_runs - """ - - source_path = str(tmp_path / "source.db") - target_path = str(tmp_path / "target.db") - source_conn = connect(source_path) - target_conn = connect(target_path) - try: - yield (source_conn, target_conn) - finally: - source_conn.close() - target_conn.close() - # there is a very real chance that the tests will leave open - # connections to the database. These will have gone out of scope at - # this stage but a gc collection may not have run. The gc - # collection ensures that all connections belonging to now out of - # scope objects will be closed - gc.collect() - - -@contextmanager -def temporarily_copied_DB(filepath: str, **kwargs): - """ - Make a temporary copy of a db-file and delete it after use. Meant to be - used together with the old version database fixtures, lest we change the - fixtures on disk. Yields the connection object - - Args: - filepath: path to the db-file - - Kwargs: - kwargs to be passed to connect - - """ - with tempfile.TemporaryDirectory() as tmpdir: - dbname_new = os.path.join(tmpdir, "temp.db") - shutil.copy2(filepath, dbname_new) - - conn = connect(dbname_new, **kwargs) - - try: - yield conn - - finally: - conn.close() - - -@pytest.fixture(name="scalar_dataset") -def _make_scalar_dataset(dataset): - n_params = 3 - n_rows = 10**3 - params_indep = [ - ParamSpecBase(f"param_{i}", "numeric", label=f"param_{i}", unit="V") - for i in range(n_params) - ] - param_dep = ParamSpecBase( - f"param_{n_params}", "numeric", label=f"param_{n_params}", unit="Ohm" - ) - - all_params = params_indep + [param_dep] - - idps = InterDependencies_(dependencies={param_dep: tuple(params_indep)}) - - dataset.set_interdependencies(idps) - dataset.mark_started() - dataset.add_results( - [ - {p.name: int(n_rows * 10 * pn + i) for pn, p in enumerate(all_params)} - for i in range(n_rows) - ] - ) - dataset.mark_completed() - yield dataset - - -@pytest.fixture( - name="scalar_datasets_parameterized", params=((3, 10**3), (5, 10**3), (10, 50)) -) -def _make_scalar_datasets_parameterized(dataset, request: FixtureRequest): - n_params = request.param[0] - n_rows = request.param[1] - params_indep = [ - ParamSpecBase(f"param_{i}", "numeric", label=f"param_{i}", unit="V") - for i in range(n_params) - ] - param_dep = ParamSpecBase( - f"param_{n_params}", "numeric", label=f"param_{n_params}", unit="Ohm" - ) - - all_params = params_indep + [param_dep] - - idps = InterDependencies_(dependencies={param_dep: tuple(params_indep)}) - - dataset.set_interdependencies(idps) - dataset.mark_started() - dataset.add_results( - [ - {p.name: int(n_rows * 10 * pn + i) for pn, p in enumerate(all_params)} - for i in range(n_rows) - ] - ) - dataset.mark_completed() - yield dataset - - -@pytest.fixture -def scalar_dataset_with_nulls(dataset): - """ - A very simple dataset. A scalar is varied, and two parameters are measured - one by one - """ - sp = ParamSpecBase("setpoint", "numeric") - val1 = ParamSpecBase("first_value", "numeric") - val2 = ParamSpecBase("second_value", "numeric") - - idps = InterDependencies_(dependencies={val1: (sp,), val2: (sp,)}) - dataset.set_interdependencies(idps) - - dataset.mark_started() - - dataset.add_results([{sp.name: 0, val1.name: 1}, {sp.name: 0, val2.name: 2}]) - dataset.mark_completed() - yield dataset - - -@pytest.fixture(scope="function", params=["array", "numeric"]) -def array_dataset(experiment, request: FixtureRequest): - meas = Measurement() - param = ArraySetPointParam() - meas.register_parameter(param, paramtype=request.param) - - with meas.run() as datasaver: - datasaver.add_result( - ( - param, - param.get(), - ) - ) - try: - yield datasaver.dataset - finally: - assert isinstance(datasaver.dataset, DataSet) - datasaver.dataset.conn.close() - - -@pytest.fixture(scope="function", params=["array", "numeric"]) -def array_dataset_with_nulls(experiment, request: FixtureRequest): - """ - A dataset where two arrays are measured, one as a function - of two other (setpoint) arrays, the other as a function of just one - of them - """ - meas = Measurement() - meas.register_custom_parameter("sp1", paramtype=request.param) - meas.register_custom_parameter("sp2", paramtype=request.param) - meas.register_custom_parameter( - "val1", paramtype=request.param, setpoints=("sp1", "sp2") - ) - meas.register_custom_parameter("val2", paramtype=request.param, setpoints=("sp1",)) - - with meas.run() as datasaver: - sp1_vals = np.arange(0, 5) - sp2_vals = np.arange(5, 10) - val1_vals = np.ones(5) - val2_vals = np.zeros(5) - datasaver.add_result(("sp1", sp1_vals), ("sp2", sp2_vals), ("val1", val1_vals)) - datasaver.add_result(("sp1", sp1_vals), ("val2", val2_vals)) - try: - yield datasaver.dataset - finally: - assert isinstance(datasaver.dataset, DataSet) - datasaver.dataset.conn.close() - - -@pytest.fixture(scope="function", params=["array", "numeric"]) -def multi_dataset(experiment, request: FixtureRequest): - meas = Measurement() - param = Multi2DSetPointParam() - - meas.register_parameter(param, paramtype=request.param) - - with meas.run() as datasaver: - datasaver.add_result( - ( - param, - param.get(), - ) - ) - try: - yield datasaver.dataset - finally: - assert isinstance(datasaver.dataset, DataSet) - datasaver.dataset.conn.close() - - -@pytest.fixture(scope="function", params=["array"]) -def different_setpoint_dataset(experiment, request: FixtureRequest): - meas = Measurement() - param = Multi2DSetPointParam2Sizes() - - meas.register_parameter(param, paramtype=request.param) - - with meas.run() as datasaver: - datasaver.add_result( - ( - param, - param.get(), - ) - ) - try: - yield datasaver.dataset - finally: - assert isinstance(datasaver.dataset, DataSet) - datasaver.dataset.conn.close() - - -@pytest.fixture(scope="function") -def array_in_scalar_dataset(experiment): - meas = Measurement() - scalar_param = Parameter("scalarparam", set_cmd=None) - param = ArraySetPointParam() - meas.register_parameter(scalar_param) - meas.register_parameter(param, setpoints=(scalar_param,), paramtype="array") - - with meas.run() as datasaver: - for i in range(1, 10): - scalar_param.set(i) - datasaver.add_result( - (scalar_param, scalar_param.get()), (param, param.get()) - ) - try: - yield datasaver.dataset - finally: - assert isinstance(datasaver.dataset, DataSet) - datasaver.dataset.conn.close() - - -@pytest.fixture(scope="function") -def varlen_array_in_scalar_dataset(experiment): - meas = Measurement() - scalar_param = Parameter("scalarparam", set_cmd=None) - param = ArraySetPointParam() - meas.register_parameter(scalar_param) - meas.register_parameter(param, setpoints=(scalar_param,), paramtype="array") - np.random.seed(0) - with meas.run() as datasaver: - for i in range(1, 10): - scalar_param.set(i) - param.setpoints = (np.arange(i),) - datasaver.add_result( - (scalar_param, scalar_param.get()), (param, np.random.rand(i)) - ) - try: - yield datasaver.dataset - finally: - assert isinstance(datasaver.dataset, DataSet) - datasaver.dataset.conn.close() - - -@pytest.fixture(scope="function") -def array_in_scalar_dataset_unrolled(experiment): - """ - This fixture yields a dataset where an array-valued parameter is registered - as a 'numeric' type and has an additional single-valued setpoint. We - expect data to be saved as individual scalars, with the scalar setpoint - repeated. - """ - meas = Measurement() - scalar_param = Parameter("scalarparam", set_cmd=None) - param = ArraySetPointParam() - meas.register_parameter(scalar_param) - meas.register_parameter(param, setpoints=(scalar_param,), paramtype="numeric") - - with meas.run() as datasaver: - for i in range(1, 10): - scalar_param.set(i) - datasaver.add_result( - (scalar_param, scalar_param.get()), (param, param.get()) - ) - try: - yield datasaver.dataset - finally: - assert isinstance(datasaver.dataset, DataSet) - datasaver.dataset.conn.close() - - -@pytest.fixture(scope="function", params=["array", "numeric"]) -def array_in_str_dataset(experiment, request: FixtureRequest): - meas = Measurement() - scalar_param = Parameter("textparam", set_cmd=None) - param = ArraySetPointParam() - meas.register_parameter(scalar_param, paramtype="text") - meas.register_parameter(param, setpoints=(scalar_param,), paramtype=request.param) - - with meas.run() as datasaver: - for i in ["A", "B", "C"]: - scalar_param.set(i) - datasaver.add_result( - (scalar_param, scalar_param.get()), (param, param.get()) - ) - try: - yield datasaver.dataset - finally: - assert isinstance(datasaver.dataset, DataSet) - datasaver.dataset.conn.close() - - -@pytest.fixture -def some_paramspecbases(): - psb1 = ParamSpecBase("psb1", paramtype="text", label="blah", unit="") - psb2 = ParamSpecBase("psb2", paramtype="array", label="", unit="V") - psb3 = ParamSpecBase("psb3", paramtype="array", label="", unit="V") - psb4 = ParamSpecBase("psb4", paramtype="numeric", label="number", unit="") - - return (psb1, psb2, psb3, psb4) - - -@pytest.fixture -def some_paramspecs(): - """ - Some different paramspecs for testing. The idea is that we just add a - new group of paramspecs as the need arises - """ - - groups = {} - - # A valid group. Corresponding to a heatmap with a text label at each point - first = {} - first["ps1"] = ParamSpec("ps1", paramtype="numeric", label="Raw Data 1", unit="V") - first["ps2"] = ParamSpec("ps2", paramtype="array", label="Raw Data 2", unit="V") - first["ps3"] = ParamSpec( - "ps3", paramtype="text", label="Axis 1", unit="", inferred_from=[first["ps1"]] - ) - first["ps4"] = ParamSpec( - "ps4", - paramtype="numeric", - label="Axis 2", - unit="V", - inferred_from=[first["ps2"]], - ) - first["ps5"] = ParamSpec( - "ps5", - paramtype="numeric", - label="Signal", - unit="Conductance", - depends_on=[first["ps3"], first["ps4"]], - ) - first["ps6"] = ParamSpec( - "ps6", - paramtype="text", - label="Goodness", - unit="", - depends_on=[first["ps3"], first["ps4"]], - ) - groups[1] = first - - # a small, valid group - second = {} - second["ps1"] = ParamSpec("ps1", paramtype="numeric", label="setpoint", unit="Hz") - second["ps2"] = ParamSpec( - "ps2", paramtype="numeric", label="signal", unit="V", depends_on=[second["ps1"]] - ) - groups[2] = second - - return groups - - -@pytest.fixture -def some_interdeps(): - """ - Some different InterDependencies_ objects for testing - """ - idps_list = [] - ps1 = ParamSpecBase("ps1", paramtype="numeric", label="Raw Data 1", unit="V") - ps2 = ParamSpecBase("ps2", paramtype="array", label="Raw Data 2", unit="V") - ps3 = ParamSpecBase("ps3", paramtype="text", label="Axis 1", unit="") - ps4 = ParamSpecBase("ps4", paramtype="numeric", label="Axis 2", unit="V") - ps5 = ParamSpecBase("ps5", paramtype="numeric", label="Signal", unit="Conductance") - ps6 = ParamSpecBase("ps6", paramtype="text", label="Goodness", unit="") - - idps = InterDependencies_( - dependencies={ps5: (ps3, ps4), ps6: (ps3, ps4)}, - inferences={ps4: (ps2,), ps3: (ps1,)}, - ) - - idps_list.append(idps) - - ps1 = ParamSpecBase("ps1", paramtype="numeric", label="setpoint", unit="Hz") - ps2 = ParamSpecBase("ps2", paramtype="numeric", label="signal", unit="V") - idps = InterDependencies_(dependencies={ps2: (ps1,)}) - - idps_list.append(idps) - - return idps_list - - -@pytest.fixture(name="DAC") # scope is "function" per default -def _make_dac(): - dac = DummyInstrument("dummy_dac", gates=["ch1", "ch2"]) - yield dac - dac.close() - - -@pytest.fixture(name="DAC3D") # scope is "function" per default -def _make_dac_3d(): - dac = DummyInstrument("dummy_dac", gates=["ch1", "ch2", "ch3"]) - yield dac - dac.close() - - -@pytest.fixture(name="DAC_with_metadata") # scope is "function" per default -def _make_dac_with_metadata(): - dac = DummyInstrument( - "dummy_dac", gates=["ch1", "ch2"], metadata={"dac": "metadata"} - ) - yield dac - dac.close() - - -@pytest.fixture(name="DMM") -def _make_dmm(): - dmm = DummyInstrument("dummy_dmm", gates=["v1", "v2"]) - yield dmm - dmm.close() - - -@pytest.fixture -def channel_array_instrument(): - channelarrayinstrument = DummyChannelInstrument("dummy_channel_inst") - yield channelarrayinstrument - channelarrayinstrument.close() - - -@pytest.fixture -def complex_num_instrument(): - class MyParam(Parameter): - def get_raw(self): - assert self.instrument is not None - return self.instrument.setpoint() + 1j * self.instrument.setpoint() - - class RealPartParam(Parameter): - def get_raw(self): - assert self.instrument is not None - return self.instrument.complex_setpoint().real - - dummyinst = DummyInstrument("dummy_channel_inst", gates=()) - - dummyinst.add_parameter( - "setpoint", - parameter_class=Parameter, - initial_value=0, - label="Some Setpoint", - unit="Some Unit", - vals=Numbers(), - get_cmd=None, - set_cmd=None, - ) - - dummyinst.add_parameter( - "complex_num", - parameter_class=MyParam, - initial_value=0 + 0j, - label="Complex Num", - unit="complex unit", - vals=ComplexNumbers(), - get_cmd=None, - set_cmd=None, - ) - - dummyinst.add_parameter( - "complex_setpoint", - initial_value=0 + 0j, - label="Complex Setpoint", - unit="complex unit", - vals=ComplexNumbers(), - get_cmd=None, - set_cmd=None, - ) - - dummyinst.add_parameter( - "real_part", - parameter_class=RealPartParam, - label="Real Part", - unit="real unit", - vals=Numbers(), - set_cmd=None, - ) - - dummyinst.add_parameter( - "some_array_setpoints", - label="Some Array Setpoints", - unit="some other unit", - vals=Arrays(shape=(5,)), - set_cmd=False, - get_cmd=lambda: np.arange(5), - ) - - dummyinst.add_parameter( - "some_array", - parameter_class=ParameterWithSetpoints, - setpoints=(dummyinst.some_array_setpoints,), - label="Some Array", - unit="some_array_unit", - vals=Arrays(shape=(5,)), - get_cmd=lambda: np.ones(5), - set_cmd=False, - ) - - dummyinst.add_parameter( - "some_complex_array_setpoints", - label="Some complex array setpoints", - unit="some_array_unit", - get_cmd=lambda: np.arange(5), - set_cmd=False, - ) - - dummyinst.add_parameter( - "some_complex_array", - label="Some Array", - unit="some_array_unit", - get_cmd=lambda: np.ones(5) + 1j * np.ones(5), - set_cmd=False, - ) - - yield dummyinst - dummyinst.close() - - -@pytest.fixture -def SpectrumAnalyzer(): - """ - Yields a DummyInstrument that holds ArrayParameters returning - different types - """ - - class BaseSpectrum(ArrayParameter): - def __init__(self, name, instrument, **kwargs): - super().__init__( - name=name, - shape=(1,), # this attribute should be removed - label="Flower Power Spectrum", - unit="V/sqrt(Hz)", - setpoint_names=("Frequency",), - setpoint_units=("Hz",), - instrument=instrument, - **kwargs, - ) - - self.npts = 100 - self.start = 0 - self.stop = 2e6 - - def get_data(self): - # This is how it should be: the setpoints are generated at the - # time we get. But that will of course not work with the old Loop - self.setpoints = (tuple(np.linspace(self.start, self.stop, self.npts)),) - # not the best SA on the market; it just returns noise... - return np.random.randn(self.npts) - - class Spectrum(BaseSpectrum): - def get_raw(self): - return super().get_data() - - class MultiDimSpectrum(ArrayParameter): - def __init__(self, name, instrument, **kwargs): - self.start = 0 - self.stop = 2e6 - self.npts = (100, 50, 20) - sp1 = np.linspace(self.start, self.stop, self.npts[0]) - sp2 = np.linspace(self.start, self.stop, self.npts[1]) - sp3 = np.linspace(self.start, self.stop, self.npts[2]) - setpoints = setpoint_generator(sp1, sp2, sp3) - - super().__init__( - name=name, - instrument=instrument, - setpoints=setpoints, - shape=(100, 50, 20), - label="Flower Power Spectrum in 3D", - unit="V/sqrt(Hz)", - setpoint_names=("Frequency0", "Frequency1", "Frequency2"), - setpoint_units=("Hz", "Other Hz", "Third Hz"), - **kwargs, - ) - - def get_raw(self): - return np.random.randn(*self.npts) - - class ListSpectrum(BaseSpectrum): - def get_raw(self): - output = super().get_data() - return list(output) - - class TupleSpectrum(BaseSpectrum): - def get_raw(self): - output = super().get_data() - return tuple(output) - - SA = DummyInstrument("dummy_SA") - SA.add_parameter("spectrum", parameter_class=Spectrum) - SA.add_parameter("listspectrum", parameter_class=ListSpectrum) - SA.add_parameter("tuplespectrum", parameter_class=TupleSpectrum) - SA.add_parameter("multidimspectrum", parameter_class=MultiDimSpectrum) - yield SA - - SA.close() - - -@pytest.fixture -def meas_with_registered_param(experiment, DAC, DMM): - meas = Measurement() - meas.register_parameter(DAC.ch1) - meas.register_parameter(DMM.v1, setpoints=[DAC.ch1]) - yield meas - - -@pytest.fixture -def meas_with_registered_param_2d(experiment, DAC, DMM): - meas = Measurement() - meas.register_parameter(DAC.ch1) - meas.register_parameter(DAC.ch2) - meas.register_parameter(DMM.v1, setpoints=[DAC.ch1, DAC.ch2]) - yield meas - - -@pytest.fixture -def meas_with_registered_param_3d(experiment, DAC3D, DMM): - meas = Measurement() - meas.register_parameter(DAC3D.ch1) - meas.register_parameter(DAC3D.ch2) - meas.register_parameter(DAC3D.ch3) - meas.register_parameter(DMM.v1, setpoints=[DAC3D.ch1, DAC3D.ch2, DAC3D.ch3]) - yield meas - - -@pytest.fixture(name="meas_with_registered_param_complex") -def _make_meas_with_registered_param_complex(experiment, DAC, complex_num_instrument): - meas = Measurement() - meas.register_parameter(DAC.ch1) - meas.register_parameter(complex_num_instrument.complex_num, setpoints=[DAC.ch1]) - yield meas - - -@pytest.fixture(name="dummyinstrument") -def _make_dummy_instrument() -> Iterator[DummyChannelInstrument]: - inst = DummyChannelInstrument("dummyinstrument") - try: - yield inst - finally: - inst.close() - - -class ArrayshapedParam(Parameter): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - def get_raw(self): - assert isinstance(self.vals, Arrays) - shape = self.vals.shape - - return np.random.rand(*shape) diff --git a/src/qcodes/tests/dataset/dond/__init__.py b/src/qcodes/tests/dataset/dond/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/dataset/dond/conftest.py b/src/qcodes/tests/dataset/dond/conftest.py deleted file mode 100644 index 947b5e3610d..00000000000 --- a/src/qcodes/tests/dataset/dond/conftest.py +++ /dev/null @@ -1,92 +0,0 @@ -import matplotlib.pyplot as plt -import pytest - -from qcodes import config, validators -from qcodes.parameters import Parameter - - -@pytest.fixture(autouse=True) -def set_tmp_output_dir(tmpdir): - old_config = config.user.mainfolder - try: - config.user.mainfolder = str(tmpdir) - yield - finally: - config.user.mainfolder = old_config - - -@pytest.fixture() -def plot_close(): - yield - plt.close("all") - - -@pytest.fixture() -def _param(): - p = Parameter("simple_parameter", set_cmd=None, get_cmd=lambda: 1) - return p - - -@pytest.fixture() -def _param_2(): - p = Parameter("simple_parameter_2", set_cmd=None, get_cmd=lambda: 2) - return p - - -@pytest.fixture() -def _param_complex(): - p = Parameter( - "simple_complex_parameter", - set_cmd=None, - get_cmd=lambda: 1 + 1j, - vals=validators.ComplexNumbers(), - ) - return p - - -@pytest.fixture() -def _param_complex_2(): - p = Parameter( - "simple_complex_parameter_2", - set_cmd=None, - get_cmd=lambda: 2 + 2j, - vals=validators.ComplexNumbers(), - ) - return p - - -@pytest.fixture() -def _param_set(): - p = Parameter("simple_setter_parameter", set_cmd=None, get_cmd=None) - return p - - -@pytest.fixture() -def _param_set_2(): - p = Parameter("simple_setter_parameter_2", set_cmd=None, get_cmd=None) - return p - - -def _param_func(_p): - """ - A private utility function. - """ - _new_param = Parameter( - "modified_parameter", set_cmd=None, get_cmd=lambda: _p.get() * 2 - ) - return _new_param - - -@pytest.fixture() -def _param_callable(_param): - return _param_func(_param) - - -def test_param_callable(_param_callable) -> None: - _param_modified = _param_callable - assert _param_modified.get() == 2 - - -@pytest.fixture() -def _string_callable(): - return "Call" diff --git a/src/qcodes/tests/dataset/fixtures/.gitignore b/src/qcodes/tests/dataset/fixtures/.gitignore deleted file mode 100644 index 8d319264d86..00000000000 --- a/src/qcodes/tests/dataset/fixtures/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -!*.json -!*.dat diff --git a/src/qcodes/tests/dataset/fixtures/__init__.py b/src/qcodes/tests/dataset/fixtures/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/dataset/fixtures/data_2018_01_17/__init__.py b/src/qcodes/tests/dataset/fixtures/data_2018_01_17/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_001_testsweep_15_42_57/__init__.py b/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_001_testsweep_15_42_57/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_001_testsweep_15_42_57/dac_ch1_set.dat b/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_001_testsweep_15_42_57/dac_ch1_set.dat deleted file mode 100644 index d3987392347..00000000000 --- a/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_001_testsweep_15_42_57/dac_ch1_set.dat +++ /dev/null @@ -1,204 +0,0 @@ -# dac_ch1_set dmm_voltage -# "Gate ch1" "Gate voltage" -# 201 -0 57 -0.1 51 -0.2 69 -0.3 40 -0.4 97 -0.5 90 -0.6 17 -0.7 74 -0.8 80 -0.9 6 -1 74 -1.1 18 -1.2 8 -1.3 18 -1.4 39 -1.5 79 -1.6 33 -1.7 40 -1.8 14 -1.9 3 -2 16 -2.1 99 -2.2 22 -2.3 82 -2.4 68 -2.5 66 -2.6 70 -2.7 69 -2.8 83 -2.9 82 -3 1 -3.1 33 -3.2 6 -3.3 38 -3.4 52 -3.5 46 -3.6 19 -3.7 59 -3.8 71 -3.9 39 -4 87 -4.1 24 -4.2 46 -4.3 63 -4.4 95 -4.5 38 -4.6 65 -4.7 15 -4.8 93 -4.9 18 -5 83 -5.1 87 -5.2 71 -5.3 43 -5.4 54 -5.5 67 -5.6 49 -5.7 26 -5.8 27 -5.9 72 -6 0 -6.1 32 -6.2 96 -6.3 48 -6.4 77 -6.5 68 -6.6 57 -6.7 27 -6.8 75 -6.9 25 -7 54 -7.1 70 -7.2 42 -7.3 44 -7.4 82 -7.5 37 -7.6 98 -7.7 10 -7.8 9 -7.9 55 -8 46 -8.1 81 -8.2 34 -8.3 46 -8.4 73 -8.5 35 -8.6 68 -8.7 74 -8.8 32 -8.9 65 -9 59 -9.1 32 -9.2 80 -9.3 0 -9.4 38 -9.5 54 -9.6 12 -9.7 5 -9.8 20 -9.9 94 -10 31 -10.1 4 -10.2 60 -10.3 14 -10.4 70 -10.5 1 -10.6 37 -10.7 32 -10.8 10 -10.9 97 -11 16 -11.1 21 -11.2 53 -11.3 19 -11.4 77 -11.5 51 -11.6 8 -11.7 83 -11.8 85 -11.9 22 -12 100 -12.1 45 -12.2 62 -12.3 35 -12.4 92 -12.5 74 -12.6 15 -12.7 29 -12.8 94 -12.9 6 -13 1 -13.1 49 -13.2 91 -13.3 16 -13.4 69 -13.5 33 -13.6 32 -13.7 2 -13.8 36 -13.9 5 -14 96 -14.1 87 -14.2 67 -14.3 79 -14.4 16 -14.5 87 -14.6 7 -14.7 27 -14.8 100 -14.9 24 -15 97 -15.1 52 -15.2 13 -15.3 8 -15.4 40 -15.5 73 -15.6 57 -15.7 92 -15.8 91 -15.9 94 -16 63 -16.1 17 -16.2 50 -16.3 37 -16.4 71 -16.5 23 -16.6 33 -16.7 53 -16.8 68 -16.9 7 -17 17 -17.1 72 -17.2 94 -17.3 62 -17.4 70 -17.5 10 -17.6 56 -17.7 81 -17.8 39 -17.9 14 -18 40 -18.1 60 -18.2 48 -18.3 65 -18.4 98 -18.5 43 -18.6 12 -18.7 5 -18.8 85 -18.9 54 -19 91 -19.1 84 -19.2 98 -19.3 44 -19.4 61 -19.5 52 -19.6 1 -19.7 82 -19.8 59 -19.9 89 -20 17 diff --git a/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_001_testsweep_15_42_57/snapshot.json b/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_001_testsweep_15_42_57/snapshot.json deleted file mode 100644 index 7de44914386..00000000000 --- a/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_001_testsweep_15_42_57/snapshot.json +++ /dev/null @@ -1,230 +0,0 @@ -{ - "station": { - "instruments": { - "dac": { - "functions": {}, - "submodules": {}, - "__class__": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "parameters": { - "IDN": { - "value": { - "vendor": null, - "model": "dac", - "serial": null, - "firmware": null - }, - "ts": "2018-01-17 15:42:38", - "raw_value": { - "vendor": null, - "model": "dac", - "serial": null, - "firmware": null - }, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dac_IDN", - "vals": "", - "label": "IDN", - "name": "IDN", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dac", - "post_delay": 0, - "unit": "" - }, - "ch1": { - "value": 8, - "ts": "2018-01-17 15:42:44", - "raw_value": 8, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dac_ch1", - "vals": "", - "label": "Gate ch1", - "name": "ch1", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dac", - "post_delay": 0, - "unit": "V" - }, - "ch2": { - "value": 0, - "ts": "2018-01-17 15:42:38", - "raw_value": 0, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dac_ch2", - "vals": "", - "label": "Gate ch2", - "name": "ch2", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dac", - "post_delay": 0, - "unit": "V" - }, - "verbose_channel": { - "value": 5, - "ts": "2018-01-17 15:42:50", - "raw_value": 5, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dac_verbose_channel", - "label": "Verbose Channel", - "name": "verbose_channel", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dac", - "post_delay": 0, - "unit": "V" - } - }, - "name": "dac" - }, - "dmm": { - "functions": {}, - "submodules": {}, - "__class__": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "parameters": { - "IDN": { - "value": { - "vendor": null, - "model": "dmm", - "serial": null, - "firmware": null - }, - "ts": "2018-01-17 15:42:38", - "raw_value": { - "vendor": null, - "model": "dmm", - "serial": null, - "firmware": null - }, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dmm_IDN", - "vals": "", - "label": "IDN", - "name": "IDN", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dmm", - "post_delay": 0, - "unit": "" - }, - "voltage": { - "value": 0, - "ts": "2018-01-17 15:42:38", - "raw_value": 0, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dmm_voltage", - "vals": "", - "label": "Gate voltage", - "name": "voltage", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dmm", - "post_delay": 0, - "unit": "V" - } - }, - "name": "dmm" - } - }, - "parameters": {}, - "components": {}, - "default_measurement": [] - }, - "loop": { - "__class__": "qcodes.loops.ActiveLoop", - "sweep_values": { - "parameter": { - "value": 8, - "ts": "2018-01-17 15:42:44", - "raw_value": 8, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dac_ch1", - "vals": "", - "label": "Gate ch1", - "name": "ch1", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dac", - "post_delay": 0, - "unit": "V" - }, - "values": [ - { - "first": 0.0, - "last": 20.0, - "num": 201, - "type": "linear" - } - ] - }, - "delay": 0.001, - "actions": [ - { - "value": 0, - "ts": "2018-01-17 15:42:38", - "raw_value": 0, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dmm_voltage", - "vals": "", - "label": "Gate voltage", - "name": "voltage", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dmm", - "post_delay": 0, - "unit": "V" - } - ], - "then_actions": [], - "ts_start": "2018-01-17 15:43:00", - "use_threads": false, - "ts_end": "2018-01-17 15:43:04" - }, - "__class__": "qcodes.data.data_set.DataSet", - "location": "data/2018-01-17/#001_testsweep_15-42-57", - "arrays": { - "dac_ch1_set": { - "__class__": "qcodes.data.data_array.DataArray", - "raw_value": 8, - "full_name": "dac_ch1", - "vals": "", - "label": "Gate ch1", - "name": "ch1", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dac", - "post_delay": 0, - "unit": "V", - "array_id": "dac_ch1_set", - "shape": [ - 201 - ], - "action_indices": [], - "is_setpoint": true - }, - "dmm_voltage": { - "__class__": "qcodes.data.data_array.DataArray", - "raw_value": 0, - "full_name": "dmm_voltage", - "vals": "", - "label": "Gate voltage", - "name": "voltage", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dmm", - "post_delay": 0, - "unit": "V", - "array_id": "dmm_voltage", - "shape": [ - 201 - ], - "action_indices": [ - 0 - ], - "is_setpoint": false - } - }, - "formatter": "qcodes.data.gnuplot_format.GNUPlotFormat", - "io": "" -} diff --git a/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_002_2D_test_15_43_14/__init__.py b/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_002_2D_test_15_43_14/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_002_2D_test_15_43_14/dac_ch1_set_dac_ch2_set.dat b/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_002_2D_test_15_43_14/dac_ch1_set_dac_ch2_set.dat deleted file mode 100644 index 497d9786d3d..00000000000 --- a/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_002_2D_test_15_43_14/dac_ch1_set_dac_ch2_set.dat +++ /dev/null @@ -1,44 +0,0 @@ -# dac_ch1_set dac_ch2_set dmm_voltage -# "Gate ch1" "Gate ch2" "Gate voltage" -# 6 6 -0 0 9 -0 1 42 -0 2 80 -0 3 15 -0 4 28 -0 5 11 - -1 0 17 -1 1 95 -1 2 46 -1 3 39 -1 4 33 -1 5 40 - -2 0 61 -2 1 51 -2 2 95 -2 3 36 -2 4 73 -2 5 36 - -3 0 96 -3 1 32 -3 2 77 -3 3 81 -3 4 100 -3 5 14 - -4 0 71 -4 1 51 -4 2 41 -4 3 57 -4 4 61 -4 5 94 - -5 0 73 -5 1 81 -5 2 61 -5 3 21 -5 4 94 -5 5 1 diff --git a/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_002_2D_test_15_43_14/snapshot.json b/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_002_2D_test_15_43_14/snapshot.json deleted file mode 100644 index ed7775ab9a0..00000000000 --- a/src/qcodes/tests/dataset/fixtures/data_2018_01_17/data_002_2D_test_15_43_14/snapshot.json +++ /dev/null @@ -1,286 +0,0 @@ -{ - "station": { - "instruments": { - "dac": { - "functions": {}, - "submodules": {}, - "__class__": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "parameters": { - "IDN": { - "value": { - "vendor": null, - "model": "dac", - "serial": null, - "firmware": null - }, - "ts": "2018-01-17 15:42:38", - "raw_value": { - "vendor": null, - "model": "dac", - "serial": null, - "firmware": null - }, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dac_IDN", - "vals": "", - "label": "IDN", - "name": "IDN", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dac", - "post_delay": 0, - "unit": "" - }, - "ch1": { - "value": 20.0, - "ts": "2018-01-17 15:43:04", - "raw_value": 20.0, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dac_ch1", - "vals": "", - "label": "Gate ch1", - "name": "ch1", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dac", - "post_delay": 0, - "unit": "V" - }, - "ch2": { - "value": 0, - "ts": "2018-01-17 15:42:38", - "raw_value": 0, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dac_ch2", - "vals": "", - "label": "Gate ch2", - "name": "ch2", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dac", - "post_delay": 0, - "unit": "V" - }, - "verbose_channel": { - "value": 5, - "ts": "2018-01-17 15:42:50", - "raw_value": 5, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dac_verbose_channel", - "label": "Verbose Channel", - "name": "verbose_channel", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dac", - "post_delay": 0, - "unit": "V" - } - }, - "name": "dac" - }, - "dmm": { - "functions": {}, - "submodules": {}, - "__class__": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "parameters": { - "IDN": { - "value": { - "vendor": null, - "model": "dmm", - "serial": null, - "firmware": null - }, - "ts": "2018-01-17 15:42:38", - "raw_value": { - "vendor": null, - "model": "dmm", - "serial": null, - "firmware": null - }, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dmm_IDN", - "vals": "", - "label": "IDN", - "name": "IDN", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dmm", - "post_delay": 0, - "unit": "" - }, - "voltage": { - "value": 0, - "ts": "2018-01-17 15:42:38", - "raw_value": 0, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dmm_voltage", - "vals": "", - "label": "Gate voltage", - "name": "voltage", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dmm", - "post_delay": 0, - "unit": "V" - } - }, - "name": "dmm" - } - }, - "parameters": {}, - "components": {}, - "default_measurement": [] - }, - "loop": { - "__class__": "qcodes.loops.ActiveLoop", - "sweep_values": { - "parameter": { - "value": 20.0, - "ts": "2018-01-17 15:43:04", - "raw_value": 20.0, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dac_ch1", - "vals": "", - "label": "Gate ch1", - "name": "ch1", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dac", - "post_delay": 0, - "unit": "V" - }, - "values": [ - { - "first": 0.0, - "last": 5.0, - "num": 6, - "type": "linear" - } - ] - }, - "delay": 0.1, - "actions": [ - { - "__class__": "qcodes.loops.ActiveLoop", - "sweep_values": { - "parameter": { - "value": 0, - "ts": "2018-01-17 15:42:38", - "raw_value": 0, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dac_ch2", - "vals": "", - "label": "Gate ch2", - "name": "ch2", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dac", - "post_delay": 0, - "unit": "V" - }, - "values": [ - { - "first": 0.0, - "last": 5.0, - "num": 6, - "type": "linear" - } - ] - }, - "delay": 0.1, - "actions": [ - { - "value": 0, - "ts": "2018-01-17 15:42:38", - "raw_value": 0, - "__class__": "qcodes.instrument.parameter.Parameter", - "full_name": "dmm_voltage", - "vals": "", - "label": "Gate voltage", - "name": "voltage", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dmm", - "post_delay": 0, - "unit": "V" - } - ], - "then_actions": [] - } - ], - "then_actions": [], - "ts_start": "2018-01-17 15:43:15", - "use_threads": false, - "ts_end": "2018-01-17 15:43:20" - }, - "__class__": "qcodes.data.data_set.DataSet", - "location": "data/2018-01-17/#002_2D_test_15-43-14", - "arrays": { - "dac_ch1_set": { - "__class__": "qcodes.data.data_array.DataArray", - "raw_value": 20.0, - "full_name": "dac_ch1", - "vals": "", - "label": "Gate ch1", - "name": "ch1", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dac", - "post_delay": 0, - "unit": "V", - "array_id": "dac_ch1_set", - "shape": [ - 6 - ], - "action_indices": [], - "is_setpoint": true - }, - "dac_ch2_set": { - "__class__": "qcodes.data.data_array.DataArray", - "raw_value": 0, - "full_name": "dac_ch2", - "vals": "", - "label": "Gate ch2", - "name": "ch2", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dac", - "post_delay": 0, - "unit": "V", - "array_id": "dac_ch2_set", - "shape": [ - 6, - 6 - ], - "action_indices": [ - 0 - ], - "is_setpoint": true - }, - "dmm_voltage": { - "__class__": "qcodes.data.data_array.DataArray", - "raw_value": 0, - "full_name": "dmm_voltage", - "vals": "", - "label": "Gate voltage", - "name": "voltage", - "inter_delay": 0, - "instrument": "qcodes.instrument_drivers.mock_instruments.DummyInstrument", - "instrument_name": "dmm", - "post_delay": 0, - "unit": "V", - "array_id": "dmm_voltage", - "shape": [ - 6, - 6 - ], - "action_indices": [ - 0, - 0 - ], - "is_setpoint": false - } - }, - "formatter": "qcodes.data.gnuplot_format.GNUPlotFormat", - "io": "" -} diff --git a/src/qcodes/tests/dataset/helper_functions.py b/src/qcodes/tests/dataset/helper_functions.py deleted file mode 100644 index 52df8ccce2d..00000000000 --- a/src/qcodes/tests/dataset/helper_functions.py +++ /dev/null @@ -1,136 +0,0 @@ -from __future__ import annotations - -from functools import reduce -from operator import mul -from typing import TYPE_CHECKING - -import numpy as np -from numpy.testing import assert_array_equal - -if TYPE_CHECKING: - from collections.abc import Hashable, Mapping, Sequence - - import pandas as pd - - -def verify_data_dict( - data: dict[str, dict[str, np.ndarray]], - dataframe: dict[str, pd.DataFrame] | None, - parameter_names: Sequence[str], - expected_names: Mapping[str, Sequence[str]], - expected_shapes: Mapping[str, Sequence[tuple[int, ...]]], - expected_values: Mapping[str, Sequence[np.ndarray]], -) -> None: - """ - Simple helper function to verify a dict of data. It can also optionally - - The expected names values - and shapes should be given as a dict with keys given by the dependent - parameters. Each value in the dicts should be the sequence of expected - names/shapes/values for that requested parameter and its dependencies. - The first element in the sequence must be the dependent parameter loaded. - - Args: - data: The dict data to verify the shape and content of. - dataframe: The data represented as a dict of Pandas DataFrames. - parameter_names: names of the parameters requested. These are expected - as top level keys in the dict. - expected_names: names of the parameters expected to be loaded for a - given parameter as a sequence indexed by the parameter. - expected_shapes: expected shapes of the parameters loaded. The shapes - should be stored as a tuple per parameter in a sequence containing - all the loaded parameters for a given requested parameter. - expected_values: expected content of the data arrays stored in a - sequence - - """ - # check that all the expected parameters in the dict are - # included in the list of parameters - assert all(param in parameter_names for param in list(data.keys())) - if dataframe is not None: - assert all(param in parameter_names for param in list(dataframe.keys())) - for param in parameter_names: - innerdata = data[param] - verify_data_dict_for_single_param( - innerdata, - expected_names[param], - expected_shapes[param], - expected_values[param], - ) - if dataframe is not None: - innerdataframe = dataframe[param] - verify_dataframe_for_single_param( - innerdataframe, - expected_names[param], - expected_shapes[param], - expected_values[param], - ) - - -def verify_data_dict_for_single_param( - datadict: dict[str, np.ndarray], - names: Sequence[str], - shapes: Sequence[tuple[int, ...]], - values, -): - # check that there are no unexpected elements in the dict - key_names = list(datadict.keys()) - assert set(key_names) == set(names) - - for name, shape, value in zip(names, shapes, values): - if datadict[name].dtype == np.dtype("O"): - mydata = np.concatenate(datadict[name]) - else: - mydata = datadict[name] - assert mydata.shape == shape - assert_array_equal(mydata, value) - - -def verify_dataframe_for_single_param( - dataframe: pd.DataFrame, - names: Sequence[str], - shapes: Sequence[tuple[int, ...]], - values, -): - import pandas as pd - - # check that the dataframe has the same elements as index and columns - pandas_index_names = list(dataframe.index.names) - pandas_column_names = list(dataframe) - pandas_names: list[Hashable] = [] - for i in pandas_index_names: - if i is not None: - pandas_names.append(i) - for j in pandas_column_names: - if j is not None: - pandas_names.append(j) - assert set(pandas_names) == set(names) - - # lets check that the index is made up - # from all but the first column as expected - if len(values) > 1: - expected_index_values = values[1:] - index_values = dataframe.index.values - - nindexes = len(expected_index_values) - nrows = shapes[0] - - for row in range(len(nrows)): - row_index_values = index_values[row] - # one dimensional arrays will have single values for there indexed - # not tuples as they don't use multiindex. Put these in tuples - # for easy comparison - if not isinstance(dataframe.index, pd.MultiIndex): - row_index_values = (row_index_values,) - - expected_values = tuple( - expected_index_values[indexnum].ravel()[row] - for indexnum in range(nindexes) - ) - assert row_index_values == expected_values - - simpledf = dataframe.reset_index() - - for name, shape, value in zip(names, shapes, values): - assert len(simpledf[name]) == reduce(mul, shape) - assert_array_equal(dataframe.reset_index()[name].to_numpy(), value.ravel()) diff --git a/src/qcodes/tests/dataset/measurement/__init__.py b/src/qcodes/tests/dataset/measurement/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/dataset_generators.py b/src/qcodes/tests/dataset_generators.py deleted file mode 100644 index e7b76d5055f..00000000000 --- a/src/qcodes/tests/dataset_generators.py +++ /dev/null @@ -1,34 +0,0 @@ -import numpy as np - -from qcodes.dataset.descriptions.dependencies import InterDependencies_ -from qcodes.dataset.descriptions.param_spec import ParamSpecBase - - -def dataset_with_outliers_generator( - ds, data_offset=5, low_outlier=-3, high_outlier=1, background_noise=True -): - x = ParamSpecBase("x", "numeric", label="Flux", unit="e^2/hbar") - t = ParamSpecBase("t", "numeric", label="Time", unit="s") - z = ParamSpecBase("z", "numeric", label="Majorana number", unit="Anyon") - - idps = InterDependencies_(dependencies={z: (x, t)}) - ds.set_interdependencies(idps) - ds.mark_started() - - npoints = 50 - xvals = np.linspace(0, 1, npoints) - tvals = np.linspace(0, 1, npoints) - for counter, xv in enumerate(xvals): - if background_noise and ( - counter < round(npoints / 2.3) or counter > round(npoints / 1.8) - ): - data = np.random.rand(npoints) - data_offset - else: - data = xv * np.linspace(0, 1, npoints) - if counter == round(npoints / 1.9): - data[round(npoints / 1.9)] = high_outlier - if counter == round(npoints / 2.1): - data[round(npoints / 2.5)] = low_outlier - ds.add_results([{"x": xv, "t": tv, "z": z} for z, tv in zip(data, tvals)]) - ds.mark_completed() - return ds diff --git a/src/qcodes/tests/delegate/__init__.py b/src/qcodes/tests/delegate/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/delegate/conftest.py b/src/qcodes/tests/delegate/conftest.py deleted file mode 100644 index 38868839ae0..00000000000 --- a/src/qcodes/tests/delegate/conftest.py +++ /dev/null @@ -1,54 +0,0 @@ -import os -import pathlib - -import pytest - -from qcodes.instrument_drivers.mock_instruments import MockDAC, MockField, MockLockin -from qcodes.station import Station - -PARENT_DIR = pathlib.Path(__file__).parent.absolute() - - -@pytest.fixture(scope="function") -def dac(): - return MockDAC("dac", num_channels=3) - - -@pytest.fixture(scope="function") -def field_x(): - return MockField("field_x") - - -@pytest.fixture(scope="function") -def lockin(): - _lockin = MockLockin(name="lockin") - return _lockin - - -@pytest.fixture(scope="function") -def station(dac, lockin, field_x): - _station = Station() - _station.add_component(dac) - _station.add_component(lockin) - _station.add_component(field_x) - return _station - - -@pytest.fixture() -def chip_config(): - return os.path.join(PARENT_DIR, "data/chip.yml") - - -@pytest.fixture() -def chip(station, chip_config): - if hasattr(station, "MockChip_123"): - return station.MockChip_123 - - station.load_config_file(chip_config) - _chip = station.load_MockChip_123(station=station) - return _chip - - -@pytest.fixture() -def chip_config_typo(): - return os.path.join(PARENT_DIR, "data/chip_typo.yml") diff --git a/src/qcodes/tests/delegate/data/__init__.py b/src/qcodes/tests/delegate/data/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/delegate/data/chip.yml b/src/qcodes/tests/delegate/data/chip.yml deleted file mode 100644 index 20dac4f2e04..00000000000 --- a/src/qcodes/tests/delegate/data/chip.yml +++ /dev/null @@ -1,77 +0,0 @@ -instruments: - MockChip_123: - type: qcodes.instrument.delegate.InstrumentGroup - init: - submodules_type: qcodes.instrument.delegate.DelegateInstrument - submodules: - device1: - parameters: - gate: dac.ch01.voltage - source: - - lockin.frequency - - lockin.amplitude - - lockin.phase - - lockin.time_constant - drain: - - lockin.X - - lockin.Y - - channel_device: - parameters: - readout: lockin.phase - channels: - gate_1: dac.ch01 - - channel_device_custom: - parameters: - readout: lockin.phase - channels: - gate_1: - channel: dac.ch01 - type: qcodes.instrument_drivers.mock_instruments.MockCustomChannel - current_valid_range: [-0.5, 0] - fast_gate: - channel: dac.ch02 - type: qcodes.instrument_drivers.mock_instruments.DummyChannel - - set_initial_values_on_load: true - initial_values: - device1: - gate.step: 5e-4 - gate.inter_delay: 12.5e-4 - channel_device: - readout: 1e-5 - gate_1.voltage.post_delay: 0.01 - channel_device_custom: - readout: 1e-5 - - field: - type: qcodes.instrument.delegate.DelegateInstrument - init: - parameters: - X: field_x.field - ramp_rate: field_x.ramp_rate - ramp_X: - - field_x.ramp_rate - - field_x.field - set_initial_values_on_load: true - initial_values: - ramp_rate: 0.02 - setters: - X: - method: field_x.set_field - block: false - units: - X: T - ramp_rate: T/min - - switch: - type: qcodes.instrument.delegate.DelegateChannelInstrument - init: - channels: dac.channels - parameters: - state: - - dac_output - - smc - - gnd - - bus diff --git a/src/qcodes/tests/delegate/data/chip_typo.yml b/src/qcodes/tests/delegate/data/chip_typo.yml deleted file mode 100644 index 61cf81c48bc..00000000000 --- a/src/qcodes/tests/delegate/data/chip_typo.yml +++ /dev/null @@ -1,42 +0,0 @@ -instruments: - MockChip_123: - type: qcodes.instrument.delegate.InstrumentGroup - init: - submodules_type: qcodes.instrument.delegate.DelegateInstrument - submodules: - device1: - gate: dac.ch01.voltage - source: - - lockin.frequency - - lockin.amplitude - - lockin.phase - - lockin.time_constant - drain: - - lockin.X - - lockin.Y - - channel_device: - parameters: - readout: lockin.phase - channels: - gate_1: dac.ch01 - - channel_device_custom: - parameters: - readout: lockin.phase - channels: - type: qcodes.instrument_drivers.mock_instruments.MockCustomChannel - gate_1: - channel: dac.ch01 - current_valid_range: [-0.5, 0] - - set_initial_values_on_load: true - initial_values: - device1: - gate.step: 5e-4 - gate.inter_delay: 12.5e-4 - channel_device: - readout: 1e-5 - gate_1.voltage.post_delay: 0.01 - channel_device_custom: - readout: 1e-5 diff --git a/src/qcodes/tests/driver_test_case.py b/src/qcodes/tests/driver_test_case.py deleted file mode 100644 index f6321cc369f..00000000000 --- a/src/qcodes/tests/driver_test_case.py +++ /dev/null @@ -1,51 +0,0 @@ -# ruff: noqa: F401 -""" -Module left for backwards compatibility. Will be deprecated and removed along the rest of qcodes.tests""" - -from __future__ import annotations - -import unittest - -from qcodes.extensions import ( - DriverTestCase, -) -from qcodes.instrument import Instrument - - -def test_instruments(verbosity: int = 1) -> None: - """ - Discover available instruments and test them all - Unlike test_instrument, this does NOT reload tests prior to running them - - optional verbosity (default 1) - """ - import qcodes - import qcodes.instrument_drivers as qcdrivers - - driver_path = list(qcdrivers.__path__)[0] - suite = unittest.defaultTestLoader.discover( - driver_path, top_level_dir=list(qcodes.__path__)[0] - ) - unittest.TextTestRunner(verbosity=verbosity).run(suite) - - -def test_instrument(instrument_testcase, verbosity: int = 2) -> None: - """ - Runs one instrument testcase - Reloads the test case before running it - - optional verbosity (default 2) - """ - import importlib - import sys - - # reload the test case - module_name = instrument_testcase.__module__ - class_name = instrument_testcase.__name__ - del sys.modules[module_name] - - module = importlib.import_module(module_name) - reloaded_testcase = getattr(module, class_name) - - suite = unittest.defaultTestLoader.loadTestsFromTestCase(reloaded_testcase) - unittest.TextTestRunner(verbosity=verbosity).run(suite) diff --git a/src/qcodes/tests/drivers/AlazarTech/__init__.py b/src/qcodes/tests/drivers/AlazarTech/__init__.py deleted file mode 100644 index 186c0c6e0b0..00000000000 --- a/src/qcodes/tests/drivers/AlazarTech/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Test for Alazar card driver and related infrastructure""" diff --git a/src/qcodes/tests/drivers/__init__.py b/src/qcodes/tests/drivers/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/drivers/auxiliary_files/__init__.py b/src/qcodes/tests/drivers/auxiliary_files/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/drivers/auxiliary_files/awgSeqDataSets.xsd b/src/qcodes/tests/drivers/auxiliary_files/awgSeqDataSets.xsd deleted file mode 100644 index 73c75ab9d77..00000000000 --- a/src/qcodes/tests/drivers/auxiliary_files/awgSeqDataSets.xsd +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/qcodes/tests/drivers/keysight_b1500/__init__.py b/src/qcodes/tests/drivers/keysight_b1500/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/drivers/keysight_b1500/b1500_driver_tests/__init__.py b/src/qcodes/tests/drivers/keysight_b1500/b1500_driver_tests/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/drivers/keysight_b1500/b1500_driver_tests/conftest.py b/src/qcodes/tests/drivers/keysight_b1500/b1500_driver_tests/conftest.py deleted file mode 100644 index 069254fdd88..00000000000 --- a/src/qcodes/tests/drivers/keysight_b1500/b1500_driver_tests/conftest.py +++ /dev/null @@ -1,42 +0,0 @@ -from unittest.mock import MagicMock, PropertyMock - -import pytest -from pytest import FixtureRequest -from pyvisa import VisaIOError - -from qcodes.instrument_drivers.Keysight.keysightb1500.KeysightB1500_base import ( - KeysightB1500, -) - - -@pytest.fixture(name="b1500") -def _make_b1500(request: FixtureRequest): - request.addfinalizer(KeysightB1500.close_all) - - try: - resource_name = "insert_Keysight_B2200_VISA_resource_name_here" - instance = KeysightB1500("SPA", address=resource_name) - except (ValueError, VisaIOError): - # Either there is no VISA lib installed or there was no real - # instrument found at the specified address => use simulated instrument - instance = KeysightB1500( - "SPA", address="GPIB::1::INSTR", pyvisa_sim_file="keysight_b1500.yaml" - ) - - instance.get_status() - instance.reset() - - yield instance - - -@pytest.fixture(name="mainframe") -def _make_mainframe(): - PropertyMock() - mainframe = MagicMock() - name_parts = PropertyMock(return_value=["mainframe"]) - type(mainframe).name_parts = name_parts - short_name = PropertyMock(return_value="short_name") - type(mainframe).short_name = short_name - full_name = PropertyMock(return_value="mainframe") - type(mainframe).full_name = full_name - yield mainframe diff --git a/src/qcodes/tests/helpers/__init__.py b/src/qcodes/tests/helpers/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/instrument_mocks.py b/src/qcodes/tests/instrument_mocks.py deleted file mode 100644 index 679da7ec127..00000000000 --- a/src/qcodes/tests/instrument_mocks.py +++ /dev/null @@ -1,52 +0,0 @@ -# ruff: noqa: F401 -# left for backwards compatibility will be deprecated and removed -# along with the rest of qcodes.tests -from __future__ import annotations - -import logging -import time -from collections.abc import Generator, Sequence -from functools import partial -from typing import Any - -import numpy as np - -from qcodes.instrument import ChannelList, Instrument, InstrumentBase, InstrumentChannel -from qcodes.instrument_drivers.mock_instruments import ( - ArraySetPointParam, - ComplexArraySetPointParam, - DmmExponentialParameter, - DmmGaussParameter, - DummyBase, - DummyChannel, - DummyChannelInstrument, - DummyFailingInstrument, - DummyInstrument, - DummyInstrumentWithMeasurement, - DummyParameterWithSetpoints1D, - DummyParameterWithSetpoints2D, - DummyParameterWithSetpointsComplex, - GeneratedSetPoints, - MockCustomChannel, - MockDAC, - MockDACChannel, - MockField, - MockLockin, - MockMetaParabola, - MockParabola, - Multi2DSetPointParam, - Multi2DSetPointParam2Sizes, - MultiScalarParam, - MultiSetPointParam, - SnapShotTestInstrument, - setpoint_generator, -) -from qcodes.parameters import ( - ArrayParameter, - MultiParameter, - Parameter, - ParameterWithSetpoints, - ParamRawDataType, -) -from qcodes.validators import Arrays, ComplexNumbers, Numbers, OnOff, Strings -from qcodes.validators import Sequence as ValidatorSequence diff --git a/src/qcodes/tests/mockers/__init__.py b/src/qcodes/tests/mockers/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/parameter/__init__.py b/src/qcodes/tests/parameter/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/parameter/conftest.py b/src/qcodes/tests/parameter/conftest.py deleted file mode 100644 index ee98eb896ca..00000000000 --- a/src/qcodes/tests/parameter/conftest.py +++ /dev/null @@ -1,219 +0,0 @@ -from __future__ import annotations - -from collections import namedtuple -from typing import TYPE_CHECKING, Any, Literal, TypeVar - -import pytest - -import qcodes.validators as vals -from qcodes.instrument_drivers.mock_instruments import DummyChannelInstrument -from qcodes.parameters import ParamDataType, Parameter, ParamRawDataType - -if TYPE_CHECKING: - from collections.abc import Callable, Generator - - from qcodes.instrument import InstrumentBase - -T = TypeVar("T") - -NOT_PASSED: Literal["NOT_PASSED"] = "NOT_PASSED" - - -@pytest.fixture(params=(True, False, NOT_PASSED)) -def snapshot_get(request: pytest.FixtureRequest) -> bool | Literal["NOT_PASSED"]: - return request.param - - -@pytest.fixture(params=(True, False, NOT_PASSED)) -def snapshot_value(request: pytest.FixtureRequest) -> bool | Literal["NOT_PASSED"]: - return request.param - - -@pytest.fixture(params=(None, False, NOT_PASSED)) -def get_cmd( - request: pytest.FixtureRequest, -) -> None | Literal[False] | Literal["NOT_PASSED"]: - return request.param - - -@pytest.fixture(params=(True, False, NOT_PASSED)) -def get_if_invalid(request: pytest.FixtureRequest) -> bool | Literal["NOT_PASSED"]: - return request.param - - -@pytest.fixture(params=(True, False, None, NOT_PASSED)) -def update(request: pytest.FixtureRequest) -> bool | None | Literal["NOT_PASSED"]: - return request.param - - -@pytest.fixture(params=(True, False)) -def cache_is_valid(request: pytest.FixtureRequest) -> bool: - return request.param - - -@pytest.fixture(name="dummy_instrument") -def _make_dummy_instrument() -> Generator[DummyChannelInstrument, None, None]: - instr = DummyChannelInstrument("dummy") - yield instr - instr.close() - - -class GettableParam(Parameter): - """Parameter that keeps track of number of get operations""" - - def __init__(self, *args: Any, **kwargs: Any): - super().__init__(*args, **kwargs) - self._get_count = 0 - - def get_raw(self) -> int: - self._get_count += 1 - return 42 - - -class BetterGettableParam(Parameter): - """Parameter that keeps track of number of get operations, - But can actually store values""" - - def __init__(self, *args: Any, **kwargs: Any): - super().__init__(*args, **kwargs) - self._get_count = 0 - - def get_raw(self) -> Any: - self._get_count += 1 - return self.cache.raw_value - - -class SettableParam(Parameter): - """Parameter that keeps track of number of set operations""" - - def __init__(self, *args: Any, **kwargs: Any): - self._set_count = 0 - super().__init__(*args, **kwargs) - - def set_raw(self, value: Any) -> None: - self._set_count += 1 - - -class OverwriteGetParam(Parameter): - """Parameter that overwrites get.""" - - def __init__(self, *args: Any, **kwargs: Any): - super().__init__(*args, **kwargs) - self._value = 42 - self.set_count = 0 - self.get_count = 0 - - def get(self) -> int: - self.get_count += 1 - return self._value - - -class OverwriteSetParam(Parameter): - """Parameter that overwrites set.""" - - def __init__(self, *args: Any, **kwargs: Any): - super().__init__(*args, **kwargs) - self._value = 42 - self.set_count = 0 - self.get_count = 0 - - def set(self, value: Any) -> None: - self.set_count += 1 - self._value = value - - -class GetSetRawParameter(Parameter): - """Parameter that implements get and set raw""" - - def __init__(self, *args: Any, **kwargs: Any): - super().__init__(*args, **kwargs) - - def get_raw(self) -> ParamRawDataType: - return self.cache.raw_value - - def set_raw(self, value: ParamRawDataType) -> None: - pass - - -class BookkeepingValidator(vals.Validator[T]): - """ - Validator that keeps track of what it validates - """ - - def __init__( - self, min_value: float = -float("inf"), max_value: float = float("inf") - ): - self.values_validated: list[T] = [] - - def validate(self, value: T, context: str = "") -> None: - self.values_validated.append(value) - - is_numeric = True - - -class MemoryParameter(Parameter): - def __init__(self, get_cmd: None | Callable[[], Any] = None, **kwargs: Any): - self.set_values: list[Any] = [] - self.get_values: list[Any] = [] - super().__init__( - set_cmd=self.add_set_value, get_cmd=self.create_get_func(get_cmd), **kwargs - ) - - def add_set_value(self, value: ParamDataType) -> None: - self.set_values.append(value) - - def create_get_func( - self, func: None | Callable[[], ParamDataType] - ) -> Callable[[], ParamDataType]: - def get_func() -> ParamDataType: - if func is not None: - val = func() - else: - val = self.cache.raw_value - self.get_values.append(val) - return val - - return get_func - - -class VirtualParameter(Parameter): - def __init__(self, name: str, param: Parameter, **kwargs: Any): - self._param = param - super().__init__(name=name, **kwargs) - - @property - def underlying_instrument(self) -> InstrumentBase | None: - return self._param.instrument - - def get_raw(self) -> ParamRawDataType: - return self._param.get() - - -blank_instruments = ( - None, # no instrument at all - namedtuple("noname", "")(), # no .name - namedtuple("blank", "name")(""), # blank .name -) -named_instrument = namedtuple("yesname", "name")("astro") - - -class ParameterMemory: - def __init__(self) -> None: - self._value: Any | None = None - - def get(self) -> ParamDataType: - return self._value - - def set(self, value: ParamDataType) -> None: - self._value = value - - def set_p_prefixed(self, val: int) -> None: - self._value = f"PVAL: {val:d}" - - @staticmethod - def parse_set_p(val: int) -> str: - return f"{val:d}" - - @staticmethod - def strip_prefix(val: str) -> int: - return int(val[6:]) diff --git a/src/qcodes/tests/sphinx_extension/__init__.py b/src/qcodes/tests/sphinx_extension/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/utils/__init__.py b/src/qcodes/tests/utils/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/validators/__init__.py b/src/qcodes/tests/validators/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/qcodes/tests/validators/conftest.py b/src/qcodes/tests/validators/conftest.py deleted file mode 100644 index 9033ebd90e3..00000000000 --- a/src/qcodes/tests/validators/conftest.py +++ /dev/null @@ -1,7 +0,0 @@ -class AClass: - def method_a(self) -> None: - raise RuntimeError("function should not get called") - - -def a_func() -> None: - pass