def main(): getParams() x = 1 allLog = SortedSet() errorNo = 0 for line in theOpenFile: if line.startswith("#"): continue if line.startswith("result, logSet"): continue if len(line) > 20: x += 1 if x % 10000 == 0: print(f'{int(x / 1000):,}') try: p: PositionTesterLogItem = PositionTesterLogItem(line, 1) if not allLog.__contains__(p): allLog.add(p) else: t4 = 1 except Exception as e: print(f'error {errorNo}:{e}') errorNo += 1 theOpenFile.close() agList = [] # remove duplicates # for each position id, # remove duplicates # build a list of (positionId, number of networks that found it, sum of all agrees all nets) for k in range(1, 200000): l = list(allLog.irange_key(k, k)) if len(l) > 0: # if your going to save the entire list or compare other features then do a clean up. for item in l: agList.append((k, enu.count(), enu.sum(lambda x: x.agree))) print(agList[-1]) with open('ur frequencyEasy20k.csv', 'w') as out: csv_out = csv.writer(out) csv_out.writerow(['positionID', 'count', 'agree']) for row in agList: csv_out.writerow(row) groups = Enumerable(agList).group_by(key_names=['id', 'count', 'agree'], key=lambda x: x[2]) countList = [] for g in groups: countList.append((g.count(), g.first()[2])) with open('countlist.csv', 'w') as out: csv_out = csv.writer(out) csv_out.writerow(['howManyPositions', 'AgreeCount']) for row in countList: csv_out.writerow(row) tmp55 = 1
def test_irange_key(): values = sorted(range(100), key=modulo) for load in range(5, 16): ss = SortedSet(range(100), key=modulo) ss._reset(load) for start in range(10): for end in range(start, 10): temp = list(ss.irange_key(start, end)) assert temp == values[(start * 10):((end + 1) * 10)] temp = list(ss.irange_key(start, end, reverse=True)) assert temp == values[(start * 10):((end + 1) * 10)][::-1] for start in range(10): for end in range(start, 10): temp = list(ss.irange_key(start, end, inclusive=(True, False))) assert temp == values[(start * 10):(end * 10)] for start in range(10): for end in range(start, 10): temp = list(ss.irange_key(start, end, (False, True))) assert temp == values[((start + 1) * 10):((end + 1) * 10)] for start in range(10): for end in range(start, 10): temp = list(ss.irange_key(start, end, inclusive=(False, False))) assert temp == values[((start + 1) * 10):(end * 10)] for start in range(10): temp = list(ss.irange_key(min_key=start)) assert temp == values[(start * 10):] for end in range(10): temp = list(ss.irange_key(max_key=end)) assert temp == values[:(end + 1) * 10]