[SciPy-User] Identify unique sequence data from array
Thu Dec 23 12:59:41 CST 2010
> You could also check one element at a time. I think it will be
> faster, because it will break if comparison of the first element
> doesn't hold. Then, if you find such an occurrence, use Robert's
> method to double check that you found the true repetition period.
>>>> a = [1,2,3,4,1,2,3,4,1,2,3,4]
>>>> a = numpy.array(a)
>>>> for i in range(1, 1+a.size/2):
> ... if (a == a[::i]).all(): print 'period is ',i
> period is 4
This works great!
For 2D if it's not obvious:
for i in range(1, 1+a.size/4):
if (a[0,0] == a[::i,0]).all():
More information about the SciPy-User