Mercurial > public > mercurial-scm > hg-stable
comparison contrib/perf-utils/perf-revlog-write-plot.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | c3e5ce3a9483 |
children | c102b704edb5 |
comparison
equal
deleted
inserted
replaced
43075:57875cf423c9 | 43076:2372284d9457 |
---|---|
42 | 42 |
43 fig = plt.figure() | 43 fig = plt.figure() |
44 comb_plt = fig.add_subplot(211) | 44 comb_plt = fig.add_subplot(211) |
45 other_plt = fig.add_subplot(212) | 45 other_plt = fig.add_subplot(212) |
46 | 46 |
47 comb_plt.plot(ary[0], | 47 comb_plt.plot( |
48 np.cumsum(ary[1]), | 48 ary[0], np.cumsum(ary[1]), color='red', linewidth=1, label='comb' |
49 color='red', | 49 ) |
50 linewidth=1, | |
51 label='comb') | |
52 | 50 |
53 plots = [] | 51 plots = [] |
54 p = other_plt.plot(ary[0], | 52 p = other_plt.plot(ary[0], ary[1], color='red', linewidth=1, label='wall') |
55 ary[1], | |
56 color='red', | |
57 linewidth=1, | |
58 label='wall') | |
59 plots.append(p) | 53 plots.append(p) |
60 | 54 |
61 colors = { | 55 colors = { |
62 10: ('green', 'xkcd:grass green'), | 56 10: ('green', 'xkcd:grass green'), |
63 100: ('blue', 'xkcd:bright blue'), | 57 100: ('blue', 'xkcd:bright blue'), |
64 1000: ('purple', 'xkcd:dark pink'), | 58 1000: ('purple', 'xkcd:dark pink'), |
65 } | 59 } |
66 for n, color in colors.items(): | 60 for n, color in colors.items(): |
67 avg_n = np.convolve(ary[1], np.full(n, 1. / n), 'valid') | 61 avg_n = np.convolve(ary[1], np.full(n, 1.0 / n), 'valid') |
68 p = other_plt.plot(ary[0][n - 1:], | 62 p = other_plt.plot( |
69 avg_n, | 63 ary[0][n - 1 :], |
70 color=color[0], | 64 avg_n, |
71 linewidth=1, | 65 color=color[0], |
72 label='avg time last %d' % n) | 66 linewidth=1, |
67 label='avg time last %d' % n, | |
68 ) | |
73 plots.append(p) | 69 plots.append(p) |
74 | 70 |
75 med_n = scipy.signal.medfilt(ary[1], n + 1) | 71 med_n = scipy.signal.medfilt(ary[1], n + 1) |
76 p = other_plt.plot(ary[0], | 72 p = other_plt.plot( |
77 med_n, | 73 ary[0], |
78 color=color[1], | 74 med_n, |
79 linewidth=1, | 75 color=color[1], |
80 label='median time last %d' % n) | 76 linewidth=1, |
77 label='median time last %d' % n, | |
78 ) | |
81 plots.append(p) | 79 plots.append(p) |
82 | 80 |
83 formatter = mticker.ScalarFormatter() | 81 formatter = mticker.ScalarFormatter() |
84 formatter.set_scientific(False) | 82 formatter.set_scientific(False) |
85 formatter.set_useOffset(False) | 83 formatter.set_useOffset(False) |
106 if visible: | 104 if visible: |
107 legline.set_alpha(1.0) | 105 legline.set_alpha(1.0) |
108 else: | 106 else: |
109 legline.set_alpha(0.2) | 107 legline.set_alpha(0.2) |
110 fig.canvas.draw() | 108 fig.canvas.draw() |
109 | |
111 if title is not None: | 110 if title is not None: |
112 fig.canvas.set_window_title(title) | 111 fig.canvas.set_window_title(title) |
113 fig.canvas.mpl_connect('pick_event', onpick) | 112 fig.canvas.mpl_connect('pick_event', onpick) |
114 | 113 |
115 plt.show() | 114 plt.show() |