diff --git a/CHANGELOG.md b/CHANGELOG.md index e8860f1..5563f01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [Unreleased] +### Changed +- `Pulse.integration_weights` now defaults to `#./default_integration_weights`, which returns [(1, pulse.length)] + ## [0.3.8] ### Added - Added time tagging to channels diff --git a/quam/components/pulses.py b/quam/components/pulses.py index e8ec75f..aeb6abb 100644 --- a/quam/components/pulses.py +++ b/quam/components/pulses.py @@ -460,17 +460,21 @@ class ReadoutPulse(BaseReadoutPulse, ABC): integration weights in radians. """ - integration_weights: Union[List[float], List[Tuple[float, int]]] = None + integration_weights: Union[List[float], List[Tuple[float, int]]] = ( + "#./default_integration_weights" + ) integration_weights_angle: float = 0 + @property + def default_integration_weights(self) -> List[Tuple[float, int]]: + return [(1, self.length)] + def integration_weights_function(self) -> List[Tuple[Union[complex, float], int]]: from qualang_tools.config import convert_integration_weights phase = np.exp(1j * self.integration_weights_angle) - if self.integration_weights is None or not len(self.integration_weights): - integration_weights = [(1, self.length)] - elif isinstance(self.integration_weights[0], float): + if isinstance(self.integration_weights[0], float): integration_weights = convert_integration_weights(self.integration_weights) else: integration_weights = self.integration_weights diff --git a/tests/components/pulses/test_pulse_weights.py b/tests/components/pulses/test_pulse_weights.py index 8032f64..1813305 100644 --- a/tests/components/pulses/test_pulse_weights.py +++ b/tests/components/pulses/test_pulse_weights.py @@ -24,20 +24,22 @@ def test_constant_readout_pulse_integration_weights_default(): compare_integration_weights(expected_weights, weights) +def test_default_integration_weights(): + pulse = pulses.SquareReadoutPulse(length=100, amplitude=1) + assert pulse.default_integration_weights == [(1, 100)] + + def test_empty_integration_weights(): - for weights in ([], np.array([]), None): - pulse = pulses.SquareReadoutPulse( - length=100, amplitude=1, integration_weights=weights - ) - - weights = pulse.integration_weights_function() - expected_weights = { - "real": [(1, 100)], - "imag": [(0, 100)], - "minus_real": [(-1, 100)], - "minus_imag": [(0, 100)], - } - compare_integration_weights(expected_weights, weights) + pulse = pulses.SquareReadoutPulse(length=100, amplitude=1) + + weights = pulse.integration_weights_function() + expected_weights = { + "real": [(1, 100)], + "imag": [(0, 100)], + "minus_real": [(-1, 100)], + "minus_imag": [(0, 100)], + } + compare_integration_weights(expected_weights, weights) def test_constant_readout_pulse_integration_weights_phase_shift():