view python/repostats.py2 @ 189:5334b86ac1db

Added pyqt unittest
author Windel Bouwman
date Sat, 25 May 2013 15:04:44 +0200
parents aaa4939a7942
children
line wrap: on
line source

#!/usr/bin/python2

import sys
# Use python 2 since mercurial does not support python 3 yet?
assert sys.version_info.major == 2

from mercurial import ui, hg
import numpy
import matplotlib.pyplot as plt
import datetime

u = ui.ui()
repo = hg.repository(u, '..')

stamps = []
nds = repo.changelog.nodesbetween()[0]
for hexid in nds:
   cset = repo.changelog.read(hexid)
   stamps.append(cset[2][0])

dts = [datetime.datetime.fromtimestamp(st) for st in stamps]

x = [dt.weekday() for dt in dts]
y = [dt.hour for dt in dts]

# plot it:
f = plt.figure()
#plt.hexbin(x, y)
plt.scatter(x, y)
ax = plt.gca()
ax.set_ylim([0, 24])
ax.set_ylabel('hour of day')
ax.set_xlim([0, 7])
ax.set_xlabel('day of week')
ax.grid()
plt.show()