MCPcopy Index your code
hub / github.com/geekcomputers/Python / auto_mode

Function auto_mode

Collatz Sequence/Collaze-Visualize.py:24–48  ·  view source on GitHub ↗
(interval)

Source from the content-addressed store, hash-verified

22
23
24def auto_mode(interval):
25 print("\nAuto mode started.")
26 print("Press SPACE in the plot window to stop.\n")
27
28 plt.ion()
29 stop = False
30
31 def on_key(event):
32 nonlocal stop
33 if event.key == ' ':
34 stop = True
35
36 fig = plt.figure()
37 fig.canvas.mpl_connect("key_press_event", on_key)
38
39 n = 1
40 while not stop:
41 seq = collatz_sequence(n)
42 visualize(seq, f"Collatz Sequence for n = {n}")
43 n += 1
44 time.sleep(interval)
45
46 plt.ioff()
47 plt.show()
48 print("Auto mode stopped.")
49
50
51# --- Main Program ---

Callers 1

Calls 3

visualizeFunction · 0.85
collatz_sequenceFunction · 0.70
showMethod · 0.45

Tested by

no test coverage detected