Skip to content

Commit efdc069

Browse files
committed
Improved formatting
1 parent 27315bd commit efdc069

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

python/generate_measurements.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ def variance(n, sigma_low, sigma_high):
9595
return Sigma_diag
9696

9797

98+
def format_array(a):
99+
"""Convert an array to a form that can be printed
100+
101+
:arg a: array to convert
102+
"""
103+
return "[" + ", ".join([f"{x:.16f}" for x in list(a)]) + "]"
104+
105+
98106
nmeas = 8
99107
dim = 2
100108
dmin = 0.2
@@ -128,10 +136,10 @@ def variance(n, sigma_low, sigma_high):
128136
# Print results in a format that can be used in the configuration file
129137
print("dim = ", args.dim, ";")
130138
print("n = ", args.nmeas, ";")
131-
print("measurement_locations = ", repr(list(p[:-1, :].flatten())), ";")
132-
print("sample_location = ", repr(list(p[-1, :].flatten())), ";")
133-
print("mean = ", repr(list(mean.flatten())), ";")
134-
print("variance = ", repr(list(Sigma_diag.flatten())), ";")
139+
print("measurement_locations = ", format_array(p[:-1, :].flatten()), ";")
140+
print("sample_location = ", format_array(p[-1, :].flatten()), ";")
141+
print("mean = ", format_array(mean.flatten()), ";")
142+
print("variance = ", format_array(Sigma_diag.flatten()), ";")
135143

136144
plt.clf()
137145
fig = plt.figure()

0 commit comments

Comments
 (0)