summaryrefslogtreecommitdiff
path: root/diffs.py
blob: 8eb0088502de47d64a1a6706cbe1d0a408f2aac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
from datetime import datetime
from phabricator import Phabricator
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as st
from sklearn.datasets.samples_generator import make_blobs

start = datetime(year=2020, month=7, day=1)


def format_stamp(stamp):
    dt = datetime.utcfromtimestamp(stamp)
    date = (dt - start).days
    time = dt.hour + dt.minute / 60.0
    return [date, time]


phab = Phabricator()  # This will use your ~/.arcrc file
diff = phab.differential.query()

dates = []
for d in diff:
    created = format_stamp(int(d["dateCreated"]))
    modified = format_stamp(int(d["dateModified"]))
    dates += [created, modified]

# Extract x and y
x = [i for i, j in dates]
y = [j for i, j in dates]
# Define the borders
xmin = 0
xmax = 60
ymin = 0
ymax = 24
print(xmin, xmax, ymin, ymax)
# Create meshgrid
xx, yy = np.mgrid[xmin:xmax:100j, ymin:ymax:100j]

positions = np.vstack([xx.ravel(), yy.ravel()])
values = np.vstack([x, y])
kernel = st.gaussian_kde(values)
f = np.reshape(kernel(positions).T, xx.shape)

print(f)

fig = plt.figure(figsize=(13, 7))
ax = plt.axes(projection='3d')
surf = ax.plot_surface(xx, yy, f, rstride=1, cstride=1, cmap='coolwarm', edgecolor='none')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('PDF')
ax.set_title('Surface plot of Gaussian 2D KDE')
fig.colorbar(surf, shrink=0.5, aspect=5) # add color bar indicating the PDF
ax.view_init(90, -90)

plt.show()

#h =plt.hist2d(x, y)
#plt.colorbar(h[3])
#plt.show()


#plt.scatter(X[:, 0], X[:, 1], s=50, c = truth)
#plt.title(f"Example of a mixture of {n_components} distributions")
#plt.xlabel("x")
#plt.ylabel("y");