Skip to content
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

Add default line length for jupyter #1400

Merged
merged 4 commits into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions qiskit/tools/visualization/_circuit_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ def circuit_drawer(circuit,
line_length (int): Sets the length of the lines generated by `text`
output type. This useful when the drawing does not fit in the
console. If None (default), it will try to guess the console width
using shutil.get_terminal_size(). If you don't want pagination at
all, set `line_length=-1`.
using shutil.get_terminal_size(). However, if you're running in
jupyter the default line length is set to 80 characters. If you
don't want pagination at all, set `line_length=-1`.
reverse_bits (bool): When set to True reverse the bit order inside
registers for the output visualization.
plot_barriers (bool): Enable/disable drawing barriers in the output
Expand Down
6 changes: 5 additions & 1 deletion qiskit/tools/visualization/_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""

from shutil import get_terminal_size
import sys

from ._error import VisualizationError

Expand Down Expand Up @@ -460,7 +461,10 @@ def lines(self, line_length=None):
if line_length is None:
line_length = self.line_length
if line_length is None:
line_length, _ = get_terminal_size()
if ('ipykernel' in sys.modules) and ('spyder' not in sys.modules):
line_length = 80
else:
line_length, _ = get_terminal_size()

noqubits = len(self.qregs)
layers = self.build_layers()
Expand Down