comparison SMART/Java/Python/plot.py @ 18:94ab73e8a190

Uploaded
author m-zytnicki
date Mon, 29 Apr 2013 03:20:15 -0400
parents 769e306b7933
children
comparison
equal deleted inserted replaced
17:b0e8584489e6 18:94ab73e8a190
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 newKey = min(top, int(math.floor((key - minValue) / float(maxValue - minValue) * self.nbBars)) * step + minValue) 137 divisor = float(maxValue - minValue) * self.nbBars
138 tmpMinValue = top
139 if divisor != 0:
140 tmpMinValue = min(top, int(math.floor((key - minValue) / divisor)))
141 newKey = tmpMinValue * step + minValue
138 values[newKey] += value 142 values[newKey] += value
139 return values 143 return values
140 144
141 def parseFile(self): 145 def parseFile(self):
142 line = {} 146 line = {}