atomiq.atomiq module#

class atomiq.atomiq.AtomiqExperiment(managers_or_parent, name=None, arg_provider=None, component_map=None, *args, **kwargs)#

Bases: EnvExperiment

CHUNKSIZE = 10#
components = ['log']#
arg_provider = <atomiq.arguments.arguments.NativeArgumentProvider object>#
prepare()#

This default prepare method calls prepare() for all children, in the order of registration, if the child has a prepare() method.

build()#

Should be implemented by the user to request arguments.

Other initialization steps such as requesting devices may also be performed here.

There are two situations where the requested devices are replaced by DummyDevice() and arguments are set to their defaults (or None) instead: when the repository is scanned to build the list of available experiments and when the dataset browser artiq_browser is used to open or run the analysis stage of an experiment. Do not rely on being able to operate on devices or arguments in build().

Datasets are read-only in this method.

Leftover positional and keyword arguments from the constructor are forwarded to this method. This is intended for experiments that are only meant to be executed programmatically (not from the GUI).

chunker(mult_scan, size=100)#

generator to call a kernel with chunks of scan points

Parameters:

size (artiq.compiler.types.TMono('int', OrderedDict([('width', artiq.compiler.types.TValue(32))]))) --

Return type:

TList

run()#

The main entry point of the experiment.

This method must be overloaded by the user to implement the main control flow of the experiment.

This method may interact with the hardware.

The experiment may call the scheduler's pause() method while in run().

prerun()#
prerun_host()#
postrun()#
postrun_host()#
prestep(point)#
poststep(point)#
prechunk(points)#
postchunk(points)#
prechunk_host(points)#
postchunk_host(points)#
step(point)#
analyze()#

Entry point for analyzing the results of the experiment.

This method may be overloaded by the user to implement the analysis phase of the experiment, for example fitting curves.

Splitting this phase from run() enables tweaking the analysis algorithm on pre-existing data, and CPU-bound analyses to be run overlapped with the next experiment in a pipelined manner.

This method must not interact with the hardware.

append_to_dataset(key, value)#

Append a value to a dataset.

The target dataset must be a list (i.e. support append()), and must have previously been set from this experiment.

The broadcast/persist/archive mode of the given key remains unchanged from when the dataset was last set. Appended values are transmitted efficiently as incremental modifications in broadcast mode.

call_child_method(method, *args, **kwargs)#

Calls the named method for each child, if it exists for that child, in the order of registration.

Parameters:
  • method (str) -- Name of the method to call

  • args -- Tuple of positional arguments to pass to all children

  • kwargs -- Dict of keyword arguments to pass to all children

get_argument(key, processor, group=None, tooltip=None)#

Retrieves and returns the value of an argument.

This function should only be called from build.

Parameters:
  • key -- Name of the argument.

  • processor -- A description of how to process the argument, such as instances of BooleanValue and NumberValue.

  • group -- An optional string that defines what group the argument belongs to, for user interface purposes.

  • tooltip -- An optional string to describe the argument in more detail, applied as a tooltip to the argument name in the user interface.

get_dataset(key, default=<class 'artiq.language.environment.NoDefault'>, archive=True)#

Returns the contents of a dataset.

The local storage is searched first, followed by the master storage (which contains the broadcasted datasets from all experiments) if the key was not found initially.

If the dataset does not exist, returns the default value. If no default is provided, raises KeyError.

By default, datasets obtained by this method are archived into the output HDF5 file of the experiment. If an archived dataset is requested more than one time or is modified, only the value at the time of the first call is archived. This may impact reproducibility of experiments.

Parameters:

archive -- Set to False to prevent archival together with the run's results. Default is True.

get_device(key)#

Creates and returns a device driver.

get_device_db()#

Returns the full contents of the device database.

mutate_dataset(key, index, value)#

Mutate an existing dataset at the given index (e.g. set a value at a given position in a NumPy array)

If the dataset was created in broadcast mode, the modification is immediately transmitted.

If the index is a tuple of integers, it is interpreted as slice(*index). If the index is a tuple of tuples, each sub-tuple is interpreted as slice(*sub_tuple) (multi-dimensional slicing).

register_child(child)#
set_dataset(key, value, broadcast=False, persist=False, archive=True)#

Sets the contents and handling modes of a dataset.

Datasets must be scalars (bool, int, float or NumPy scalar) or NumPy arrays.

Parameters:
  • broadcast -- the data is sent in real-time to the master, which dispatches it.

  • persist -- the master should store the data on-disk. Implies broadcast.

  • archive -- the data is saved into the local storage of the current run (archived as a HDF5 file).

set_default_scheduling(priority=None, pipeline_name=None, flush=None)#

Sets the default scheduling options.

This function should only be called from build.

setattr_argument(key, processor=None, group=None, tooltip=None)#

Sets an argument as attribute. The names of the argument and of the attribute are the same.

The key is added to the instance's kernel invariants.

setattr_dataset(key, default=<class 'artiq.language.environment.NoDefault'>, archive=True)#

Sets the contents of a dataset as attribute. The names of the dataset and of the attribute are the same.

setattr_device(key)#

Sets a device driver as attribute. The names of the device driver and of the attribute are the same.

