qml.transforms.core.transform_program.TransformProgram

class TransformProgram(initial_program=None)[source]

Bases: object

Class that contains a transform program and the methods to interact with it.

The order of execution is the order in the list containing the containers.

The main case where one would have to interact directly with a transform program is when developing a Device. In this case, the pre-processing method of a device returns a transform program. You should directly refer to the device API documentation for more details.

Warning

This class is developer-facing and should not be used directly. Instead, use qml.transform if you would like to make a custom transform.

See also

transform()

has_final_transform

True if the transform program has a terminal transform.

is_informative

True if the transform program is informative.

has_final_transform

True if the transform program has a terminal transform.

is_informative

True if the transform program is informative.

Returns

Boolean

Return type

bool

add_transform(transform, *targs, **tkwargs)

Add a transform (dispatcher) to the end of the program.

get_last()

Get the last transform container.

has_classical_cotransform()

Check if the transform program has some classical cotransforms.

insert_front(transform_container)

Insert the transform container at the beginning of the program.

insert_front_transform(transform, *targs, …)

Add a transform (dispatcher) to the beginning of the program.

is_empty()

Check if the transform program is empty or not.

pop_front()

Pop the transform container at the beginning of the program.

push_back(transform_container)

Add a transform (container) to the end of the program.

add_transform(transform, *targs, **tkwargs)[source]

Add a transform (dispatcher) to the end of the program.

Note that this should be a function decorated with/called by qml.transforms.transform, and not a TransformContainer.

Parameters
  • transform (TransformDispatcher) – The transform to add to the transform program.

  • *targs – Any additional arguments that are passed to the transform.

Keyword Arguments

**tkwargs – Any additional keyword arguments that are passed to the transform.

get_last()[source]

Get the last transform container.

Returns

The last transform in the program.

Return type

TransformContainer

Raises

TransformError – It raises an error if the program is empty.

has_classical_cotransform()[source]

Check if the transform program has some classical cotransforms.

Returns

Boolean

Return type

bool

insert_front(transform_container)[source]

Insert the transform container at the beginning of the program.

Parameters

transform_container (TransformContainer) – A transform represented by its container.

insert_front_transform(transform, *targs, **tkwargs)[source]

Add a transform (dispatcher) to the beginning of the program.

Parameters
  • transform (TransformDispatcher) – The transform to add to the front of the transform program.

  • *targs – Any additional arguments that are passed to the transform.

Keyword Arguments

**tkwargs – Any additional keyword arguments that are passed to the transform.

is_empty()[source]

Check if the transform program is empty or not.

Returns

Boolean, True if empty, False otherwise.

Return type

bool

pop_front()[source]

Pop the transform container at the beginning of the program.

Returns

The transform container at the beginning of the program.

Return type

TransformContainer

push_back(transform_container)[source]

Add a transform (container) to the end of the program.

Parameters

transform_container (TransformContainer) – A transform represented by its container.