Mercurial > repos > yufei-luo > s_mart
comparison SMART/Java/Python/plot.py @ 46:169d364ddd91
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 30 Sep 2013 03:19:26 -0400 |
parents | 2c0c0a89fad7 |
children |
comparison
equal
deleted
inserted
replaced
45:e454402ba9d9 | 46:169d364ddd91 |
---|---|
132 maxValue = int(math.ceil(max(line.keys()))) | 132 maxValue = int(math.ceil(max(line.keys()))) |
133 step = (maxValue - minValue) / self.nbBars | 133 step = (maxValue - minValue) / self.nbBars |
134 values = dict([i * step + minValue, 0] for i in range(0, self.nbBars)) | 134 values = dict([i * step + minValue, 0] for i in range(0, self.nbBars)) |
135 top = (self.nbBars - 1) * step + minValue | 135 top = (self.nbBars - 1) * step + minValue |
136 for key, value in line.iteritems(): | 136 for key, value in line.iteritems(): |
137 divisor = float(maxValue - minValue) * self.nbBars | 137 newKey = min(top, int(math.floor((key - minValue) / float(maxValue - minValue) * self.nbBars)) * step + minValue) |
138 tmpMinValue = top | |
139 if divisor != 0: | |
140 tmpMinValue = min(top, int(math.floor((key - minValue) / divisor))) | |
141 newKey = tmpMinValue * step + minValue | |
142 values[newKey] += value | 138 values[newKey] += value |
143 return values | 139 return values |
144 | 140 |
145 def parseFile(self): | 141 def parseFile(self): |
146 line = {} | 142 line = {} |