-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmerge_state_RQ6.py
More file actions
159 lines (112 loc) · 4.03 KB
/
Copy pathmerge_state_RQ6.py
File metadata and controls
159 lines (112 loc) · 4.03 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import json
import scipy.stats as stats
import os
# decide whether there are Python files in commit files
def decidePy(commitfile):
flag = False
for file in commitfile:
if file.endswith(".py"):
# print(file)
flag = True
return flag
def calORraw(ismerge,isdyn,dic):
if ismerge == True and isdyn ==True:
dic["mergeDT"] = dic["mergeDT"] + 1
if ismerge == False and isdyn == False:
dic["NmergeNDT"] = dic["NmergeNDT"] + 1
if ismerge == True and isdyn ==False:
dic["mergeNDT"] = dic["mergeNDT"] + 1
if ismerge == False and isdyn == True:
dic["NmergeDT"] = dic["NmergeDT"] + 1
return dic
def smooth(OR_raw_data):
for key in OR_raw_data.keys():
if OR_raw_data[key] == 0:
OR_raw_data[key] = OR_raw_data[key] + 1
def runDT(crawlerfile,dynamicfile):
pulls = json.load(open(crawlerfile,'r'))
dynDic = json.load(open(dynamicfile,'r'))
prefix = crawlerfile.split(".")[0].replace("crawlerResult","dataset")+"/"
# prefix = '/home/xxm/Desktop/EMSE/dataset/auto-sklearn/'
# print pull
OR_raw_data = {"mergeDT":0,"NmergeDT":0,"mergeNDT":0,"NmergeNDT":0}
for pull in pulls:
commitfile = pull["commitfile"]
if decidePy(commitfile):
ismerge= pull["is_merged"]
isdyn = False
# print(type(fixbug))
for file in commitfile.keys():
# print pre + file
if prefix + file in dynDic.keys():
isdyn = True
# print(prefix + file)
OR_raw_data = calORraw(ismerge,isdyn,OR_raw_data)
# print(OR_raw_data)
# smooth
# smooth(OR_raw_data)
oddsratio, pvalue = stats.fisher_exact([[OR_raw_data["mergeDT"], OR_raw_data["NmergeDT"]], [OR_raw_data["mergeNDT"], OR_raw_data["NmergeNDT"]]])
return oddsratio,pvalue
def runRDT(crawlerfile,dynamicfile):
pulls = json.load(open(crawlerfile,'r'))
dynDic = json.load(open(dynamicfile,'r'))
prefix = crawlerfile.split(".")[0].replace("crawlerResult","dataset")+"/"
# prefix = '/home/xxm/Desktop/EMSE/dataset/auto-sklearn/'
# print pull
OR_raw_data = {"mergeDT":0,"NmergeDT":0,"mergeNDT":0,"NmergeNDT":0}
for pull in pulls:
commitfile = pull["commitfile"]
if decidePy(commitfile):
ismerge= pull["is_merged"]
isdyn = False
# print(type(fixbug))
for file in commitfile.keys():
# print pre + file
if prefix + file in dynDic.keys():
isdyn = True
# print(prefix + file)
OR_raw_data = calORraw(ismerge,isdyn,OR_raw_data)
# print(OR_raw_data)
# smooth
# smooth(OR_raw_data)
oddsratio, pvalue = stats.fisher_exact([[OR_raw_data["mergeDT"], OR_raw_data["NmergeDT"]], [OR_raw_data["mergeNDT"], OR_raw_data["NmergeNDT"]]])
return oddsratio,pvalue
def runVDT(crawlerfile,dynamicfile):
pulls = json.load(open(crawlerfile,'r'))
dynDic = json.load(open(dynamicfile,'r'))
prefix = crawlerfile.split(".")[0].replace("crawlerResult","dataset")+"/"
# prefix = '/home/xxm/Desktop/EMSE/dataset/auto-sklearn/'
# print pull
OR_raw_data = {"mergeDT":0,"NmergeDT":0,"mergeNDT":0,"NmergeNDT":0}
for pull in pulls:
commitfile = pull["commitfile"]
if decidePy(commitfile):
ismerge= pull["is_merged"]
isdyn = False
# print(type(fixbug))
for file in commitfile.keys():
# print pre + file
if prefix + file in dynDic.keys():
if "VDT" in dynDic[prefix + file].keys():
isdyn = True
# print(prefix + file)
OR_raw_data = calORraw(ismerge,isdyn,OR_raw_data)
# print(OR_raw_data)
# smooth
# smooth(OR_raw_data)
oddsratio, pvalue = stats.fisher_exact([[OR_raw_data["mergeDT"], OR_raw_data["NmergeDT"]], [OR_raw_data["mergeNDT"], OR_raw_data["NmergeNDT"]]])
return oddsratio,pvalue
def runRQ6():
RQ6list = [("project","OR","pvalue")]
crawlerDir = '/home/xxm/Desktop/EMSE/crawlerResult'
for root, dirs, files in os.walk(crawlerDir):
for file in files:
if not file.startswith("."):
crawlerfile =root+"/"+file
dynamicfile = crawlerfile.replace("crawlerResult","DTResult")
oddsratio,pvalue = runDT(crawlerfile,dynamicfile)
print(file.replace(".json",""),"ismerge","Fisher_exact",oddsratio,pvalue)
RQ6list.append((file.replace(".json",""),oddsratio,pvalue))
return RQ6list
# RQ6list = runRQ6()
# print(RQ6list)