Skip to content

Commit 5c139f5

Browse files
authored
Merge pull request #29 from Axiomatic-AI/plot-spectra-admits-dicts
admit dictionary as input of plot spectra
2 parents e3216a6 + c6b8078 commit 5c139f5

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/axiomatic/pic_helpers.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import re
2-
import numpy as np # type: ignore
2+
from typing import Dict, List, Optional, Set, Tuple, Union
3+
34
import iklayout # type: ignore
45
import matplotlib.pyplot as plt # type: ignore
6+
import numpy as np # type: ignore
57
import plotly.graph_objects as go # type: ignore
6-
from typing import List, Optional, Tuple, Dict, Set
78

8-
from . import Parameter, StatementDictionary, StatementValidationDictionary, StatementValidation, Computation
9+
from . import Computation, Parameter, StatementDictionary, StatementValidation, StatementValidationDictionary
910

1011

1112
def plot_circuit(component):
@@ -97,7 +98,7 @@ def plot_single_spectrum(
9798

9899

99100
def plot_interactive_spectra(
100-
spectra: List[List[List[float]]],
101+
spectra: Union[List[List[List[float]]], Dict[Tuple[str, str], List[List[float]]]],
101102
wavelengths: List[float],
102103
spectrum_labels: Optional[List[str]] = None,
103104
vlines: Optional[List[float]] = None,
@@ -119,13 +120,18 @@ def plot_interactive_spectra(
119120
"""
120121

121122
# Defaults
122-
if spectrum_labels is None:
123+
if spectrum_labels is None and isinstance(spectra, dict):
124+
spectrum_labels = [f"T {port_in} -> {port_out}" for port_in, port_out in spectra.keys()]
125+
elif spectrum_labels is None:
123126
spectrum_labels = [f"Spectrum {i}" for i in range(len(spectra))]
124127
if vlines is None:
125128
vlines = []
126129
if hlines is None:
127130
hlines = []
128131

132+
if isinstance(spectra, dict):
133+
spectra = list(spectra.values())
134+
129135
# Adjust y-axis range
130136
all_vals = [val for spec in spectra for iteration in spec for val in iteration]
131137
y_min = min(all_vals)

0 commit comments

Comments
 (0)