|
@@ -99,17 +99,17 @@ class MyTestCase(unittest.TestCase):
|
|
|
painter = MerchantAmountPainter(start_time=start_time, end_time=end_time, mchids=set(), card_types={4, 5, 6})
|
|
|
painter.paint()
|
|
|
|
|
|
-
|
|
|
def test_ChannelWriter(self):
|
|
|
from refill import ChannelWriter, open_hdf5
|
|
|
import time
|
|
|
|
|
|
hfive = open_hdf5('/var/www/html/data/stdata/channel.hdf5', True)
|
|
|
chwriter = ChannelWriter(hfive)
|
|
|
- itema = {'channel_name':'zero', 'time':int(time.time()), 'spec':50, 'card_type':4, 'channel_amount':49, 'period':30}
|
|
|
- itemb = {'channel_name':'xxxxxx', 'time':int(time.time()), 'spec':50, 'card_type':4, 'channel_amount':49, 'period':30,'mch_amount':49.625}
|
|
|
- chwriter.write('ch_succ',itema)
|
|
|
- chwriter.write('ch_succ',itemb)
|
|
|
+ itema = {'channel_name': 'zero', 'time': int(time.time()), 'spec': 50, 'card_type': 4, 'channel_amount': 49, 'period': 30}
|
|
|
+ itemb = {'channel_name': 'xxxxxx', 'time': int(time.time()), 'spec': 50, 'card_type': 4, 'channel_amount': 49, 'period': 30,
|
|
|
+ 'mch_amount': 49.625}
|
|
|
+ chwriter.write('ch_succ', itema)
|
|
|
+ chwriter.write('ch_succ', itemb)
|
|
|
|
|
|
def test_netcheck(self):
|
|
|
from refill import NetchkReader
|
|
@@ -260,10 +260,44 @@ class MyTestCase(unittest.TestCase):
|
|
|
result[card_type].append(spec)
|
|
|
return result
|
|
|
|
|
|
- tups = [(4, 100), (4, 50), (5, 10), (4, 30), (5, 30), (6, 100), (5, 100), ]
|
|
|
+ tups = [(4, 100), (4, 50), (5, 10), (4, 30), (5, 30), (6, 100), (5, 100)]
|
|
|
x = split_card(tups)
|
|
|
y = 1
|
|
|
|
|
|
+ def testFindLowest(self):
|
|
|
+ #ratios = {'feimingyu_high': 1,'feimingyu_high': 5 / 215, 'lechong': 4 / 2108, 'lechong_high': 4 / 2223, 'weixue': 13 / 17101, 'yunchonggong': 7 / 23276,'yunchonggongx': 1 / 232760}
|
|
|
+ ratios = {'feimingyu_high': 0.05,'feimingyu_high': 5 / 215, 'lechong': 4 / 2108, 'lechong_high': 4 / 2223, 'weixue': 0.1, 'yunchonggong': 7 / 23276,'yunchonggongx': 1 / 232760}
|
|
|
+ # ratios = {'feimingyu_high': 0.9, 'lechong': 4 / 2108, 'lechong_high': 4 / 2223, 'weixue': 13 / 17101, 'yunchonggong': 1 / 23276}
|
|
|
+ # ratios = {'lechong': 4 / 2108, 'lechong_high': 4 / 2223, 'weixue': 13 / 17101, 'yunchonggong': 1 / 23276}
|
|
|
+ # ratios = {'feimingyu_high': 5 / 215, 'lechong': 4 / 2108, 'lechong_high': 4 / 2223, 'weixue': 13 / 17101, 'yunchonggong': 1 / 23276}
|
|
|
+ # ratios = {'feimingyu_high': 1, 'lechong': 4 / 2108, 'lechong_high': 4 / 2223, 'weixue': 13 / 17101, 'yunchonggong': 1 / 23276}
|
|
|
+ # def classify_ratio(ratios):
|
|
|
+ # result = {}
|
|
|
+ # for name,ratio in ratios.items():
|
|
|
+ # if round(ratio,2) >= 0.1:
|
|
|
+ # result[1] =
|
|
|
+
|
|
|
+ import math,cmath
|
|
|
+
|
|
|
+ def calc_avg(ratios):
|
|
|
+ total = 0.0
|
|
|
+ for name, ratio in ratios.items():
|
|
|
+ x = cmath.log(ratio)
|
|
|
+ log.debug(f'log={x}')
|
|
|
+ total += ratio
|
|
|
+ return total / len(ratios)
|
|
|
+
|
|
|
+ avg = calc_avg(ratios)
|
|
|
+ left = dict()
|
|
|
+ for name, ratio in ratios.items():
|
|
|
+ if ratio < avg:
|
|
|
+ left[name] = ratio
|
|
|
+
|
|
|
+ for name, ratio in ratios.items():
|
|
|
+ rate = ratio / avg
|
|
|
+ alpha = rate * rate
|
|
|
+
|
|
|
+ log.debug(f'{name} rate:{rate} alpha:{alpha}')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
unittest.main()
|