In [1]:
import git
import pandas as pd
import matplotlib.dates as mdates
import datetime


/Applications/Canopy.app/appdata/canopy-1.0.3.1262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages/pytz/__init__.py:35: UserWarning: Module argparse was already imported from /Applications/Canopy.app/appdata/canopy-1.0.3.1262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/argparse.pyc, but /Users/arokem/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages is being added to sys.path
  from pkg_resources import resource_stream

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]:
{'Ariel Rokem': 273,
 'Bago Amirbekian': 285,
 'Christopher Nguyen': 53,
 'Eleftherios Garyfallidis': 936,
 'Emanuele Olivetti': 5,
 'Emmanuel Caruyer': 3,
 'Erik Ziegler': 11,
 'Ian Nimmo-Smith': 145,
 'Jean-Christophe Houde': 1,
 'Maria Luisa Mandelli': 1,
 'Matthew Brett': 432,
 'Matthias Ekman': 3,
 'Matthieu Dumont': 62,
 'Maxime Descoteaux': 18,
 'Michael Paquette': 5,
 'Samuel St-Jean': 39,
 'Stefan van der Walt': 75,
 'Yaroslav Halchenko': 7,
 'endolith': 4,
 'smerlet': 1}

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]:
<matplotlib.text.Text at 0x110769b10>