Circuit
A variational circuit: an ordered sequence of exponential gates, angles, and a state.
All gates must share a family (see ExpGate). Empty parameters means unbound; a
bound circuit needs exactly n_parameters values.
The per-gate index values give the parameter mapping: with none set, each gate gets its
own angle in order; otherwise every gate must set a contiguous 0..n-1 index, and gates
sharing an index share an angle.
Attributes
attribute_state_given= initial_state is not Noneattributegates= gatesThe ordered exponential gates.
attributeparameters= parametersThe angle values, or empty for an unbound circuit.
attributeinitial_state= initial_stateThe reference state (occupied mode / qubit indices).
attributefamily= self._resolve_family(gates)"pauli", "majorana", or "empty"; the propagators dispatch on it.
attribute__hash__= Noneattributeresolved_mappingtuple[int, ...]Per-gate angle index, derived from each gate's index (see Circuit).
attributen_parametersintNumber of distinct variational angles the circuit references.
Functions
func__init__(self, gates=(), parameters=(), initial_state=None) -> NoneBuild the circuit, dropping identity gates and validating family/mapping/params.
paramselfparamgatesSequence[ExpGate]= ()The ordered exponential gates.
paramparametersSequence[float]= ()The angle values, or empty for an unbound circuit.
paraminitial_stateSequence[int] | None= NoneThe reference state (occupied mode / qubit indices), or None to
defer to the propagator's. () is not None: it is the explicit vacuum,
and a propagator built against a different reference rejects it.
Returns
Nonefunc__eq__(self, other) -> boolEqual when gates, parameters, and initial state match (family is derived).
paramselfparamotherobjectReturns
boolfunc__repr__(self) -> strReturn a string representation listing the gates, parameters, and initial state.
paramselfReturns
strfunc__len__(self) -> intNumber of gates.
paramselfReturns
intfunc__iter__(self) -> Iterator[ExpGate]Iterate over the gates in application order.
paramselfReturns
collections.abc.Iterator[monoprop.circuit.ExpGate]func__add__(self, other) -> CircuitConcatenate two circuits of the same family, appending other's angles.
other's angle indices are shifted up by self.n_parameters, so the two halves keep
independent angles and every gate in the result gets an explicit index. Prefer one
MonomialPropagator.build_graph call over
incremental multi-call building, whose ordering is picture-dependent.
paramselfparamotherCircuitReturns
monoprop.circuit.Circuitfuncfrom_dense_arrays(cls, majoranas, gen_coeffs, param_inds, parameters=(), initial_state=None) -> CircuitBuild a Majorana circuit from flat, per-monomial dense arrays.
The native dense/wire format (also the on-disk msgpack-fixture layout): consecutive
monomials sharing a param_ind become one Majorana ExpGate with that
param_ind as its index, so weight-tying is preserved and the expanded engine
arrays stay identical.
paramclsparammajoranasSequence[Sequence[int]]One Majorana-index sequence per monomial.
paramgen_coeffsSequence[float]Generator coefficient per monomial (already structural).
paramparam_indsSequence[int]Variational-angle index per monomial; contiguous runs group into gates.
paramparametersSequence[float]= ()Optional angle values.
paraminitial_stateSequence[int] | None= NoneReference state (occupied mode indices), or None to defer to the
propagator's. () is the explicit vacuum, exactly as in the constructor -- the
wire format has no third state, so a caller round-tripping it decides which of the
two an absent field means.
Returns
monoprop.circuit.Circuit