Skip to content

Commit

Permalink
Merge pull request #87 from qua-platform/feat/default-weights
Browse files Browse the repository at this point in the history
Feat: Add default integration weights
  • Loading branch information
nulinspiratie authored Dec 12, 2024
2 parents 1e10748 + 97f7564 commit 4009624
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 8 additions & 4 deletions quam/components/pulses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 15 additions & 13 deletions tests/components/pulses/test_pulse_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 4009624

Please sign in to comment.