In practice, one would normally explicitly derive a class from
object class (was called new-style class back then).
https://docs.python.org/release/2.5.2/ref/node33.html
https://wiki.python.org/moin/NewClassVsClassicClass
print needs parentheses for portability with Python3.x.
xrange() only exists in Python2.x (i.e. breaks on Python3.x).
Using range() (which pre-allocates a whole list in Python2.x)
won't be a problem unless len(averages) is huge enough to give
any pressure to vm subsystem.
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
while (start < ftime):
end = ftime if ftime < end else end
results = [ts.get_value(start, end) for ts in series]
while (start < ftime):
end = ftime if ftime < end else end
results = [ts.get_value(start, end) for ts in series]
- print "%s, %s" % (end, ', '.join(["%0.3f" % i for i in results]))
+ print("%s, %s" % (end, ', '.join(["%0.3f" % i for i in results])))
start += ctx.interval
end += ctx.interval
start += ctx.interval
end += ctx.interval
while (start < ftime):
end = ftime if ftime < end else end
results = [ts.get_value(start, end) for ts in series]
while (start < ftime):
end = ftime if ftime < end else end
results = [ts.get_value(start, end) for ts in series]
- print "%s, %0.3f" % (end, sum(results))
+ print("%s, %0.3f" % (end, sum(results)))
start += ctx.interval
end += ctx.interval
start += ctx.interval
end += ctx.interval
while (start < ftime):
end = ftime if ftime < end else end
results = [ts.get_value(start, end) for ts in series]
while (start < ftime):
end = ftime if ftime < end else end
results = [ts.get_value(start, end) for ts in series]
- print "%s, %0.3f" % (end, float(sum(results))/len(results))
+ print("%s, %0.3f" % (end, float(sum(results))/len(results)))
start += ctx.interval
end += ctx.interval
start += ctx.interval
end += ctx.interval
end += ctx.interval
total = 0
end += ctx.interval
total = 0
- for i in xrange(0, len(averages)):
+ for i in range(0, len(averages)):
total += averages[i]*weights[i]
total += averages[i]*weights[i]
- print '%0.3f' % (total/sum(weights))
+ print('%0.3f' % (total/sum(weights)))
+class TimeSeries(object):
def __init__(self, ctx, fn):
self.ctx = ctx
self.last = None
def __init__(self, ctx, fn):
self.ctx = ctx
self.last = None
value += sample.get_contribution(start, end)
return value
value += sample.get_contribution(start, end)
return value
def __init__(self, ctx, start, end, value):
self.ctx = ctx
self.start = start
def __init__(self, ctx, start, end, value):
self.ctx = ctx
self.start = start