-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathTests_G9.py
127 lines (107 loc) · 3.57 KB
/
Tests_G9.py
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
import sys
from os import getcwd
from os.path import join
from collections import Counter
from rich.console import Console
from rich.table import Table
sys.path.append(join(getcwd(), "openunderstand"))
sys.path.append(join(getcwd(), "openunderstand", "oudb"))
sys.path.append(join(getcwd(), "openunderstand", "utils"))
import openunderstand.ounderstand as und
_db = und.open("/home/mehran/Downloads/OpenUnderstand/hw.udb")
dbents = _db.ents()
def understandout(ou, ouanswer):
import os
import sys
sys.path.append(
"/home/mehran/Downloads/Scientific.Toolworks.Understand.5.1.1023.Linux/Understand-5.1.1023-Linux-64bit/scitools/bin/linux64/Python"
)
import understand
db = understand.open(
"/home/mehran/Downloads/OpenUnderstand/benchmark/hw6test/hw6test.udb"
)
dbents = db.ents()
unders = []
counter = 0
for i in dbents:
for ref in sorted(
i.refs("Set Partial"), key=lambda x: x.line()
): # Sort by line numbers
print("Under =====> ", ref.ent().name(), ref.line())
unders.append(ref.line())
counter += 1
# Count occurrences of each element in the lists
count1 = Counter(ou)
count2 = Counter(unders)
# Find elements that are in one Counter but not in the other, considering counts
unique_to_openunderstand = {
key: count1[key]
for key in count1
if key not in count2 or count1[key] > count2[key]
}
unique_to_understand = {
key: count2[key]
for key in count2
if key not in count1 or count2[key] > count1[key]
}
# Create and print a table
table = Table(
title="Number of Set Partials", show_header=True, header_style="bold magenta"
)
table.add_column("OpenUnderstand", style="dim", justify="center")
table.add_column("Understand", style="dim", justify="center")
for key, count in unique_to_openunderstand.items():
table.add_row(str(key), "")
for key, count in unique_to_understand.items():
table.add_row("", str(key))
# Add counter and ouanswer to the table
table.add_row(f"OU: {ouanswer}", f"U: {counter}")
console = Console()
console.print(table)
# Print the unique elements
print(
"Elements unique to OpenUnderstand:",
[key for key, count in unique_to_openunderstand.items()],
)
print(
"Elements unique to Understand:",
[key for key, count in unique_to_understand.items()],
)
print("\n--------------Set--------------")
counter = 0
openunderstandOutput = []
for i in dbents:
for ref in sorted(
i.refs("Set Partial"), key=lambda y: y.line()
): # Sort by line numbers
print("OpenUnder =====> ", ref.ent().name(), ref.line())
openunderstandOutput.append(ref.line())
counter += 1
ouanswer = counter
understandout(openunderstandOutput, ouanswer)
# ref.kindname [OK]
# ref.kind [OK]
# ref.line [OK]
# ref.column [OK]
# ref.file [OK]
# ref.ent() [OK]
# ref.ent().name [OK]
# ref.ent().longname [OK]
# ref.ent().refs [API Error]
# ref.ent().ents [API Error]
# ref.ent().parent [Close] LATER
# ref.ent().type [Not OK]
# ref.ent().kind [Not OK But i know how to fix]
# ref.ent().kindName [Just like above]
# ref.ent().value [NOT BAD]
# ref.ent().filerefs [Ok]
# ref.scope() [Not OK]
# ref.scope().value [Close]
# ref.scope().longname [OK]
# ref.scope().kind [like ent().kind]
# ref.scope().type [OK]
# ref.scope().value [OK]
# ref.scope().contents [OK (Space problem from somewhere else)]
# ref.scope().name [Not OK]
# ref.scope().kindname [just like kind]
# ref.scope().parent [Error]