projects
/
sawsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Ensure that printed histograms always have at least two bins listed.
[sawsim.git]
/
pysawsim
/
histogram.py
diff --git
a/pysawsim/histogram.py
b/pysawsim/histogram.py
index cdb0bbf086120789595bf4061969d3f1fd73b814..6c326d2ef6cb53e6efd83fffbf338dfff565f860 100644
(file)
--- a/
pysawsim/histogram.py
+++ b/
pysawsim/histogram.py
@@
-151,11
+151,21
@@
class Histogram (object):
1.5e-10\t10
2e-10\t40
2.5e-10\t5
1.5e-10\t10
2e-10\t40
2.5e-10\t5
+ >>> h.bin_edges = h.bin_edges[:2]
+ >>> h.counts = h.counts[:1]
+ >>> h.to_stream(sys.stdout)
+ ... # doctest: +NORMALIZE_WHITESPACE, +REPORT_UDIFF
+ #Force (N)\tUnfolding events
+ 1.5e-10\t10
+ 2e-10\t0
"""
if self.headings != None:
stream.write('#%s\n' % '\t'.join(self.headings))
for bin,count in zip(self.bin_edges, self.counts):
stream.write('%g\t%g\n' % (bin, count))
"""
if self.headings != None:
stream.write('#%s\n' % '\t'.join(self.headings))
for bin,count in zip(self.bin_edges, self.counts):
stream.write('%g\t%g\n' % (bin, count))
+ if len(self.counts) == 1:
+ # print an extra line so that readers can determine bin width
+ stream.write('%g\t0\n' % (self.bin_edges[-1]))
def analyze(self):
"""Analyze `.counts` and `.bin_edges` if the raw data is missing.
def analyze(self):
"""Analyze `.counts` and `.bin_edges` if the raw data is missing.