MCPcopy Create free account
hub / github.com/Vespa314/chan.py / CTrendLine

Class CTrendLine

Math/TrendLine.py:26–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25
26class CTrendLine:
27 def __init__(self, lst, side=TREND_LINE_SIDE.OUTSIDE):
28 self.line = None
29 self.side = side
30 self.cal(lst)
31
32 def cal(self, lst):
33 bench = float('inf')
34 if self.side == TREND_LINE_SIDE.INSIDE:
35 all_p = [Point(bi.get_begin_klu().idx, bi.get_begin_val()) for bi in lst[-1::-2]]
36 else:
37 all_p = [Point(bi.get_end_klu().idx, bi.get_end_val()) for bi in lst[-1::-2]]
38 c_p = copy.copy(all_p)
39 while True:
40 line, idx = cal_tl(c_p, lst[-1].dir, self.side)
41 dis = sum(line.cal_dis(p) for p in all_p)
42 if dis < bench:
43 bench = dis
44 self.line = line
45 c_p = c_p[idx:]
46 if len(c_p) == 1:
47 break
48
49
50def init_peak_slope(_dir, side):

Callers 1

update_bi_listMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected