Skip to content

builder.circuit is not an instance of a perceval ACircuit #146

@alexiasalavrakos

Description

@alexiasalavrakos

Describe the bug
In the Your First Quantum Layer notebook, at the end, a perceval experiment is based on a circuit obtained with the circuit builder. An error is raised, I believe because the circuit is not an instance of a perceval ACircuit

To Reproduce

from merlin.builder import CircuitBuilder
import perceval as pcvl
builder = CircuitBuilder(n_modes=6)
circuit = builder.circuit
experiment = pcvl.Experiment(circuit)

Observed results
ValueError: The number of modes should be a strictly positive integer (got Circuit(n_modes=6, components=0))

Expected behavior
The last line should run without errors.

Additional context
I then tried

from perceval.components.linear_circuit import Circuit, ACircuit
isinstance(circuit, ACircuit)

I believe the issue comes from there, because of the if loop in perceval's Experiment class, line 134 which calls
if isinstance(m_circuit, ACircuit):

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