Skip to content

Commit 19f7bd6

Browse files
committed
Fix empty X, Y and spaces
1 parent 346c50e commit 19f7bd6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

plotille.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _scale(a):
6767
for i in range(bins):
6868
hight = int(width * 8 * _scale(h[i]) / h_max)
6969
canvas += ['{:10.5f} | {:{width}s} {}'.format(
70-
(b[i] + b[i+1]) / 2, # use bucket center as representation
70+
(b[i] + b[i + 1]) / 2, # use bucket center as representation
7171
'⣿' * (hight // 8) + lasts[hight % 8],
7272
h[i],
7373
width=width)]
@@ -134,8 +134,12 @@ def plot(X, Y, width=80, height=50, X_label='X', Y_label='Y', linesep=os.linesep
134134
# make point iterators
135135
from_points = izip(X, Y)
136136
to_points = izip(X, Y)
137-
# remove first point of to_points
138-
next(to_points)
137+
try:
138+
# remove first point of to_points
139+
next(to_points)
140+
except StopIteration:
141+
# empty X, Y
142+
pass
139143

140144
# subsequent points
141145
for (x0, y0), (x, y) in izip(from_points, to_points):

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ max-line-length = 159
33
import-order-style = google
44

55
[tool:pytest]
6-
addopts = --cov=plotille --cov-report=term-missing --flake8 -v -s
6+
addopts = --cov=plotille --cov-report=term-missing --flake8 -v -s
77

88
[bdist_wheel]
99
universal = 1

0 commit comments

Comments
 (0)