peewee Documentation Release 1.0.0create_aggregate] class WeightedAverage(object): def __init__(self): self.total_weight = 0.0 self.total_ct = 0.0 def step(self, value, wt=None): wt = wt or 1.0 self.total_weight += * value def finalize(self): if self.total_weight != 0.0: return self.total_ct / self.total_weight return 0.0 ext_db.adapter.register_aggregate(WeightedAverage, 2, 'weighted_avg')0 码力 | 101 页 | 163.20 KB | 1 年前3
peewee Documentation
Release 1.0.0total_weight = 0.0 self.total_ct = 0.0 def step(self, value, wt=None): wt = wt or 1.0 self.total_weight += wt self.total_ct += wt * value def finalize(self): if self.total_weight != 0.0: return self self.total_ct / self.total_weight return 0.0 ext_db.adapter.register_aggregate(WeightedAverage, 2, ’weighted_avg’) • custom collations 1.9. Playhouse, a collection of addons 63 peewee Documentation, Release0 码力 | 71 页 | 405.29 KB | 1 年前3
共 2 条
- 1













