In [1]:
import git
import pandas as pd
import matplotlib.dates as mdates
import datetime
In [2]:
years = mdates.YearLocator() # every year
months = mdates.MonthLocator() # every month
yearsFmt = mdates.DateFormatter('%Y')
In [3]:
repo_dir = '/Users/arokem/source/dipy/'
In [4]:
R = git.Repo(repo_dir)
In [5]:
log = R.log()
In [6]:
c = log[-1]
In [8]:
dd = {}
time = []
author = []
n_authors = 0
cum_authors = []
duplicate_authors = {'Ariel Rokem': ['Ariel Rokem', 'arokem'],
'Bago Amirbekian': ['MrBago', 'Bago Amirbekian'],
'Christopher Nguyen': ['Christopher Nguyen', 'Christopher'],
'Ian Nimmo-Smith': ['Ian Nimmo-Smith', 'iannimmosmith'],
'Maxime Descoteaux' : ['Maxime Descoteaux', 'mdesco'],
'Eleftherios Garyfallidis': ['Eleftherios Garyfallidis', 'Dipy Developers']}
for c in log[-1::-1]:
time.append(datetime.datetime(c.committed_date.tm_year, c.committed_date.tm_mon, c.committed_date.tm_mday))
author = c.committer.name
duplicate = False
for k in duplicate_authors:
if author in duplicate_authors[k]:
author = k
if dd.has_key(author):
dd[author]+=1
else:
n_authors +=1
dd[author] = 1
cum_authors.append(n_authors)
In [9]:
dd
Out[9]:
In [18]:
tags = R.tags[:2]
tag_times = [datetime.datetime(t.commit.committed_date.tm_year,
t.commit.committed_date.tm_mon,
t.commit.committed_date.tm_mday) for t in tags]
In [10]:
ts = pd.Series(cum_authors, index=time)
In [39]:
fig, ax = plt.subplots(1)
ax = ts.plot(use_index=True)
ax.figure.autofmt_xdate()
ax.set_ylim([0,21])
ax.arrow(tag_times[0], 2, 0, -2)
ax.text(tag_times[0], 2.5, 'rel0.5', horizontalalignment='center')
ax.arrow(tag_times[1], 2, 0, -2)
ax.text(tag_times[1], 2.5, 'rel0.6', horizontalalignment='center')
Out[39]: