-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproof_of_concept_04_charts.py
More file actions
82 lines (66 loc) · 2.24 KB
/
Copy pathproof_of_concept_04_charts.py
File metadata and controls
82 lines (66 loc) · 2.24 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
import json
import matplotlib.pyplot as plt
from collections import defaultdict, Counter
import os
# =======================
# INITIAL CONFIGURATION
# =======================
TRACEABILITY_FILE = 'proof_of_concept/traceability_map.json'
OUTPUT_DIR = 'analysis_charts'
# Create output directory if it doesn't exist
os.makedirs(OUTPUT_DIR, exist_ok=True)
# Relevant tags per research question
TAG_GROUPS = {
'testing_needed': ['testing', 'fix', 'error'],
'mock_usage': ['mock'],
'refactor_needed': ['mock', 'refactor'],
'high_activity': ['testing', 'model', 'config'],
'ci_cd_issues': ['config', 'model', 'fix'],
}
# Nice titles for the charts
TITLES = {
'testing_needed': '🔬 Features that need more testing',
'mock_usage': '🧪 Features with heavy mock usage',
'refactor_needed': '🔧 Features requiring refactor for testability',
'high_activity': '📈 Most active features (testing, model, config)',
'ci_cd_issues': '⚙️ Features with CI/CD issues',
}
# =======================
# LOAD DATA
# =======================
with open(TRACEABILITY_FILE) as f:
traceability_map = json.load(f)
# Group by feature and count tags
feature_tag_count = defaultdict(Counter)
for feature, source_type, tag in traceability_map:
feature_tag_count[feature][tag] += 1
# Helper function to sum tag counts per group
def sum_tags(counter, tags):
return sum(counter[tag] for tag in tags)
# =======================
# GENERATE CHARTS
# =======================
def generate_chart(question_key, tags):
data = [
(feature, sum_tags(counter, tags))
for feature, counter in feature_tag_count.items()
if sum_tags(counter, tags) > 0
]
if not data:
return
data.sort(key=lambda x: x[1], reverse=True)
features, counts = zip(*data)
plt.figure(figsize=(10, 5))
plt.bar(features, counts)
plt.title(TITLES[question_key])
plt.ylabel('Occurrences')
plt.xlabel('Feature')
plt.xticks(rotation=45, ha='right')
plt.tight_layout()
output_path = os.path.join(OUTPUT_DIR, f'{question_key}.png')
plt.savefig(output_path)
plt.close()
print(f'[✓] Chart generated: {output_path}')
# Generate all charts
for key, tags in TAG_GROUPS.items():
generate_chart(key, tags)