コード例 #1
0
def test_get_ds_info(experiment):
    N = 5

    m = qc.Measurement(exp=experiment)

    m.register_custom_parameter('x', unit='cm')
    m.register_custom_parameter('y')
    m.register_custom_parameter('foo')
    for n in range(N):
        m.register_custom_parameter(f'z_{n}', setpoints=['x', 'y'])

    with m.run() as datasaver:
        dataset = datasaver.dataset

        ds_info_with_empty_timestamps = get_ds_info(dataset,
                                                    get_structure=False)
        assert ds_info_with_empty_timestamps['completed_date'] == ''
        assert ds_info_with_empty_timestamps['completed_time'] == ''

    # timestamps are difficult to test for, so we will cheat here and
    # instead of hard-coding timestamps we will just get them from the dataset
    # The same applies to the guid as it contains the timestamp
    started_ts = dataset.run_timestamp()
    completed_ts = dataset.completed_timestamp()

    expected_ds_info = {
        'experiment': '2d_softsweep',
        'sample': 'no sample',
        'completed_date': completed_ts[:10],
        'completed_time': completed_ts[11:],
        'started_date': started_ts[:10],
        'started_time': started_ts[11:],
        'name': 'results',
        'structure': None,
        'records': 0,
        'guid': dataset.guid,
        'inspectr_tag': ''
    }

    ds_info = get_ds_info(dataset, get_structure=False)

    assert ds_info == expected_ds_info

    expected_ds_info_with_structure = expected_ds_info.copy()
    expected_ds_info_with_structure['structure'] = get_ds_structure(dataset)

    ds_info_with_structure = get_ds_info(dataset)

    assert ds_info_with_structure == expected_ds_info_with_structure
コード例 #2
0
def test_get_ds_structure(experiment):
    N = 5

    m = qc.Measurement(exp=experiment)
    m.register_custom_parameter('x', unit='cm', label='my_x_param')
    m.register_custom_parameter('y')

    # check that unused parameters don't mess with
    m.register_custom_parameter('foo')

    for n in range(N):
        m.register_custom_parameter(f'z_{n}', setpoints=['x', 'y'])

    with m.run() as datasaver:
        dataset = datasaver.dataset

    # test dataset structure function
    expected_structure = {
        'x': {
            'unit': 'cm',
            'label': 'my_x_param',
            'values': []
        },
        'y': {
            'unit': '',
            'label': '',
            'values': []
        }
        # note that parameter 'foo' is not expected to be included
        # because it's a "standalone" parameter
    }
    for n in range(N):
        expected_structure.update({
            f'z_{n}': {
                'unit': '',
                'label': '',
                'axes': ['x', 'y'],
                'values': []
            }
        })
    structure = get_ds_structure(dataset)
    assert structure == expected_structure