Skip to content

Commit

Permalink
Merge pull request #4408 from jenshnielsen/build/add_data_init_files
Browse files Browse the repository at this point in the history
Add __init__.py files to data directories
  • Loading branch information
astafan8 authored Jul 22, 2022
2 parents 15446b4 + f1a762e commit d38994c
Show file tree
Hide file tree
Showing 17 changed files with 89 additions and 65 deletions.
18 changes: 9 additions & 9 deletions docs/examples/DataSet/import-data-from-legacy-dat-files.ipynb

Large diffs are not rendered by default.

Empty file added qcodes/monitor/dist/__init__.py
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
79 changes: 79 additions & 0 deletions qcodes/tests/dataset/measurement/test_load_legacy_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import json
from pathlib import Path

import pytest

from qcodes.dataset import import_dat_file, load_by_id
from qcodes.dataset.data_set import DataSet


@pytest.mark.usefixtures("experiment")
def test_load_legacy_files_2d():
full_location = (
Path(__file__).parent.parent
/ "fixtures"
/ "data_2018_01_17"
/ "data_002_2D_test_15_43_14"
)
run_ids = import_dat_file(str(full_location))
run_id = run_ids[0]
data = load_by_id(run_id)
assert isinstance(data, DataSet)
assert data.parameters == "dac_ch1_set,dac_ch2_set,dmm_voltage"
assert data.number_of_results == 36
expected_names = ["dac_ch1_set", "dac_ch2_set", "dmm_voltage"]
expected_labels = ["Gate ch1", "Gate ch2", "Gate voltage"]
expected_units = ["V", "V", "V"]
expected_depends_on = ["", "", "dac_ch1_set, dac_ch2_set"]
for i, parameter in enumerate(data.get_parameters()):
assert parameter.name == expected_names[i]
assert parameter.label == expected_labels[i]
assert parameter.unit == expected_units[i]
assert parameter.depends_on == expected_depends_on[i]
assert parameter.type == "numeric"
snapshot = json.loads(data.get_metadata("snapshot"))
assert sorted(list(snapshot.keys())) == [
"__class__",
"arrays",
"formatter",
"io",
"location",
"loop",
"station",
]


@pytest.mark.usefixtures("experiment")
def test_load_legacy_files_1d():
full_location = (
Path(__file__).parent.parent
/ "fixtures"
/ "data_2018_01_17"
/ "data_001_testsweep_15_42_57"
)
run_ids = import_dat_file(str(full_location))
run_id = run_ids[0]
data = load_by_id(run_id)
assert isinstance(data, DataSet)
assert data.parameters == "dac_ch1_set,dmm_voltage"
assert data.number_of_results == 201
expected_names = ["dac_ch1_set", "dmm_voltage"]
expected_labels = ["Gate ch1", "Gate voltage"]
expected_units = ["V", "V"]
expected_depends_on = ["", "dac_ch1_set"]
for i, parameter in enumerate(data.get_parameters()):
assert parameter.name == expected_names[i]
assert parameter.label == expected_labels[i]
assert parameter.unit == expected_units[i]
assert parameter.depends_on == expected_depends_on[i]
assert parameter.type == "numeric"
snapshot = json.loads(data.get_metadata("snapshot"))
assert sorted(list(snapshot.keys())) == [
"__class__",
"arrays",
"formatter",
"io",
"location",
"loop",
"station",
]
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from qcodes.dataset.descriptions.param_spec import ParamSpecBase
from qcodes.dataset.experiment_container import new_experiment
from qcodes.dataset.export_config import DataExportType
from qcodes.dataset.legacy_import import import_dat_file
from qcodes.dataset.measurements import Measurement
from qcodes.dataset.sqlite.connection import atomic_transaction
from qcodes.parameters import Parameter, expand_setpoints_helper
Expand Down Expand Up @@ -2248,60 +2247,6 @@ def test_parameter_inference(channel_array_instrument):
'array') == 'array'


@pytest.mark.usefixtures("experiment")
def test_load_legacy_files_2D():
location = '../fixtures/2018-01-17/#002_2D_test_15-43-14'
directory = os.path.dirname(__file__)
full_location = os.path.join(directory, location)
run_ids = import_dat_file(full_location)
run_id = run_ids[0]
data = load_by_id(run_id)
assert isinstance(data, DataSet)
assert data.parameters == 'dac_ch1_set,dac_ch2_set,dmm_voltage'
assert data.number_of_results == 36
expected_names = ['dac_ch1_set', 'dac_ch2_set', 'dmm_voltage']
expected_labels = ['Gate ch1', 'Gate ch2', 'Gate voltage']
expected_units = ['V', 'V', 'V']
expected_depends_on = ['', '', 'dac_ch1_set, dac_ch2_set']
for i, parameter in enumerate(data.get_parameters()):
assert parameter.name == expected_names[i]
assert parameter.label == expected_labels[i]
assert parameter.unit == expected_units[i]
assert parameter.depends_on == expected_depends_on[i]
assert parameter.type == 'numeric'
snapshot = json.loads(data.get_metadata('snapshot'))
assert sorted(list(snapshot.keys())) == ['__class__', 'arrays',
'formatter', 'io', 'location',
'loop', 'station']


@pytest.mark.usefixtures("experiment")
def test_load_legacy_files_1D():
location = '../fixtures/2018-01-17/#001_testsweep_15-42-57'
dir = os.path.dirname(__file__)
full_location = os.path.join(dir, location)
run_ids = import_dat_file(full_location)
run_id = run_ids[0]
data = load_by_id(run_id)
assert isinstance(data, DataSet)
assert data.parameters == 'dac_ch1_set,dmm_voltage'
assert data.number_of_results == 201
expected_names = ['dac_ch1_set', 'dmm_voltage']
expected_labels = ['Gate ch1', 'Gate voltage']
expected_units = ['V', 'V']
expected_depends_on = ['', 'dac_ch1_set']
for i, parameter in enumerate(data.get_parameters()):
assert parameter.name == expected_names[i]
assert parameter.label == expected_labels[i]
assert parameter.unit == expected_units[i]
assert parameter.depends_on == expected_depends_on[i]
assert parameter.type == 'numeric'
snapshot = json.loads(data.get_metadata('snapshot'))
assert sorted(list(snapshot.keys())) == ['__class__', 'arrays',
'formatter', 'io', 'location',
'loop', 'station']


@pytest.mark.parametrize("bg_writing", [True, False])
@pytest.mark.usefixtures("experiment")
def test_adding_parents(bg_writing, DAC):
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ qcodes =
monitor/dist/css/*
configuration/*.json
instrument/sims/*.yaml
tests/dataset/fixtures/2018-01-17/*/*
tests/dataset/fixtures/data_2018_01_17/*/*
tests/delegate/data/*.yml
tests/drivers/auxiliary_files/*
py.typed
Expand Down

0 comments on commit d38994c

Please sign in to comment.