Skip to content

Commit e7f31d3

Browse files
committed
added foundry precision argument to plot parameter history
1 parent c813df8 commit e7f31d3

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/axiomatic/pic_helpers.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ def plot_interactive_spectra(
197197
fig.show()
198198

199199

200-
def plot_parameter_history(parameters: List[Parameter], parameter_history: List[dict]):
200+
def plot_parameter_history(
201+
parameters: List[Parameter], parameter_history: List[dict], foundry_precision: Optional[float] = None
202+
):
201203
"""
202204
Plots the history of specified parameters over iterations.
203205
Args:
@@ -218,11 +220,22 @@ def plot_parameter_history(parameters: List[Parameter], parameter_history: List[
218220
plt.xlabel("Iterations")
219221
plt.ylabel(param.path)
220222
split_param = param.path.split(",")
223+
param_vals = None
221224
if "," in param.path:
222225
split_param = param.path.split(",")
223-
plt.plot([parameter_history[i][split_param[0]][split_param[1]] for i in range(len(parameter_history))])
226+
param_vals = [parameter_history[i][split_param[0]][split_param[1]] for i in range(len(parameter_history))]
227+
if foundry_precision is not None:
228+
lower_bound = [val - foundry_precision for val in param_vals]
229+
upper_bound = [val + foundry_precision for val in param_vals]
230+
plt.plot(range(len(parameter_history)), param_vals)
231+
plt.fill_between(range(len(parameter_history)), lower_bound, upper_bound, color="b", alpha=0.1)
232+
233+
# Parameters not linked to a component will not be a physical parameter linked to a measurement
234+
# and will not have a foundry precision
224235
else:
225-
plt.plot([parameter_history[i][param.path] for i in range(len(parameter_history))])
236+
param_vals = [parameter_history[i][param.path] for i in range(len(parameter_history))]
237+
plt.plot(range(len(parameter_history)), param_vals, color="b")
238+
226239
plt.show()
227240

228241

@@ -331,7 +344,7 @@ def print_statements(
331344
if val.holds is not None:
332345
holds_tag = "holds" if val.holds else "not-hold"
333346
else:
334-
holds_tag = ''
347+
holds_tag = ""
335348
html_parts.append(f'<div class="block {holds_tag}">')
336349
html_parts.append(f"<h2>{param_stmt.type}</h2>")
337350
html_parts.append(f'<p><span class="label">Statement:</span> {param_stmt.text}</p>')
@@ -362,11 +375,11 @@ def print_statements(
362375
):
363376
if struct_stmt.formalization is None and only_formalized:
364377
continue
365-
378+
366379
if val.holds is not None:
367380
holds_tag = "holds" if struct_val.holds else "not-hold"
368381
else:
369-
holds_tag = ''
382+
holds_tag = ""
370383
html_parts.append(f'<div class="block {holds_tag}">')
371384
html_parts.append(f"<h2>{struct_stmt.type}</h2>")
372385
html_parts.append(f'<p><span class="label ">Statement:</span> {struct_stmt.text}</p>')
@@ -404,7 +417,7 @@ def print_statements(
404417
final_html = "\n".join(html_parts)
405418

406419
# Display the HTML string
407-
from IPython.display import display, HTML # type: ignore
420+
from IPython.display import HTML, display # type: ignore
408421

409422
display(HTML(final_html))
410423
else:

0 commit comments

Comments
 (0)