minor clean up: f() in CyclicSampler
Browse files- automata.py +1 -10
automata.py
CHANGED
@@ -503,16 +503,7 @@ class CyclicSampler(AutomatonSampler):
|
|
503 |
+ self.__info__
|
504 |
|
505 |
def f(self, x):
|
506 |
-
|
507 |
-
# NOTE: for Python 3.7 or below, accumulate doesn't have the 'initial' argument.
|
508 |
-
x_padded = np.concatenate([np.array([0]), x]).astype(np.int64)
|
509 |
-
states = list(itertools.accumulate(x_padded, lambda a,b: (a+b)%self.n ))
|
510 |
-
states = states[1:]
|
511 |
-
else:
|
512 |
-
states = list(itertools.accumulate(x, lambda a,b: (a+b)%self.n, initial=0))
|
513 |
-
states = states[1:] # remove the 1st entry with is the (meaningless) initial value 0
|
514 |
-
|
515 |
-
return np.array(states).astype(np.int64)
|
516 |
|
517 |
def sample(self):
|
518 |
T = self.sample_length()
|
|
|
503 |
+ self.__info__
|
504 |
|
505 |
def f(self, x):
|
506 |
+
return np.cumsum(x) % self.n
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
507 |
|
508 |
def sample(self):
|
509 |
T = self.sample_length()
|