Skip to content

Commit 4521b39

Browse files
committed
Fix --nosummary flag
The `--nosummary` flag was inverted, which cause it to always be true. Rather than just flip `store_false` to `store_true`, I opted to refactor the internal name from `nosummary` to `showSummary`. This avoids double-negatives ("Are we not not showing the summary?"), making the logic easier to follow and easier to find bugs in. I left the flag name as-is for compatability reasons. Fixes glamp#1.
1 parent 607f778 commit 4521b39

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

bashplotlib/histogram.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def run_demo():
5050
print "hist -f ./data/exp.txt -s 35.0 -b 40"
5151
plot_hist('./data/exp.txt', height=35.0, bincount=40)
5252

53-
def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title="", xlab=None, nosummary=True):
53+
def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title="", xlab=None, showSummary=False):
5454
"""make a histogram
5555
5656
Keyword arguments:
@@ -60,7 +60,7 @@ def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title="",
6060
colour -- colour of the bars in the terminal
6161
title -- title at the top of the plot
6262
xlab -- boolen value for whether or not to display x-axis labels
63-
nosummary -- boolean value for whether or not to display a summary
63+
showSummary -- boolean value for whether or not to display a summary
6464
"""
6565

6666
if pch is None:
@@ -135,7 +135,7 @@ def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title="",
135135
center = max(map(len, map(str, [n, min_val, mean, max_val])))
136136
center += 15
137137

138-
if nosummary is not True:
138+
if showSummary:
139139
print
140140
print "-"*(2 + center)
141141
print "|" + "Summary".center(center) + "|"
@@ -165,7 +165,7 @@ def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title="",
165165
parser.add_option('-c', '--colour', help='colour of the plot (%s)' % ", ".join([c for c in bcolours.keys() if c != 'ENDC']),
166166
default='white', dest='colour')
167167
parser.add_option('-d', '--demo', help='run demos', action='store_true', dest='demo')
168-
parser.add_option('-n', '--nosummary', help='run demos', action='store_true', dest='nosummary')
168+
parser.add_option('-n', '--nosummary', help='hide summary', action='store_false', dest='showSummary', default=True)
169169

170170
(opts, args) = parser.parse_args()
171171

@@ -178,7 +178,7 @@ def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title="",
178178
if opts.demo:
179179
run_demo()
180180
elif opts.f:
181-
plot_hist(opts.f, opts.h, opts.b, opts.p, opts.colour, opts.t, opts.x, opts.nosummary)
181+
plot_hist(opts.f, opts.h, opts.b, opts.p, opts.colour, opts.t, opts.x, opts.showSummary)
182182
else:
183183
print "nothing to plot!"
184184

bin/hist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if __name__=="__main__":
2222
parser.add_option('-x', '--xlab', help='label bins on x-axis', default=None, action="store_true", dest='x')
2323
parser.add_option('-c', '--colour', help='colour of the plot (%s)' % ", ".join([c for c in bcolours.keys() if c != 'ENDC']),
2424
default='white', dest='colour')
25-
parser.add_option('-n', '--nosummary', help='hide summary', action='store_false', dest='nosummary')
25+
parser.add_option('-n', '--nosummary', help='hide summary', action='store_false', dest='showSummary', default=True)
2626

2727
(opts, args) = parser.parse_args()
2828

@@ -33,7 +33,7 @@ if __name__=="__main__":
3333
opts.f = sys.stdin.readlines()
3434

3535
if opts.f:
36-
plot_hist(opts.f, opts.h, opts.b, opts.p, opts.colour, opts.t, opts.x, opts.nosummary)
36+
plot_hist(opts.f, opts.h, opts.b, opts.p, opts.colour, opts.t, opts.x, opts.showSummary)
3737
else:
3838
print "nothing to plot!"
3939

0 commit comments

Comments
 (0)