In [1]:
import pandas as pd
import altair
from altair import X, Y
In [2]:
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]
In [3]:
!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')
In [4]:
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)
In [5]:
altair.Chart(py3_changes).mark_bar().encode(
    x=X("yearmonth(time)"),
    y="count(*):Q",
    color = "fame"
).interactive()
Out[5]:
In [6]:
# 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)
In [7]:
altair.Chart(py3_whitelist[["time", "whitelisted", "testsuite"]].melt('time')).mark_line().encode(
    x='time:T',
    y='value:Q',
    color='variable'
).interactive()
Out[7]:
In [8]:
altair.Chart(py3_changes).mark_bar().encode(
    x='count(*):N',
    y=Y('fame:N')
)
Out[8]:
In [9]:
py3_whitelist.query("time == time.max()")[["whitelisted", "testsuite"]]
Out[9]:
whitelisted testsuite
1 749 748
In [ ]: