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 tketCircuit
. Run pyzx_circuit_name.to_basic_gates() before conversion.- Parameters:
pyzx_circ (
Circuit
) – A circuit to be converted- Return type:
- Returns:
The converted circuit
- pytket.extensions.pyzx.pyzx_to_tk_arc(pyzx_arc)[source]¶
Convert a pyzx
pyzx.routing.architecture.Architecture
to a pytketArchitecture
.- Parameters:
pytket_arc – A Architecture to be converted
- Return type:
- 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 tketCircuit
. Run pyzx_circuit_name.to_basic_gates() before conversion.- Parameters:
- Return type:
- Returns:
The converted pytket circuit
- pytket.extensions.pyzx.tk_to_pyzx(tkcircuit, denominator_limit=1000000)[source]¶
Convert a tket
Circuit
to apyzx.Circuit
.- Parameters:
tkcircuit (
Circuit
) – A circuit to be converteddenominator_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 pyzxpyzx.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 convertedpyzx_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 givenArchitecture
to apyzx.Circuit
and thepyzx.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 convertedpytket_arc (
Architecture
) – Corresponding Architecturedenominator_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:
- 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
)