Skip to content

Python wrappers / utility functions #11

@bjader

Description

@bjader

Ideally we would have our examples have minimal calls to the Julia namespace. For a Python user, each call to jl.foo() requires knowing the function name, arguments and behaviour up-front, since an IDE won't be able to link this to corresponding Julia function. Furthermore, boilerplate code such as:

qc = transpile(qc, backend=backend, basis_gates=list(SUPPORTED_GATES))

circuit, edges = circuit_description(qc)

qmap = graph_to_grid(graph_from_edges(edges))

# Set tensor network truncation parameters
chi = 4
cutoff = 1e-12

psi_bpc, errors = jl.tn_from_circuit(circuit, qmap, edges, chi, cutoff)

Could all be replaced by a Python function that executes all the above with helpful argument names and documentation:

def tn_from_circuit(circuit: QuantumCircuit, chi, cutoff))
    qc = transpile(qc, backend=backend, basis_gates=list(SUPPORTED_GATES))
    circuit, edges = circuit_description(qc)
    qmap = graph_to_grid(graph_from_edges(edges))
    return jl.tn_from_circuit(circuit, qmap, edges, chi, cutoff)

A similar change could be made for having to call to:

obs_jl = jl.translate_observable(observable_description(obs), qmap)
z_eval = np.real(jl.expect(psi_bpc, obs_jl))

for any expectation value

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions