Forgot to reset the index when period is non-zero in the Cython implementation