forked from ZiyaoWei/pyMatrixProfile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorder.py
More file actions
32 lines (25 loc) · 638 Bytes
/
order.py
File metadata and controls
32 lines (25 loc) · 638 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import random
class Order:
def next(self):
raise NotImplementedError("next() not implemented")
class LinearOrder(Order):
def __init__(self, m):
self.m = m
self.idx = -1
def next(self):
self.idx += 1
if self.idx < self.m:
return self.idx
else:
return None
class RandomOrder(Order):
def __init__(self, m):
self.idx = -1
self.indices = range(m)
random.shuffle(self.indices)
def next(self):
self.idx += 1
try:
return self.indices[self.idx]
except IndexError:
return None