numenta/NAB

KeyError in labeler.py

PierrickPochelu opened this issue · 0 comments

https://github.com/numenta/NAB/blob/master/nab/labeler.py line 424

The following code:

         front = max(a - windowLength/2, 0)
        back = min(a + windowLength/2, length-1)

        windowLimit = [strf(data["timestamp"][front]),
                       strf(data["timestamp"][back])]

Produces:
KeyError due to the fact front may be a decimal value

Should be:

        front = int(round(max(a - windowLength/2, 0)))
        back = int(round(min(a + windowLength/2, length-1)))

        windowLimit = [strf(data["timestamp"][front]),
                       strf(data["timestamp"][back])]