atomiq.helper

Functions

normalize_component_name(name)

get_module(path[, relative_path])

get_class_by_name(name[, relative_path])

Resolve class by name

rec_getattr(obj, attr)

Get object's attribute. May use dot notation.

random_ascii_string(length)

file_from_url(url)

Load content from a file specified by a URL.

component_dict(component)

Extract the required information (id, type) from the entries of a component list defined

component_data(component_dict)

block_dict(blockdef)

Extract the required information (class, map) from the entries of a block list defined

replace_member(obj, target, replacement)

Replace a member (target) of an object (obj) with a different member (replacement). This is useful to change

identity_float(x)

identity_int32(x)

identity_float_int32(x)

isnan(x)

Check whether a float is NaN.

less_than_uint32(x, y)

Helper function to compare two unsigned int32 bit register x and y values which are a int32 (x<y).

unsigned_bitshift32(x, bits)

Implemets a right bitshift operation on an signed int32 (as supported by the artiq kernel) which encodes an

master_ipc_call(experiment, action)

Return a method to call the artiq master through internal IPC communication

dummy_decorator(func)

Module Contents

atomiq.helper.normalize_component_name(name)[source]
Return type:

str

atomiq.helper.get_module(path, relative_path=None)[source]
atomiq.helper.get_class_by_name(name, relative_path=None)[source]

Resolve class by name

Parameters:

name -- (str) "%s.%s" % (module.name, class.name)

Returns:

(class)

atomiq.helper.rec_getattr(obj, attr)[source]

Get object's attribute. May use dot notation.

>>> class C(object): pass
>>> a = C()
>>> a.b = C()
>>> a.b.c = 4
>>> rec_getattr(a, 'b.c')
4
atomiq.helper.random_ascii_string(length)[source]
atomiq.helper.file_from_url(url)[source]

Load content from a file specified by a URL.

This can be every type of URL supported by pythons urllib (e.g. http://, file://, etc ). Giving the basic auth credentials in the URL in the form http://user:password@hostname:port/path is supported.

Returns:

file handle on the file

Parameters:

url (str)

Return type:

io.IOBase

atomiq.helper.component_dict(component)[source]

Extract the required information (id, type) from the entries of a component list defined in an AtomiqBlock/AtomiqExperiment

We allow entries in a components list of AtomiqExperiment/AtomiqBlock to be either just strings specifying the id of the component or tuples of the form (id, type) to require a specific type of the component with the given id. The type can also be a superclass of the specified component.

Parameters:

component (Union[str, tuple]) -- entry of the component list

Returns:

dictionary with keys "id" and and "type"

Return type:

dict

atomiq.helper.component_data(component_dict)[source]
Parameters:

component_dict (dict)

Return type:

Union[str, tuple]

atomiq.helper.block_dict(blockdef)[source]

Extract the required information (class, map) from the entries of a block list defined in an AtomiqBlock/AtomiqExperiment

We allow entries in a blocks list of AtomiqExperiment/AtomiqBlock to be either just strings specifying the class of the AtomiqBlock to be imported or tuples of the form (class, ,map) to specify a mapping of the components in the experiment to the components in the block.

Parameters:

blockdef (Union[str, tuple]) -- entry of the blocks list

Returns:

dictionary with keys "class", "map", and "alias"

Return type:

dict

atomiq.helper.replace_member(obj, target, replacement)[source]

Replace a member (target) of an object (obj) with a different member (replacement). This is useful to change member functions of components at construction of the object depending on the configuration.

when running the legacy artiq compiler, every object has its own class and we can/have to modify the class. Otherwise, we just alter the object itself.

Parameters:
  • target (str)

  • replacement (str)

atomiq.helper.identity_float(x)[source]
Parameters:

x (artiq.language.types.TFloat)

Return type:

artiq.language.types.TFloat

atomiq.helper.identity_int32(x)[source]
Parameters:

x (artiq.language.types.TInt32)

Return type:

artiq.language.types.TInt32

atomiq.helper.identity_float_int32(x)[source]
Parameters:

x (artiq.language.types.TFloat)

Return type:

artiq.language.types.TInt32

atomiq.helper.isnan(x)[source]

Check whether a float is NaN.

We cannot use math.isnan or numpy.isnan in the core, so we use IEEE 754 and do it by hand.

Parameters:

x (artiq.language.types.TFloat)

Return type:

artiq.language.types.TBool

atomiq.helper.less_than_uint32(x, y)[source]

Helper function to compare two unsigned int32 bit register x and y values which are a int32 (x<y). This is a necessary workaround as the ARTIQ kernel does not support unsigned integers.

Parameters:
  • x (artiq.language.types.TInt32)

  • y (artiq.language.types.TInt32)

Return type:

artiq.language.types.TBool

atomiq.helper.unsigned_bitshift32(x, bits)[source]

Implemets a right bitshift operation on an signed int32 (as supported by the artiq kernel) which encodes an unsigned uint32 value.

Parameters:
  • x (artiq.language.types.TInt32)

  • bits (artiq.language.types.TInt32)

Return type:

artiq.language.types.TInt32

atomiq.helper.master_ipc_call(experiment, action)[source]

Return a method to call the artiq master through internal IPC communication

Parameters:
  • experiment -- The artiq/atomiq experiment object

  • action (str) -- action in the master process to call with this function

Returns:

Method that calles the requested RPC endpoint in the master

atomiq.helper.dummy_decorator(func)[source]