<jupyter_start><jupyter_text>Introduction<jupyter_code>import widget_message_speed
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize']=(10,7.5)
plt.rcParams['font.size']=20
w = widget_message_speed.ExampleWidget()
w.layout.height = '200px'<jupyter_output><empty_output><jupyter_text>Move mouse over the widget to generate events<jupyter_code>w<jupyter_output><empty_output><jupyter_text>validatecheck that `py_ts_time + ts_py_time = ts_roundtrip` and that there are the same number entries in a lists (may need to wait a second for all messages to finish)<jupyter_code>import numpy as np
assert np.all(np.array(w.py_ts_times) + np.array(w.ts_py_times) == np.array(w.ts_roundtrip))
#check that they all have the same length
len(w.py_ts_times), len(w.ts_py_times), len(w.ts_roundtrip)
plt.title('roundtrip time')
# plt.hist([i[0]+i[1] for i in zip(w.py_ts_times, w.ts_py_times)], bins='auto', density=True)

plt.hist(w.ts_roundtrip, bins='auto', density=True)
ax = plt.gca()
xlim = ax.get_xlim()
plt.xlabel('ms')
plt.tight_layout()
plt.savefig('roundtrip.png')
plt.show()

# idx = int(np.max(w.py_ts_times) > np.max(w.ts_py_times))
# bins = np.histogram_bin_edges([w.ts_py_times,w.py_ts_times][idx],bins='auto')

plt.hist(w.ts_py_times, bins = 'auto', density=True)
plt.xlim(xlim)
plt.title('typescript -> python')
plt.xlabel('milliseconds')
plt.tight_layout()
plt.savefig('ts_to_py.png')
# plt.ylabel('probability')
plt.show()

plt.hist(w.py_ts_times, bins= 'auto', density=True)
plt.xlim(xlim)
plt.title('python -> typescript')
plt.xlabel('milliseconds')
plt.tight_layout()
plt.savefig('py_to_ts.png')

# plt.ylabel('probability')
plt.show()





plt.scatter(w.ts_py_times,w.py_ts_times, alpha=.1, color='k')
plt.ylabel('py -> ts (ms)')
plt.xlabel('ts -> py (ms)')
plt.tight_layout()
plt.savefig('scatter.png')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16648764769065522, 'fraction_numerical': 0.00644468313641246, 'mean_word_length': 7.135371179039302, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '268945', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 800, 'n_tokens_neox': 749, 'n_words': 125, 'path': 'examples/timing-test.ipynb', 'repo_name': 'ianhi/widget_message_speed', 'size': '1862'}