-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow wire_options
per wire MPL drawers
#6165
Comments
Dear @dwierichs , I am new to the community and hope to find some good first issue to contribute. If this issue is not yet taken by other people, could I possibly work on it and later submit a PR? I worked a lot on MPS and hope to improve a bit on this part. Maybe later adding similar features to MERA related implementations. |
Hi @zazabap |
@zazabap I discussed internally, and I added details to the issue description of how the user interface (UI) should look for this feature. Would you like to work on it? :) Let me know in case you have any questions! |
Thanks a lot for the internal discussion! I will start a pull request and work on it. The rest of the fix and new features will attribute to #6486 |
**Context:** On the level of mid-scale algorithms, it might be nice to differentiate between different "types" of wires, for example by coloring them differently, or giving them distinct line styles. As an example, in PennyLaneAI/qml#1185 on preparing matrix product states, there are auxiliary bond qubits and physical qubits, and coloring them differently would be a neat thing to do. **Description of the Change:** Update the output wire_options that could change the line style and color for circuit output. ```python @qml.qnode(qml.device("default.qubit")) def node(x): for w in range(5): qml.Hadamard(w) return qml.expval(qml.PauliZ(0) @ qml.PauliY(1)) # Make all wires cyan and bold, # except for wires 2 and 6, which are dashed and another color wire_options = {"color": "cyan", "linewidth": 5, 2: {"linestyle": "--", "color": "red"}, 6: {"linestyle": "--", "color": "orange"} } _,ax = qml.draw_mpl(node, wire_options=wire_options)(0.52) ``` **Benefits:** When complicated sates and quantum circuits diagram are created, wires could be marked with different selections. **Possible Drawbacks:** N/A **Related GitHub Issues:** #6165 --------- Co-authored-by: David Wierichs <[email protected]> Co-authored-by: ringo-but-quantum <> Co-authored-by: Astral Cai <[email protected]> Co-authored-by: Christina Lee <[email protected]>
Closed by #6486 |
**Context:** On the level of mid-scale algorithms, it might be nice to differentiate between different "types" of wires, for example by coloring them differently, or giving them distinct line styles. As an example, in PennyLaneAI/qml#1185 on preparing matrix product states, there are auxiliary bond qubits and physical qubits, and coloring them differently would be a neat thing to do. **Description of the Change:** Update the output wire_options that could change the line style and color for circuit output. ```python @qml.qnode(qml.device("default.qubit")) def node(x): for w in range(5): qml.Hadamard(w) return qml.expval(qml.PauliZ(0) @ qml.PauliY(1)) # Make all wires cyan and bold, # except for wires 2 and 6, which are dashed and another color wire_options = {"color": "cyan", "linewidth": 5, 2: {"linestyle": "--", "color": "red"}, 6: {"linestyle": "--", "color": "orange"} } _,ax = qml.draw_mpl(node, wire_options=wire_options)(0.52) ``` **Benefits:** When complicated sates and quantum circuits diagram are created, wires could be marked with different selections. **Possible Drawbacks:** N/A **Related GitHub Issues:** #6165 --------- Co-authored-by: David Wierichs <[email protected]> Co-authored-by: ringo-but-quantum <> Co-authored-by: Astral Cai <[email protected]> Co-authored-by: Christina Lee <[email protected]>
Feature details
On the level of mid-scale algorithms, it might be nice to differentiate between different "types" of wires, for example by coloring them differently, or giving them distinct line styles. As an example, in this demo on preparing matrix product states, there are auxiliary bond qubits and physical qubits, and coloring them differently would be a neat thing to do.
Implementation
This should be as simply as allowing a nested dictionary for
wire_options
with wires as keys and innerwire_options
dictionaries. If such a nested dictionary is passed, we only need to iterate over it, instead of reusing the same for all wires.To make the idea clear, here are some example inputs that already are supported, and some that should work after adding this feature:
For a circuit with many wires, it would be annoying to have to pass information for all wires. That's why the following should also be supported:
Specify the
wire_options
for all wires at the same time, but allow single wire entries to be in that dictionary, refining the options for a given wire:Suggestion for an updated description in the docstrings:
How important would you say this feature is?
1: Not important. Would be nice to have.
Additional information
This is really just a small cosmetic idea.
The text was updated successfully, but these errors were encountered: