From 09ab70d05f6ccd666a0a59f2414f9bf8e361e418 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Tue, 12 Apr 2022 15:36:20 -0600 Subject: [PATCH] play with desmos and test.sh until about 2 buttons held per window --- poc/py-ratio1024-log2/state_to_buttons.py | 17 +++++++++-------- poc/py-ratio1024-log2/stream_to_state.py | 9 +++++++-- poc/py-ratio1024-log2/test.sh | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/poc/py-ratio1024-log2/state_to_buttons.py b/poc/py-ratio1024-log2/state_to_buttons.py index ad314b4..05591d4 100644 --- a/poc/py-ratio1024-log2/state_to_buttons.py +++ b/poc/py-ratio1024-log2/state_to_buttons.py @@ -2,7 +2,7 @@ import argparse import os from time import sleep -import buttons +#import buttons def main(): args = get_args() @@ -18,14 +18,15 @@ def main(): if not key in buckets: buckets[key] = [False, len(buckets)] buckets[key][0] = False if line[0] == "/" else float(line.split()[-1]) - for key in bucket: - keycode = buttons.keys[bucket[key][1]] - if bucket[key][0]: - print("down", key, button[key]) - buttons.down(keycode) + for key in buckets: + #keycode = buttons.keys[bucket[key][1]] + if buckets[key][0]: + print("down", key, end=" ") #, button[key]) + #buttons.down(keycode) else: - print("up", key, button[key]) - buttons.up(keycode) + print("up", key, end=" ") #, button[key]) + #buttons.up(keycode) + print() def get_args(): ap = argparse.ArgumentParser() diff --git a/poc/py-ratio1024-log2/stream_to_state.py b/poc/py-ratio1024-log2/stream_to_state.py index 9e35d4a..122acdc 100644 --- a/poc/py-ratio1024-log2/stream_to_state.py +++ b/poc/py-ratio1024-log2/stream_to_state.py @@ -84,8 +84,13 @@ class Window(): for key in keys: count = len([True for i in self.w if i[0] == key]) #scaled_rate = int(log((count / cnt) * 1024.0, 2)+.5) - scaled_rate = int((count / cnt) * 1024.0 + .5) - scaled_rates[key] = scaled_rate + #scaled_rate = int((count / cnt) * 1024.0 + .5) + x = (count/cnt) + x = x * 3 + x = log(5*x+1, 2)/2 + x = x / 2 + #print(f"{count}/{cnt} => {x}") + scaled_rates[key] = int(x*self.n+.5) return scaled_rates def push(self, k): diff --git a/poc/py-ratio1024-log2/test.sh b/poc/py-ratio1024-log2/test.sh index f4c947f..efc0e42 100644 --- a/poc/py-ratio1024-log2/test.sh +++ b/poc/py-ratio1024-log2/test.sh @@ -32,4 +32,4 @@ python3 ./testdata/rand_0_n_weighted_stream.py \ | peek \ | python3 ./stream_to_state.py \ -d 10000 \ - -m 0.1 + -m 0.2