API documentation

Module for conversion between PyZX and tket primitives.

pytket.extensions.pyzx.pyzx_to_tk(pyzx_circ)[source]

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

Parameters:

pyzx_circ (Circuit) – A circuit to be converted

Return type:

Circuit

Returns:

The converted circuit

pytket.extensions.pyzx.pyzx_to_tk_arc(pyzx_arc)[source]

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

Parameters:

pytket_arc – A Architecture to be converted

Return type:

Architecture

Returns:

The converted pyzx Architecture

pytket.extensions.pyzx.pyzx_to_tk_placed_circ(pyzx_circ, q_map)[source]

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 (Circuit) – A circuit to be converted

  • q_map (Dict[UnitID, UnitID]) – 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

Return type:

Circuit

Returns:

The converted pytket circuit

pytket.extensions.pyzx.tk_to_pyzx(tkcircuit, denominator_limit=1000000)[source]

Convert a tket Circuit to a pyzx.Circuit.

Parameters:
  • tkcircuit (Circuit) – A circuit to be converted

  • denominator_limit (int) – 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.

Return type:

Circuit

Returns:

The converted circuit

pytket.extensions.pyzx.tk_to_pyzx_arc(pytket_arc, pyzx_arc_name='')[source]

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 (Architecture) – A Architecture to be converted

  • pyzx_arc_name (str) – Name of the architecture in pyzx

Return type:

Architecture

Returns:

The converted pyzx Architecture

pytket.extensions.pyzx.tk_to_pyzx_placed_circ(pytket_circ, pytket_arc, denominator_limit=1000000, pyzx_arc_name='')[source]

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 (Circuit) – A circuit to be converted

  • pytket_arc (Architecture) – Corresponding Architecture

  • denominator_limit (int) – 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 (str) – Name of the architecture in pyzx

Return type:

Tuple[Architecture, Circuit, Dict[UnitID, UnitID]]

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

)