labcore.measurement.sweep#

Functions

append_sweeps(first, second)

Append two sweeps.

as_pointer(fun, *data_specs)

Convenient in-line creation of a pointer function.

nest_sweeps(outer, inner)

Nest two sweeps.

null_action()

once(action)

Return a sweep that executes the action once.

pointer(*data_specs)

Create a decorator for functions that return pointer generators.

sweep_parameter(param, sweep_iterable, *actions)

Create a sweep over a parameter.

zip_sweeps(first, second)

Zip two sweeps.

Classes

AppendSweeps(first, second)

AsyncRecord(*specs)

Base class decorator used to record asynchronous data from instrument.

CombineSweeps(first, second)

NestSweeps(first, second)

PointerFunction(func, *data_specs)

A class that allows using a generator function as a pointer.

Sweep(pointer, *actions)

Base class for sweeps.

SweepIterator(sweep, state[, pass_kwargs, ...])

Iterator for the Sweep class.

ZipSweeps(first, second)

class labcore.measurement.sweep.AppendSweeps(first: Sweep, second: Sweep)[source]#

Bases: CombineSweeps

class labcore.measurement.sweep.AsyncRecord(*specs)[source]#

Bases: object

Base class decorator used to record asynchronous data from instrument. Use the decorator with create_background_sweep function to create Sweeps that collect asynchronous data from external devices running experiments independently of the measurement PC, e.i. the measuring happening is not being controlled by a Sweep but instead an external device (e.g. the OPX). Each instrument should have its own custom setup_wrapper (see setup_wrapper docstring for more info), and a custom collector. Auxiliary functions for the start_wrapper and collector should also be located in this class.

Parameters:

specs – A list of the DataSpecs to record the data produced.

collect(*args, **kwargs) Generator[Dict, None, None][source]#
setup(fun, *args, **kwargs)[source]#
wrap_setup(fun: Callable, *args: Any, **kwargs: Any) Callable[source]#

Wraps the start function. setup_wrapper should consist of another function inside of it decorated with @wraps with fun as its argument. In this case the wrapped function is setup. Setup should accept the *args and **kwargs of fun. It should also place any returns from fun in the communicator. setup_wrapper needs to return the wrapped function (setup).

Parameters:

fun – The measurement function. In the case of the OPX this would be the function that returns the QUA code with any arguments that it might use.

wrapped_setup: Callable#
class labcore.measurement.sweep.CombineSweeps(first: Sweep, second: Sweep)[source]#

Bases: object

get_data_specs()[source]#
class labcore.measurement.sweep.NestSweeps(first: Sweep, second: Sweep)[source]#

Bases: CombineSweeps

class labcore.measurement.sweep.PointerFunction(func, *data_specs)[source]#

Bases: FunctionToRecords

A class that allows using a generator function as a pointer.

get_data_specs()[source]#
using(*args, **kwargs) PointerFunction[source]#

Set the default positional and keyword arguments that will be used when the function is called.

Returns:

A copy of the object. This is to allow setting different defaults to multiple uses of the function.

class labcore.measurement.sweep.Sweep(pointer: Iterable | None, *actions: Callable)[source]#

Bases: object

Base class for sweeps.

Can be iterated over; for each pointer value the associated actions are executed. Each iteration step produces a record, containing all values produced by pointer and actions that have been annotated as such. (see: record_as())

Parameters:
  • pointer – An iterable that defines the steps over which we iterate

  • actions – A variable number of functions. Each will be called for each iteration step, with the pointer value(s) as arguments, provided the function can accept it.

property action_kwargs#
append_action(action: Callable)[source]#

Add an action to the sweep.

static copy_sweep_options(src: Sweep, target: Sweep | None)[source]#
get_data_specs() Tuple[DataSpec, ...][source]#

Return the data specs of the sweep.

Share state properties between sweeps.

property pass_kwargs#
pass_on_none = False#
pass_on_returns = True#
static propagate_sweep_options(sweep: Sweep)[source]#
record_none = True#
run() SweepIterator[source]#

Create the iterator for the sweep.

set_options(**action_kwargs: Dict[str, Any])[source]#

Configure the sweep actions.

Parameters:

action_kwargs – Keyword arguments to pass to action functions format: {‘<action_name>’: {‘key’: ‘value’} <action_name> is what action_function.__name__ returns.

property state#
static update_option_dict(src: Dict[str, Any], target: Dict[str, Any], level: int) None[source]#

Rules: work in progress :).

class labcore.measurement.sweep.SweepIterator(sweep: Sweep, state: Dict[str, Any], pass_kwargs=typing.Dict[str, typing.Any], action_kwargs=typing.Dict[str, typing.Dict[str, typing.Any]])[source]#

Bases: object

Iterator for the Sweep class.

Manages the actual iteration of the pointer, and the execution of action functions. Manages and updates the state of the sweep.

class labcore.measurement.sweep.ZipSweeps(first: Sweep, second: Sweep)[source]#

Bases: CombineSweeps

labcore.measurement.sweep.append_sweeps(first: Sweep, second: Sweep) Sweep[source]#

Append two sweeps.

Iteration over the combined sweep will first complete the first sweep, then the second sweep.

labcore.measurement.sweep.as_pointer(fun: Callable, *data_specs: str | Tuple[str, None | List[str] | Tuple[str], str, str] | Dict[str, str | None | List[str] | Tuple[str]] | DataSpec) PointerFunction[source]#

Convenient in-line creation of a pointer function.

labcore.measurement.sweep.nest_sweeps(outer: Sweep, inner: Sweep) Sweep[source]#

Nest two sweeps.

Iteration over the combined sweep will execute the full inner sweep for each iteration step of the outer sweep.

labcore.measurement.sweep.null_action()[source]#
labcore.measurement.sweep.once(action: Callable) Sweep[source]#

Return a sweep that executes the action once.

labcore.measurement.sweep.pointer(*data_specs: str | Tuple[str, None | List[str] | Tuple[str], str, str] | Dict[str, str | None | List[str] | Tuple[str]] | DataSpec) Callable[source]#

Create a decorator for functions that return pointer generators.

labcore.measurement.sweep.sweep_parameter(param: str | Parameter | Tuple[str, None | List[str] | Tuple[str], str, str] | DataSpec, sweep_iterable: Iterable, *actions: Callable) Sweep[source]#

Create a sweep over a parameter.

Parameters:
  • param

    One of:

    • A string: Generates an independent, scalar data parameter.

    • A tuple or list: will be passed to the constructor of DataSpec; see make_data_spec().

    • A DataSpec instance.

    • A qcodes parameter. In this case the parameter’s set method is called for each value during the iteration.

  • sweep_iterable – An iterable that generates the values the parameter will be set to.

  • actions – An arbitrary number of action functions.

labcore.measurement.sweep.zip_sweeps(first: Sweep, second: Sweep) Sweep[source]#

Zip two sweeps.

Iteration over the combined sweep will elementwise advance the two sweeps together.