qml.noise.partial_wires

partial_wires(operation, *args, **kwargs)[source]

Builds a partial function based on the given operation with all argument frozen except wires.

Parameters
  • operation (Operation, class) – Instance of an operation or the class corresponding to the operation.

  • *args – Positional arguments provided in the case where the keyword argument operation is a class for building the partially evaluated instance.

  • **kwargs – Keyword arguments for the building the partially evaluated instance. These will override any arguments present in the operation instance or args.

Returns

A wrapper function that accepts a sequence of wires as an argument or any object with a wires property.

Return type

callable

Raises

ValueError – If args are provided when the given operation is an instance.

Example

One may give an instance of Operation for the operation argument:

>>> func = qml.noise.partial_wires(qml.RX(1.2, [12]))
>>> func(2)
qml.RX(1.2, wires=[2])
>>> func(qml.RY(1.0, ["wires"]))
qml.RX(1.2, wires=["wires"])

Additionally, an Operation class can also be provided, while providing required positional arguments via args:

>>> func = qml.noise.partial_wires(qml.RX, 3.2, [20])
>>> func(qml.RY(1.0, [0]))
qml.RX(3.2, wires=[0])

Finally, one can also use kwargs instead of positional arguments:

>>> func = qml.noise.partial_wires(qml.RX, phi=1.2)
>>> func(qml.RY(1.0, [2]))
qml.RX(1.2, wires=[2])
>>> rfunc = qml.noise.partial_wires(qml.RX(1.2, [12]), phi=2.3)
>>> rfunc(qml.RY(1.0, ["light"]))
qml.RX(2.3, wires=["light"])