def test_nest_3d(indep_params, dep_params): px, x, tablex = indep_params["x"] py, y, tabley = indep_params["y"] pz, z, tablez = indep_params["z"] def f(vx, vy, vz): return vx**2 + vy**2 + vz**2 pi, i, tablei = dep_params["i"] pi.get = lambda: f(px(), py(), pz()) sweep_values_x = [0, 1, 2] sweep_values_y = [5, 6, 7] sweep_values_z = [8, 9, 10] nest = Nest(Sweep(x, tablex, lambda: sweep_values_x), Sweep(y, tabley, lambda: sweep_values_y), Sweep(z, tablez, lambda: sweep_values_z), Measure(i, tablei)) meas = SweepMeasurement() meas.register_sweep(nest) interdeps = meas._interdeps assert interdeps.dependencies == { ParamSpecBase('i', 'numeric', '', ''): (ParamSpecBase('x', 'numeric', '', ''), ParamSpecBase('y', 'numeric', '', ''), ParamSpecBase('z', 'numeric', '', '')) } assert interdeps.inferences == {} assert interdeps.standalones == set()
def do_experiment(experiment_name, sweep_object, setup=None, cleanup=None, station=None, live_plot=False): if "/" in experiment_name: experiment_name, sample_name = experiment_name.split("/") else: sample_name = None try: experiment = load_experiment_by_name(experiment_name, sample_name) except ValueError: # experiment does not exist yet db_location = qcodes.config["core"]["db_location"] DataSet(db_location) experiment = new_experiment(experiment_name, sample_name) def add_actions(action, callables): if callables is None: return for cabble in np.atleast_1d(callables): if not isinstance(cabble, tuple): cabble = (cabble, ()) action(*cabble) if live_plot: try: from plottr.qcodes_dataset import QcodesDatasetSubscriber from plottr.tools import start_listener start_listener() except ImportError: warn("Cannot perform live plots, plottr not installed") live_plot = False meas = SweepMeasurement(exp=experiment, station=station) meas.register_sweep(sweep_object) add_actions(meas.add_before_run, setup) add_actions(meas.add_after_run, cleanup) with meas.run() as datasaver: if live_plot: datasaver.dataset.subscribe(QcodesDatasetSubscriber( datasaver.dataset), state=[], min_wait=0, min_count=1) for data in sweep_object: datasaver.add_result(*data.items()) return _DataExtractor(datasaver)
def test_sweep_parameter(indep_params): px, x, table = indep_params["x"] sweep_values = [0, 1, 2] parameter_sweep = Sweep(x, table, lambda: sweep_values) meas = SweepMeasurement() meas.register_sweep(parameter_sweep) interdeps = meas._interdeps assert interdeps.dependencies == {} assert interdeps.inferences == {} assert interdeps.standalones == {ParamSpecBase('x', 'numeric', '', '')}
def test_nest_in_chain_2_whatever(indep_params, dep_params): px, x, tablex = indep_params["x"] pi, i, tablei = dep_params["i"] pj, j, tablej = dep_params["j"] sweep_values = [0, 1, 2] sweep_object = Nest(Sweep(x, tablex, lambda: sweep_values), Chain(Measure(i, tablei))) meas = SweepMeasurement() meas.register_sweep(sweep_object) interdeps = meas._interdeps assert interdeps.dependencies == { ParamSpecBase('i', 'numeric', '', ''): (ParamSpecBase('x', 'numeric', '', ''), ) } assert interdeps.inferences == {} assert interdeps.standalones == set()
def test_chain_simple(indep_params): px, x, tablex = indep_params["x"] py, y, tabley = indep_params["y"] sweep_values_x = [0, 1, 2] sweep_values_y = [4, 5, 6] parameter_sweep = Chain(Sweep(x, tablex, lambda: sweep_values_x), Sweep(y, tabley, lambda: sweep_values_y)) meas = SweepMeasurement() meas.register_sweep(parameter_sweep) interdeps = meas._interdeps assert interdeps.dependencies == {} assert interdeps.inferences == {} assert interdeps.standalones == { ParamSpecBase('y', 'numeric', '', ''), ParamSpecBase('x', 'numeric', '', '') }
def test_interleave_1d_2d(indep_params, dep_params): px, x, tablex = indep_params["x"] py, y, tabley = indep_params["y"] pi, i, tablei = dep_params["i"] pj, j, tablej = dep_params["j"] def f(vx): return vx ** 2 pi.get = lambda: f(px()) def g(vx, vy): return vx ** 2 + vy ** 2 pj.get = lambda: g(px(), py()) sweep_values_x = [0, 1, 2] sweep_values_y = [4, 5, 6] sweep_object = Nest( Sweep(x, tablex, lambda: sweep_values_x), Chain( Measure(i, tablei), Nest( Sweep(y, tabley, lambda: sweep_values_y), Measure(j, tablej) ) ) ) meas = SweepMeasurement() meas.register_sweep(sweep_object) interdeps = meas._interdeps assert interdeps.dependencies == { ParamSpecBase('i', 'numeric', '', ''): (ParamSpecBase('x', 'numeric', '', ''),), ParamSpecBase('j', 'numeric', '', ''): (ParamSpecBase('x', 'numeric', '', ''), ParamSpecBase('y', 'numeric', '', ''))} assert interdeps.inferences == {} assert interdeps.standalones == set()
def test_nest(indep_params, dep_params): px, x, tablex = indep_params["x"] pi, i, tablei = dep_params["i"] def f(value): return value**2 pi.get = lambda: f(px()) sweep_values = [0, 1, 2] nest = Nest(Sweep(x, tablex, lambda: sweep_values), Measure(i, tablei)) meas = SweepMeasurement() meas.register_sweep(nest) interdeps = meas._interdeps assert interdeps.dependencies == { ParamSpecBase('i', 'numeric', '', ''): (ParamSpecBase('x', 'numeric', '', ''), ) } assert interdeps.inferences == {} assert interdeps.standalones == set()