Skip to content

Commit

Permalink
Merge branch 'master' into implement-shift-frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
SooluThomas authored May 12, 2020
2 parents b41428f + 607bdf5 commit 9bc78b4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions qiskit/qobj/converters/pulse_instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def convert_set_frequency(self, shift, instruction):
'name': 'setf',
't0': shift+instruction.start_time,
'ch': instruction.channel.name,
'frequency': instruction.frequency
'frequency': instruction.frequency / 1e9
}
return self._qobj_model(**command_dict)

Expand Down Expand Up @@ -551,7 +551,7 @@ def convert_set_frequency(self, instruction):
"""
t0 = instruction.t0
channel = self.get_channel(instruction.ch)
frequency = instruction.frequency
frequency = instruction.frequency * 1e9

if isinstance(frequency, str):
frequency_expr = parse_string_expr(frequency, partial_binding=False)
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/bugfix-set-frequency-29608d213a8cbece.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
Fixed the SI unit conversion for :py:class:`qiskit.pulse.SetFrequency`. The
``SetFrequency`` instruction should be in Hz on the frontend and has to be
converted to GHz when ``SetFrequency`` is converted to ``PulseQobjInstruction``.
4 changes: 2 additions & 2 deletions test/python/qobj/test_pulse_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_frame_change(self):
def test_set_frequency(self):
"""Test converted qobj from SetFrequency."""
converter = InstructionToQobjConverter(PulseQobjInstruction, meas_level=2)
instruction = SetFrequency(8.0, DriveChannel(0))
instruction = SetFrequency(8.0e9, DriveChannel(0))

valid_qobj = PulseQobjInstruction(
name='setf',
Expand Down Expand Up @@ -316,7 +316,7 @@ def test_frame_change(self):

def test_set_frequency(self):
"""Test converted qobj from SetFrequency."""
instruction = SetFrequency(8.0, DriveChannel(0))
instruction = SetFrequency(8.0e9, DriveChannel(0))

qobj = PulseQobjInstruction(name='setf', ch='d0', t0=0, frequency=8.0)
converted_instruction = self.converter(qobj)
Expand Down
2 changes: 1 addition & 1 deletion test/python/qobj/test_qobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def setUp(self):
PulseQobjInstruction(name='fc', t0=5, ch='d0', phase='P1'),
PulseQobjInstruction(name='pv', t0=10, ch='d0', val=0.1 + 0.0j),
PulseQobjInstruction(name='pv', t0=10, ch='d0', val='P1'),
PulseQobjInstruction(name='setf', t0=10, ch='d0', frequency=8.),
PulseQobjInstruction(name='setf', t0=10, ch='d0', frequency=8.0),
PulseQobjInstruction(name='shiftf', t0=10, ch='d0', frequency=4.0),
PulseQobjInstruction(name='acquire', t0=15, duration=5,
qubits=[0], memory_slot=[0],
Expand Down

0 comments on commit 9bc78b4

Please sign in to comment.