Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def init_tracker():
# init the tracker
iterative_eval_tracker(iterations=100, tolerance=0.001)
assert iterative_eval_tracker.ns.iteration_number == 0
assert iterative_eval_tracker.ns.iterations == 100
assert iterative_eval_tracker.ns.tolerance == 0.001
assert iterative_eval_tracker.tolerance == 0.001
assert iterative_eval_tracker.done
def do_test_tracker():
# test done if no WIP
iterative_eval_tracker.wip(1)
assert iterative_eval_tracker.ns.todo == {1}
assert not iterative_eval_tracker.done
iterative_eval_tracker.inc_iteration_number()
assert iterative_eval_tracker.done
def test_iterative_eval_tracker():
assert isinstance(iterative_eval_tracker.ns.todo, set)
def init_tracker():
# init the tracker
iterative_eval_tracker(iterations=100, tolerance=0.001)
assert iterative_eval_tracker.ns.iteration_number == 0
assert iterative_eval_tracker.ns.iterations == 100
assert iterative_eval_tracker.ns.tolerance == 0.001
assert iterative_eval_tracker.tolerance == 0.001
assert iterative_eval_tracker.done
def do_test_tracker():
# test done if no WIP
iterative_eval_tracker.wip(1)
assert iterative_eval_tracker.ns.todo == {1}
assert not iterative_eval_tracker.done
iterative_eval_tracker.inc_iteration_number()
def do_test_tracker():
# test done if no WIP
iterative_eval_tracker.wip(1)
assert iterative_eval_tracker.ns.todo == {1}
assert not iterative_eval_tracker.done
iterative_eval_tracker.inc_iteration_number()
assert iterative_eval_tracker.done
assert iterative_eval_tracker.tolerance == 0.001
assert iterative_eval_tracker.done
def do_test_tracker():
# test done if no WIP
iterative_eval_tracker.wip(1)
assert iterative_eval_tracker.ns.todo == {1}
assert not iterative_eval_tracker.done
iterative_eval_tracker.inc_iteration_number()
assert iterative_eval_tracker.done
init_tracker()
do_test_tracker()
# init the tracker
iterative_eval_tracker(iterations=2, tolerance=5)
assert iterative_eval_tracker.ns.iteration_number == 0
assert iterative_eval_tracker.ns.iterations == 2
assert iterative_eval_tracker.ns.tolerance == 5
# test done if max iters exceeded
iterative_eval_tracker.inc_iteration_number()
assert iterative_eval_tracker.ns.iteration_number == 1
iterative_eval_tracker.wip(1)
assert not iterative_eval_tracker.done
iterative_eval_tracker.inc_iteration_number()
assert iterative_eval_tracker.ns.iteration_number == 2
iterative_eval_tracker.wip(1)
assert iterative_eval_tracker.done
# check calced / iscalced
def do_test_tracker():
# test done if no WIP
iterative_eval_tracker.wip(1)
assert iterative_eval_tracker.ns.todo == {1}
assert not iterative_eval_tracker.done
iterative_eval_tracker.inc_iteration_number()
assert iterative_eval_tracker.done
iterative_eval_tracker.inc_iteration_number()
assert iterative_eval_tracker.ns.iteration_number == 1
iterative_eval_tracker.wip(1)
assert not iterative_eval_tracker.done
iterative_eval_tracker.inc_iteration_number()
assert iterative_eval_tracker.ns.iteration_number == 2
iterative_eval_tracker.wip(1)
assert iterative_eval_tracker.done
# check calced / iscalced
assert not iterative_eval_tracker.is_calced(1)
iterative_eval_tracker.calced(1)
assert iterative_eval_tracker.is_calced(1)
iterative_eval_tracker.inc_iteration_number()
assert not iterative_eval_tracker.is_calced(1)
class AThread(threading.Thread):
def run(self):
try:
init_tracker()
import time
time.sleep(0.1)
do_test_tracker()
self.result = True
except: # noqa: E722
self.result = False
thread = AThread()
thread.start()
init_tracker()
do_test_tracker()
def do_test_tracker():
# test done if no WIP
iterative_eval_tracker.wip(1)
assert iterative_eval_tracker.ns.todo == {1}
assert not iterative_eval_tracker.done
iterative_eval_tracker.inc_iteration_number()
assert iterative_eval_tracker.done
def value_tree_str(self, address, indent=0):
iterative_eval_tracker.inc_iteration_number()
yield from self._value_tree_str(address)