API documentation#

Module for conversion between PyZX and tket primitives.

pytket.extensions.pyzx.pyzx_to_tk(pyzx_circ: Circuit) Circuit#

Convert a pyzx.Circuit to a tket Circuit . Run pyzx_circuit_name.to_basic_gates() before conversion.

Parameters:

pyzx_circ – A circuit to be converted

Returns:

The converted circuit

pytket.extensions.pyzx.pyzx_to_tk_arc(pyzx_arc: Architecture) Architecture#

Convert a pyzx pyzx.routing.architecture.Architecture to a pytket Architecture .

Parameters:

pytket_arc – A Architecture to be converted

Returns:

The converted pyzx Architecture

pytket.extensions.pyzx.pyzx_to_tk_placed_circ(pyzx_circ: Circuit, q_map: Dict[UnitID, UnitID]) Circuit#

Convert a pyzx.Circuit and a placment map to a placed tket Circuit . Run pyzx_circuit_name.to_basic_gates() before conversion.

Parameters:
  • pyzx_circ – A circuit to be converted

  • q_map – placment map to assign each of the qubits in the pyzx circuit to one of the architecture nodes. It is recommended to use here the map generated by tk_to_pyzx_placed_circ

Returns:

The converted pytket circuit

pytket.extensions.pyzx.tk_to_pyzx(tkcircuit: Circuit, denominator_limit: int = 1000000) Circuit#

Convert a tket Circuit to a pyzx.Circuit.

Parameters:
  • tkcircuit – A circuit to be converted

  • denominator_limit – The limit for denominator size when converting floats to fractions. Smaller limits allow for correct representation of simple fractions with non-exact floating-point representations, while larger limits allow for more precise angles.

Returns:

The converted circuit

pytket.extensions.pyzx.tk_to_pyzx_arc(pytket_arc: Architecture, pyzx_arc_name: str = '') Architecture#

Convert a pytket Architecture to a pyzx pyzx.routing.architecture.Architecture . The conversion will remove all the node names and will keep them only integer named in the order they are given in the node set of pytket_arc.

Parameters:
  • pytket_arc – A Architecture to be converted

  • pyzx_arc_name – Name of the architecture in pyzx

Returns:

The converted pyzx Architecture

pytket.extensions.pyzx.tk_to_pyzx_placed_circ(pytket_circ: Circuit, pytket_arc: Architecture, denominator_limit: int = 1000000, pyzx_arc_name: str = '') Tuple[Architecture, Circuit, Dict[UnitID, UnitID]]#

Convert a (placed) tket Circuit with a given Architecture to a pyzx.Circuit and the pyzx.routing.architecture.Architecture and a map to give the information for converting the pyzx circuit back to pytket circuit using pyzx_to_tk_placed_circ assigning each of the circuit qubits a one of the architecture nodes

Parameters:
  • pytket_circ – A circuit to be converted

  • pytket_arc – Corresponding Architecture

  • denominator_limit – The limit for denominator size when converting floats to fractions. Smaller limits allow for correct representation of simple fractions with non-exact floating-point representations, while larger limits allow for more precise angles.

  • pyzx_arc_name – Name of the architecture in pyzx

Returns:

Tuple containing generated pyzx.Circuit , pyzx.routing.architecture.Architecture and a map to give the information for converting the pyzx circuit back to pytket circuit using pyzx_to_tk_placed_circ assigning each of the circuit qubits a one of the architecture nodes

)