-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
52 lines (40 loc) · 1.4 KB
/
test.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
import sys
import subprocess
import numpy as np
import matplotlib.pyplot as plt
import math
def plot(points, file):
axis_font = {"color": "black", "weight": "normal", "size": 16}
title_font = {"family": "serif", "color": "black", "weight": "normal", "size": 16}
rng1 = []
z = []
for point in points:
try:
rng1.append(float(point[0]))
z.append(float(point[1]))
except Exception:
continue
# M /= len(points)
# rng = np.linspace(start=float(points[0][0]), stop=float(points[-1][0]), num=len(points))
# y = []
# for value in rng:
# # if value:
# y.append(math.log2(value))
plt.style.use('seaborn-ticks')
plt.grid(color='grey', linestyle='-', linewidth=0.5)
plt.xlabel("$n$", fontdict=axis_font)
plt.ylabel("$O$", fontdict=title_font)
# plt.plot(rng, y, linestyle="--", linewidth=1.0, color="red")
plt.plot(rng1, z)
plt.axis("tight")
plt.savefig(file)
plt.show()
with open(sys.argv[1], 'r') as c_file:
parameters = c_file.readline()
process_cmd = ['./build/Proiect_SD'] + [c.strip('\n') for c in parameters.split(' ')]
raw_result = subprocess.check_output(process_cmd)
# print(raw_result)
result = [pair.split(' ') for pair in raw_result.decode('utf-8').split('\n') if len(pair)]
# print(result)
# print(result)
plot(result, sys.argv[1] + "_out.eps")