The key is added to the instance's kernel invariants.

class atomiq.atomiq.AtomiqBlock(*args, **kwargs)#

Bases: AtomiqExperiment

CHUNKSIZE = 10#
analyze()#

Entry point for analyzing the results of the experiment.

This method may be overloaded by the user to implement the analysis phase of the experiment, for example fitting curves.

Splitting this phase from run() enables tweaking the analysis algorithm on pre-existing data, and CPU-bound analyses to be run overlapped with the next experiment in a pipelined manner.

This method must not interact with the hardware.

append_to_dataset(key, value)#

Append a value to a dataset.

The target dataset must be a list (i.e. support append()), and must have previously been set from this experiment.

The broadcast/persist/archive mode of the given key remains unchanged from when the dataset was last set. Appended values are transmitted efficiently as incremental modifications in broadcast mode.

arg_provider = <atomiq.arguments.arguments.NativeArgumentProvider object>#
build()#

Should be implemented by the user to request arguments.

Other initialization steps such as requesting devices may also be performed here.

There are two situations where the requested devices are replaced by DummyDevice() and arguments are set to their defaults (or None) instead: when the repository is scanned to build the list of available experiments and when the dataset browser artiq_browser is used to open or run the analysis stage of an experiment. Do not rely on being able to operate on devices or arguments in build().

Datasets are read-only in this method.

Leftover positional and keyword arguments from the constructor are forwarded to this method. This is intended for experiments that are only meant to be executed programmatically (not from the GUI).

call_child_method(method, *args, **kwargs)#

Calls the named method for each child, if it exists for that child, in the order of registration.

Parameters:
  • method (str) -- Name of the method to call

  • args -- Tuple of positional arguments to pass to all children

  • kwargs -- Dict of keyword arguments to pass to all children

chunker(mult_scan, size=100)#

generator to call a kernel with chunks of scan points

Parameters:

size (artiq.compiler.types.TMono('int', OrderedDict([('width', artiq.compiler.types.TValue(32))]))) --

Return type:

TList

components = ['log']#
get_argument(key, processor, group=None, tooltip=None)#

Retrieves and returns the value of an argument.

This function should only be called from build.

Parameters:
  • key -- Name of the argument.

  • processor -- A description of how to process the argument, such as instances of BooleanValue and NumberValue.

  • group -- An optional string that defines what group the argument belongs to, for user interface purposes.

  • tooltip -- An optional string to describe the argument in more detail, applied as a tooltip to the argument name in the user interface.

get_dataset(key, default=<class 'artiq.language.environment.NoDefault'>, archive=True)#

Returns the contents of a dataset.

The local storage is searched first, followed by the master storage (which contains the broadcasted datasets from all experiments) if the key was not found initially.

If the dataset does not exist, returns the default value. If no default is provided, raises KeyError.

By default, datasets obtained by this method are archived into the output HDF5 file of the experiment. If an archived dataset is requested more than one time or is modified, only the value at the time of the first call is archived. This may impact reproducibility of experiments.

Parameters:

archive -- Set to False to prevent archival together with the run's results. Default is True.

get_device(key)#

Creates and returns a device driver.

get_device_db()#

Returns the full contents of the device database.

mutate_dataset(key, index, value)#

Mutate an existing dataset at the given index (e.g. set a value at a given position in a NumPy array)

If the dataset was created in broadcast mode, the modification is immediately transmitted.

If the index is a tuple of integers, it is interpreted as slice(*index). If the index is a tuple of tuples, each sub-tuple is interpreted as slice(*sub_tuple) (multi-dimensional slicing).

postchunk(points)#
postchunk_host(points)#
postrun()#
postrun_host()#
poststep(point)#
prechunk(points)#
prechunk_host(points)#
prepare()#

This default prepare method calls prepare() for all children, in the order of registration, if the child has a prepare() method.

prerun()#
prerun_host()#
prestep(point)#
register_child(child)#
run()#

The main entry point of the experiment.

This method must be overloaded by the user to implement the main control flow of the experiment.

This method may interact with the hardware.

The experiment may call the scheduler's pause() method while in run().

set_dataset(key, value, broadcast=False, persist=False, archive=True)#

Sets the contents and handling modes of a dataset.

Datasets must be scalars (bool, int, float or NumPy scalar) or NumPy arrays.

Parameters:
  • broadcast -- the data is sent in real-time to the master, which dispatches it.

  • persist -- the master should store the data on-disk. Implies broadcast.

  • archive -- the data is saved into the local storage of the current run (archived as a HDF5 file).

set_default_scheduling(priority=None, pipeline_name=None, flush=None)#

Sets the default scheduling options.

This function should only be called from build.

setattr_argument(key, processor=None, group=None, tooltip=None)#

Sets an argument as attribute. The names of the argument and of the attribute are the same.

The key is added to the instance's kernel invariants.

setattr_dataset(key, default=<class 'artiq.language.environment.NoDefault'>, archive=True)#

Sets the contents of a dataset as attribute. The names of the dataset and of the attribute are the same.

setattr_device(key)#

Sets a device driver as attribute. The names of the device driver and of the attribute are the same.

The key is added to the instance's kernel invariants.

step(point)#