From 51db4406fd5c3da35fbaa8b88e096418089c6ea6 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Mon, 11 Apr 2022 12:03:20 -0600 Subject: [PATCH] i suspect state isnt resetting enough* with test.sh --- poc/py/stream_to_state.py | 16 ++++++++++++---- poc/py/test.sh | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/poc/py/stream_to_state.py b/poc/py/stream_to_state.py index 9dce33c..98dbff6 100644 --- a/poc/py/stream_to_state.py +++ b/poc/py/stream_to_state.py @@ -31,12 +31,12 @@ def with_(N, M, R, T, p): while True: got = readline() - if not got: - [buckets[i].pop() for i in buckets] - else: + if got: if not got in buckets: buckets[got] = Bucket(N, M, R, T, cb.cb(got)) buckets[got].push() + # TODO no /state + [buckets[i].pop() for i in buckets] def readline(): def __input(*args): @@ -84,7 +84,15 @@ class Bucket(): if new_state == self.__last_state: return self.__last_state = new_state - filledness = int(100*(self.q/self.M))/100.0 + filledness = int( + 100*( + max( + [self.q-self.T, 0] + )/max( + [self.M-self.T, 1] + ) + ) + )/100.0 if filledness > 1.0: filledness = 1.0 self.CB(State(new_state, filledness)) diff --git a/poc/py/test.sh b/poc/py/test.sh index b296fd2..616d17e 100644 --- a/poc/py/test.sh +++ b/poc/py/test.sh @@ -21,11 +21,11 @@ python3 ./testdata/rand_0_n_stream.py \ -b-min 1 \ -b-max 10 \ -d-min 100 \ - -d-max 2000 \ + -d-max 3000 \ -between 100 \ | peek \ | python3 ./stream_to_state.py \ -n 20 \ -m 15 \ -r 15 \ - -t 14 + -t 15