Loading quantify_scheduler/pulse_library.py +72 −67 Original line number Diff line number Diff line Loading @@ -484,7 +484,15 @@ class DRAGPulse(Operation): return self._get_signature(pulse_info) class DCCompensationPulse(SquarePulse): def create_dc_compensation_pulse( pulses: List[Operation], sampling_rate: int, port: str, t0: float = 0, amp: Optional[float] = None, duration: Optional[float] = None, data: Optional[Dict[str, Any]] = None, ) -> SquarePulse: """ Calculates a SquarePulse to counteract charging effects based on a list of pulses. Loading @@ -492,6 +500,9 @@ class DCCompensationPulse(SquarePulse): ---------- pulses List of pulses to compensate sampling_rate Resolution to calculate the enclosure of the pulses to calculate the area to compensate. amp Desired amplitude of the DCCompensationPulse. Leave to None to calculate the value for compensation, Loading @@ -518,24 +529,18 @@ class DCCompensationPulse(SquarePulse): The operation's dictionary, by default None Note: if the data parameter is not None all other parameters are overwritten using the contents of data. """ def __init__( self, pulses: List[Operation], sampling_rate: int, port: str, t0: float = 0, amp: Optional[float] = None, duration: Optional[float] = None, data: Optional[Dict[str, Any]] = None, ) -> None: Returns ------- : Returns a SquarePulse object that compensates all pulses passed as argument """ # Make sure that the list contains at least one element assert len(pulses) > 0 pulse_info_list: List[Dict[str, Any]] = DCCompensationPulse._extract_pulses( pulses, port ) pulse_info_list: List[Dict[str, Any]] = _extract_pulses(pulses, port) # Calculate the area given by the list of pulses area: float = area_pulses(pulse_info_list, sampling_rate) Loading @@ -552,14 +557,14 @@ class DCCompensationPulse(SquarePulse): c_amp = -abs(amp) else: c_amp = abs(amp) c_duration = area / c_amp c_duration = abs(area / c_amp) else: raise ValueError( "The `DCCompensationPulse` allows either amp or duration to " + "be specified, not both. Both amp and duration were passed." ) super().__init__( return SquarePulse( amp=c_amp, duration=c_duration, port=port, Loading @@ -569,7 +574,7 @@ class DCCompensationPulse(SquarePulse): data=data, ) @staticmethod def _extract_pulses(pulses: List[Operation], port: str) -> List[Dict[str, Any]]: # Collect all pulses for the given port pulse_info_list: List[Dict[str, Any]] = list() Loading tests/scheduler/test_pulse_library.py +7 −5 Original line number Diff line number Diff line Loading @@ -13,8 +13,8 @@ from quantify_scheduler.pulse_library import ( RampPulse, SoftSquarePulse, SquarePulse, create_dc_compensation_pulse, decompose_long_square_pulse, DCCompensationPulse, ) from quantify_scheduler.resources import BasebandClockResource, ClockResource Loading Loading @@ -246,7 +246,7 @@ def test_dccompensation_pulse_amp() -> None: amp=1, duration=1e-8, port="LP", clock=BasebandClockResource.IDENTITY ) pulse2 = DCCompensationPulse( pulse2 = create_dc_compensation_pulse( duration=1e-8, pulses=[pulse0, pulse1], sampling_rate=int(1e9), Loading @@ -259,7 +259,9 @@ def test_dccompensation_pulse_modulated() -> None: clock = ClockResource("clock", 1.0) pulse0 = SquarePulse(amp=1, duration=1e-8, port="LP", clock=clock) with pytest.raises(ValueError): DCCompensationPulse(amp=1, pulses=[pulse0], port="LP", sampling_rate=int(1e9)) create_dc_compensation_pulse( amp=1, pulses=[pulse0], port="LP", sampling_rate=int(1e9) ) def test_dccompensation_pulse_duration() -> None: Loading @@ -270,7 +272,7 @@ def test_dccompensation_pulse_duration() -> None: amp=1, duration=1e-8, port="LP", clock=BasebandClockResource.IDENTITY ) pulse2 = DCCompensationPulse( pulse2 = create_dc_compensation_pulse( amp=1, pulses=[pulse0, pulse1], sampling_rate=int(1e9), Loading @@ -285,7 +287,7 @@ def test_dccompensation_pulse_both_params() -> None: pulse0 = SquarePulse( amp=1, duration=1e-8, port="LP", clock=BasebandClockResource.IDENTITY ) DCCompensationPulse( create_dc_compensation_pulse( amp=1, duration=1e-8, pulses=[pulse0], Loading Loading
quantify_scheduler/pulse_library.py +72 −67 Original line number Diff line number Diff line Loading @@ -484,7 +484,15 @@ class DRAGPulse(Operation): return self._get_signature(pulse_info) class DCCompensationPulse(SquarePulse): def create_dc_compensation_pulse( pulses: List[Operation], sampling_rate: int, port: str, t0: float = 0, amp: Optional[float] = None, duration: Optional[float] = None, data: Optional[Dict[str, Any]] = None, ) -> SquarePulse: """ Calculates a SquarePulse to counteract charging effects based on a list of pulses. Loading @@ -492,6 +500,9 @@ class DCCompensationPulse(SquarePulse): ---------- pulses List of pulses to compensate sampling_rate Resolution to calculate the enclosure of the pulses to calculate the area to compensate. amp Desired amplitude of the DCCompensationPulse. Leave to None to calculate the value for compensation, Loading @@ -518,24 +529,18 @@ class DCCompensationPulse(SquarePulse): The operation's dictionary, by default None Note: if the data parameter is not None all other parameters are overwritten using the contents of data. """ def __init__( self, pulses: List[Operation], sampling_rate: int, port: str, t0: float = 0, amp: Optional[float] = None, duration: Optional[float] = None, data: Optional[Dict[str, Any]] = None, ) -> None: Returns ------- : Returns a SquarePulse object that compensates all pulses passed as argument """ # Make sure that the list contains at least one element assert len(pulses) > 0 pulse_info_list: List[Dict[str, Any]] = DCCompensationPulse._extract_pulses( pulses, port ) pulse_info_list: List[Dict[str, Any]] = _extract_pulses(pulses, port) # Calculate the area given by the list of pulses area: float = area_pulses(pulse_info_list, sampling_rate) Loading @@ -552,14 +557,14 @@ class DCCompensationPulse(SquarePulse): c_amp = -abs(amp) else: c_amp = abs(amp) c_duration = area / c_amp c_duration = abs(area / c_amp) else: raise ValueError( "The `DCCompensationPulse` allows either amp or duration to " + "be specified, not both. Both amp and duration were passed." ) super().__init__( return SquarePulse( amp=c_amp, duration=c_duration, port=port, Loading @@ -569,7 +574,7 @@ class DCCompensationPulse(SquarePulse): data=data, ) @staticmethod def _extract_pulses(pulses: List[Operation], port: str) -> List[Dict[str, Any]]: # Collect all pulses for the given port pulse_info_list: List[Dict[str, Any]] = list() Loading
tests/scheduler/test_pulse_library.py +7 −5 Original line number Diff line number Diff line Loading @@ -13,8 +13,8 @@ from quantify_scheduler.pulse_library import ( RampPulse, SoftSquarePulse, SquarePulse, create_dc_compensation_pulse, decompose_long_square_pulse, DCCompensationPulse, ) from quantify_scheduler.resources import BasebandClockResource, ClockResource Loading Loading @@ -246,7 +246,7 @@ def test_dccompensation_pulse_amp() -> None: amp=1, duration=1e-8, port="LP", clock=BasebandClockResource.IDENTITY ) pulse2 = DCCompensationPulse( pulse2 = create_dc_compensation_pulse( duration=1e-8, pulses=[pulse0, pulse1], sampling_rate=int(1e9), Loading @@ -259,7 +259,9 @@ def test_dccompensation_pulse_modulated() -> None: clock = ClockResource("clock", 1.0) pulse0 = SquarePulse(amp=1, duration=1e-8, port="LP", clock=clock) with pytest.raises(ValueError): DCCompensationPulse(amp=1, pulses=[pulse0], port="LP", sampling_rate=int(1e9)) create_dc_compensation_pulse( amp=1, pulses=[pulse0], port="LP", sampling_rate=int(1e9) ) def test_dccompensation_pulse_duration() -> None: Loading @@ -270,7 +272,7 @@ def test_dccompensation_pulse_duration() -> None: amp=1, duration=1e-8, port="LP", clock=BasebandClockResource.IDENTITY ) pulse2 = DCCompensationPulse( pulse2 = create_dc_compensation_pulse( amp=1, pulses=[pulse0, pulse1], sampling_rate=int(1e9), Loading @@ -285,7 +287,7 @@ def test_dccompensation_pulse_both_params() -> None: pulse0 = SquarePulse( amp=1, duration=1e-8, port="LP", clock=BasebandClockResource.IDENTITY ) DCCompensationPulse( create_dc_compensation_pulse( amp=1, duration=1e-8, pulses=[pulse0], Loading