Skip to content

Commit

Permalink
fix a bug in find_pulse
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxiLi committed May 2, 2021
1 parent c11dc37 commit a57e3c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/qutip_qip/device/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,10 @@ def get_pulse_dict(self):
return label_list

def find_pulse(self, pulse_name):
pulse_dict = self.get_pulse_dict()
if isinstance(pulse_name, str):
try:
return self.pulses[self.pulse_dict[pulse_name]]
return self.pulses[pulse_dict[pulse_name]]
except (KeyError):
raise KeyError(
"Pulse name {} undefined. "
Expand Down
7 changes: 6 additions & 1 deletion tests/test_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def testChooseSolver(self):
result = proc.run_state(init_state=init_state, solver="mcsolve")
assert_allclose(
fidelity(result.states[-1], qubit_states(2, [0, 1, 0, 0])),
1, rtol=1.e-7)
1, rtol=1.e-7)

def test_no_saving_intermidiate_state(self):
processor = Processor(1)
Expand All @@ -352,3 +352,8 @@ def test_no_saving_intermidiate_state(self):
)
result = processor.run_state(basis(2,0), tlist=[0,1])
assert(len(result.states) == 2)

def test_pulse_dict(self):
processor = Processor(1)
processor.add_control(sigmax(), 0, label="test")
assert("test" in processor.get_pulse_dict())

0 comments on commit a57e3c2

Please sign in to comment.