-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
What should we add?
It would be very convenient to have a draw
method for the Operator
class similar to what is available for the Statevector
and DensityMatrix
classes. A good start would be to just add text representations (repr
, text
, latex_source
and latex
), but more could be added later if needed, like a visual representation of Pauli decompositions, cityscape plot of the op matrix, etc. (I believe the state visualizations work for operators as well, so some of these will be minimal work too).
Having this feature will also allow the user to set a predefine way of displaying things locally in the user config file. Not sure if this would have to be a separate PR since it will require its own testing, release notes, etc.
I can implement this if there is any interest. I would just need some guidance on what would be the best way to organize the code. In the case of the Statevector
class, the draw
method calls the state_drawer
function which lives under visualization.state_visualization
. Not sure if for Operator
something similar would have to be done, or if everything could just be defined under the draw
method itself since a __repr__
method already exists, and latex_source
and latex
only need to call the array_to_latex
function.
The only representation remaining would be text
, which ideally could be implemented just by reusing the visualization.state_visualization.TextMatrix
class, but currently this does not support operators. This line errors out because the Operator
class does not have a .dims
attribute, so either that would need to be modified, or a __str__
method could be defined for Operator
and simply use that.