-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
The parameter idle_wires
default flipped to False in all circuit drawers
#13865
Conversation
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 13696173867Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to say that this is a better default, but then I thought: actually I use the drawers quite a lot for small-scale drawing, and I think suppressing idle wires there by default is quite possibly surprising behaviour.
I wonder if it's worth having idle_wires
take a number to use as a cut-off size: if there are n
or more idle wires (possibly only count qubit ones), hide them, and if there's fewer, show them? So idle_wires=0
is the same as the current idle_wires=False
. We'd have to catch idle_wires=True
and turn it into idle_wires=math.inf
, potentially.
Alternatively, we ignore the int stuff, and add a third option to idle_wires
: "layout"
. I think this might be the happiest middle-ground: if the circuit has been transpiled to a layout (so the left margin will indicate qubit mapping), then we set idle_wires=False
, and if it hasn't, we set idle_wires=True
. (Could also call the option "auto"
or something.)
I'm not 100% convinced of that, I'm just slightly concerned about breaking usability of drawing small-scale circuits - I would think there's a pretty sizeable number of people who almost invariably draw those, and it'd be confusing if wires are sometimes hidden on them.
upgrade_visualization: | ||
- | | ||
The default for the parameter ``idle_wires`` changed to ``False`` in all the circuit drawers. If you still want to see wires without instructions, set ``idle_wires=True`` explicitly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might help to either explain a bit more, or put in a couple of text-mode drawings just to illustrate the difference? I'm not sure users necessarily know what the option is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. done in 4f83dc7
@@ -1117,7 +1117,9 @@ def test_idle_wires_barrier(self): | |||
circuit.barrier() | |||
|
|||
fname = "idle_wires_barrier.png" | |||
self.circuit_drawer(circuit, output="mpl", cregbundle=False, filename=fname) | |||
self.circuit_drawer( | |||
circuit, output="mpl", cregbundle=False, filename=fname, idle_wires=False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I accidentally found that a test with the description "Test that idle_wires False works with barrier" was not doing idle_wires=False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Luciano, this does feel like a good default now.
def _get_layered_instructions( | ||
circuit, reverse_bits=False, justify=None, idle_wires=True, wire_order=None, wire_map=None | ||
circuit, reverse_bits=False, justify=None, idle_wires="auto", wire_order=None, wire_map=None | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we leave this as idle_wires: bool
, and resolve the "auto"
at the top level of the drawers?
default_idle_wires = config.get("circuit_idle_wires", False) | ||
default_idle_wires = config.get("circuit_idle_wires", "auto") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we now resolve "auto"
into either True
or False
immediately after line 227, so the rest of the visualisers don't need to change?
qiskit/circuit/quantumcircuit.py
Outdated
idle_wires: Include (or not) idle wires (wires with no circuit elements) | ||
in output visualization. The string ``"auto"`` is also possible, in which | ||
case idle wires are show except that the circuit has a layout attached. | ||
Default is ``"auto"`` unless the | ||
user config file (usually ``~/.qiskit/settings.conf``) has an | ||
alternative value set. For example, ``circuit_idle_wires = True``. | ||
alternative value set. For example, ``circuit_idle_wires = False``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to update the configuration-file logic to make it possible to specify "auto"
in there too?
there's some bloch sphere plot failure which likely shouldn't be related to this, let's see if it persists
handle "auto" at the circuit_drawer level and subsequently use on booleans in internal logic
Co-authored-by: Jake Lishman <jake@binhbar.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this locally and it seems to do what I expect - thanks for the changes to the default, Luciano, and for getting it over the line, Julien.
Summary
Closes #12361
Details and comments
As QPUs are getting bigger, also the circuits are growing in terms of qubits.