Skip to content

Commit 25569ab

Browse files
committed
avoid circuit import because of typing
1 parent 4ca02e7 commit 25569ab

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/braket/pulse/waveforms.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
import string
1818
from abc import ABC, abstractmethod
1919
from copy import deepcopy
20-
from typing import Any, Dict, List, Optional, Union
20+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
21+
22+
if TYPE_CHECKING:
23+
from braket.pulse.pulse_sequence import PulseSequence
2124

2225
import numpy as np
2326
import openpulse.ast as ast
@@ -33,10 +36,19 @@
3336

3437

3538
class WaveformDict(dict):
36-
def __init__(self, wf_dict: Dict, pulse_sequence):
37-
for wf in wf_dict.values():
38-
wf._pulse_sequence = pulse_sequence
39-
super().__init__(wf_dict)
39+
"""
40+
A dict of waveforms.
41+
42+
Note:
43+
WaveformDict binds a pulse sequence to each waveform that is
44+
added to the dict. It serves as back reference when a
45+
waveform is modified so the OQpy object is also updated.
46+
"""
47+
48+
def __init__(self, waveform_dict: Dict, pulse_sequence: PulseSequence):
49+
for waveform in waveform_dict.values():
50+
waveform._pulse_sequence = pulse_sequence
51+
super().__init__(waveform_dict)
4052
self._pulse_sequence = pulse_sequence
4153

4254
def __setitem__(self, key: str, value: Waveform):

0 commit comments

Comments
 (0)