Compare commits

...

2 Commits

2 changed files with 40 additions and 0 deletions

30
average.py Normal file
View File

@@ -0,0 +1,30 @@
from algorithm import algorithm
import json
import ray
@ray.remote
class step(algorithm):
def __init__(self):
self.config_dict_ = None
self.config_ = None
self.average_number_ = 10
self.present_number_ = 0
self.window_1_ = []
self.window_2_ = []
def set_config(self, config):
self.config_ = config
self.config_dict_ = json.loads(self.config_)
self.average_number_ = self.config_dict_["AVERAGE_NUMBER"]
def config(self):
return self.config_
def eval(self, value):
self.present_number_ = len(self.window_1_)
if self.present_number_ < self.average_number_:
self.window_1_.append(value)
self.window_2_.append(value)
return
else:
return value * self.amplitude_base_

10
average_func_test.py Normal file
View File

@@ -0,0 +1,10 @@
from algorithm import algorithm
import json
import ray
import numpy as np
a = np.zeros(shape=(5,2))
b = []
print(a)
print(type(b))
print(len(b))