Created
November 9, 2019 02:21
-
-
Save saimn/4c4018e1b11ae913d5e4195cdba1d6d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
import re | |
from collections import defaultdict | |
# flake8 --select=E501 astropy/ > pep8length.txt | |
with open('pep8length.txt') as f: | |
text = f.read() | |
matches = re.findall(r'astropy/(.*?)/.*.py:.*(\d\d) > 79 characters', text) | |
stats = defaultdict(list) | |
for module, count in matches: | |
stats[module].append(int(count)) | |
fig, axes = plt.subplots(4, 5, sharex=True, sharey=True) | |
bins = range(75, 105) | |
tot = [] | |
for ax, name in zip(axes.flat, sorted(stats)): | |
arr = np.array(stats[name]) | |
ratio = np.count_nonzero(arr < 88) / arr.shape[0] * 100 | |
tot += stats[name] | |
ax.hist(arr, bins=bins) | |
ax.set_title(f'{name}, {ratio:.0f}% < 88c') | |
ax.axvline(88, lw=1, color='lightgray') | |
arr = np.array(tot) | |
below = np.count_nonzero(arr < 88) | |
ratio = below / arr.shape[0] * 100 | |
fig.suptitle(f'Total: {ratio:.0f}% < 88 chars\n' | |
f'{below} lines < 88 chars ({arr.shape[0]} total)') | |
fig.subplots_adjust() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment