Closed golfdish closed 9 years ago
On closer inspection it appears that this is a consequence of startTime
being larger than timestamp
, as when startTime
is set before time.time()
gets patched out.
I've pushed a less-than-ideal fix for this in e1f9118b85f88a9bc5eec8f7de5fb6cf676041ef. Thanks!
Calculating
self.__sample.stddev
for aPmfStatDict
after callingaddValue
results in a ZeroDivisionError when the list of samples has 1 element but itscount
is 2 or greater, as when an operation takes zero time (e.g. when unit testing withtime.time()
patched out). This is due to these lines inExponentiallyDecayingReservoir.update
(samplestats.py:151):priority
is obviously 0 whentimestamp - self.startTime
is 0, thusself.samples()
returns a list of length 1 (self.values.values()
) whileself.count
is 2 or greater. Becauseself.count
decideslen(self)
for aSampler
, the test at the top ofin
Sampler
(samplestats.py:54) returns False, allowing the following code to execute, with the inevitable ZeroDivisionError when it divides bylen(arr) - 1
.