Open mariaschuld opened 2 years ago
Hamiltonian coefficients are now shown only when there is less than three coefficients:
0: ───┤ ╭<𝓗(1.00,1.00,1.00)>
1: ───┤ ├<𝓗(1.00,1.00,1.00)>
2: ───┤ ╰<𝓗(1.00,1.00,1.00)>
For greater than 3, only a simple 𝓗
is displayed.
0: ───┤ ╭<𝓗>
1: ───┤ ├<𝓗>
2: ───┤ ├<𝓗>
3: ───┤ ╰<𝓗>
We could cache the hamiltonian and display it below similar to how we handle matrices, but I think this is currently sufficient.
How the Hamiltonian is displayed is now the responsibility of the label
method.
Since Hamiltonians are now observables with differentiable coefficients, drawing a circuit with a Hamiltonian looks as follows:
However, information about the observables is not shown. Instead we could use the solution of how arbitrary unitaries get printed below the circuit:
This would require an update in
qml.circuit_drawer.representation_resolver
which mimics the behaviour ofQubitUnitary
.Useful info: The Hamiltonian class defines a
__str__()
method which prints an abbreviated string such asHamiltonian(terms=2, wires=[0,1])
and a__repr__()
method for the full information. The latter is probably what we want here.