-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_memory.py
More file actions
70 lines (55 loc) · 2.22 KB
/
plot_memory.py
File metadata and controls
70 lines (55 loc) · 2.22 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
import matplotlib.pyplot as plt
import numpy as np
from os import listdir,chdir
import pandas as pd
print(listdir())
chdir('Tensor_Networks_topology\\mps_ordering')
print(listdir())
# results = np.loadtxt('results.txt')
# N,CHI,RES_tree,RES_mps,RES_omps,MEM_tree,MEM_mps,MEM_omps = zip(*results)
df_results = pd.read_csv('results_df')
N = df_results['N']
CHI = df_results['chi']
RES_tree = df_results['f_tree']
RES_mps = df_results['fidelity_mps']
RES_omps = df_results['fidelity_omps']
MEM_tree = df_results['mem_tree']
MEM_mps = df_results['mem_mps']
MEM_omps = df_results['mem_omps']
chi_range = range(int(np.min(CHI)),int(np.max(CHI))+1,int(CHI[1]-CHI[0]))
N_gate_range = range(int(np.min(N)),int(np.max(N))+1,int(N[len(chi_range)]-N[0]))
# RES = np.array(RES).reshape(len(N),len(CHI))
N = np.array(N).reshape(len(N_gate_range),len(chi_range))
CHI = np.array(CHI).reshape(len(N_gate_range),len(chi_range))
RES_tree = np.array(RES_tree).reshape(len(N_gate_range),len(chi_range))
RES_mps = np.array(RES_mps).reshape(len(N_gate_range),len(chi_range))
RES_omps = np.array(RES_omps).reshape(len(N_gate_range),len(chi_range))
MEM_tree = np.array(MEM_tree).reshape(len(N_gate_range),len(chi_range))
MEM_mps = np.array(MEM_mps).reshape(len(N_gate_range),len(chi_range))
MEM_omps = np.array(MEM_omps).reshape(len(N_gate_range),len(chi_range))
# plt.plot(MEM_tree[i],RES_tree[i],color='g')
# plt.plot(MEM_mps[i],RES_mps[i],color='r')
# plt.show()
fig = plt.figure()
gs = fig.add_gridspec(1, len(N.T[0]), hspace=0, wspace=0)
axes = gs.subplots(sharex='col', sharey='row')
fig.suptitle('Fidelity by Nb of Coef for different number of Gates')
fig.supxlabel('Nb Coef')
fig.supylabel('Fidelity')
# fig, axes = plt.subplots(1,9,sharey=True)
for i in range(len(N.T[0])):
axes[i].plot(MEM_tree[i],RES_tree[i],color = 'g',label = 'Tree')
axes[i].plot(MEM_mps[i],RES_mps[i],color = 'r',label = 'Mps')
axes[i].plot(MEM_omps[i],RES_omps[i],color = 'b',label = 'oMps')
axes[i].set_title('N='+str(int(N.T[0][i])))
axes[-1].legend()
# for ax in axes.flat:
# ax.set(xlabel='Nb Coef', ylabel='Fidelity')
for ax in axes.flat:
ax.label_outer()
plt.tight_layout()
plt.show()
# print(N.T.shape)
# print(CHI.shape)
# print(MEM_tree.shape)
# print(RES_tree.shape)