import pandas as pd
import altair
from altair import X, Y
def whitelist_length(node: str):
res = !hg cat "contrib/python3-whitelist" --rev {node}|wc -l
return res[0]
def testsuite_length(node: str):
res = !hg log -T "{{count(files('tests/*.t'))}}" --rev {node}
return res[0]
!hg log contrib/python3-whitelist -Tjson > py3_whitelist.json
py3_whitelist = pd.read_json('py3_whitelist.json')
!hg log -k py3 -k 'Python 3' -Tjson > py3_changes.json
py3_changes = pd.read_json('py3_changes.json')
def cleanup(df) -> None:
# Convert dates (acounting for the tz) to second-based unix epoch
time = pd.DataFrame(list(df.date), columns=["a", "b"])
df["time"] = pd.to_datetime(time.a + time.b, unit="s")
# Get contributors names
df["fame"] = pd.DataFrame(df.user.str.split(" <").tolist(), columns=["user", '_']).user
cleanup(py3_whitelist)
cleanup(py3_changes)
altair.Chart(py3_changes).mark_bar().encode(
x=X("yearmonth(time)"),
y="count(*):Q",
color = "fame"
).interactive()
# ask hg about the number of whitelisted py3 tests as well as the number of tests in total
py3_whitelist["whitelisted"] = py3_whitelist.node.apply(whitelist_length)
py3_whitelist["testsuite"] = py3_whitelist.node.apply(testsuite_length)
altair.Chart(py3_whitelist[["time", "whitelisted", "testsuite"]].melt('time')).mark_line().encode(
x='time:T',
y='value:Q',
color='variable'
).interactive()
altair.Chart(py3_changes).mark_bar().encode(
x='count(*):N',
y=Y('fame:N')
)
py3_whitelist.query("time == time.max()")[["whitelisted", "testsuite"]]