Skip to content

Commit

Permalink
Merge pull request #21 from qua-platform/feat/channels-conflicting-of…
Browse files Browse the repository at this point in the history
…fsets

Change differing channel offsets from error to warning
  • Loading branch information
nulinspiratie authored Mar 14, 2024
2 parents a609301 + 6d4d061 commit 5673a22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions quam/components/channels.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from dataclasses import field
from typing import ClassVar, Dict, List, Optional, Tuple, Union
import warnings

from quam.components.hardware import BaseFrequencyConverter, Mixer, LocalOscillator
from quam.components.pulses import Pulse, ReadoutPulse
Expand Down Expand Up @@ -427,10 +428,11 @@ def apply_to_config(self, config: dict):
offset = self.opx_output_offset
if offset is not None:
if abs(analog_output.get("offset", offset) - offset) > 1e-4:
raise ValueError(
warnings.warn(
f"Channel {self.name} has conflicting output offsets: "
f"{analog_output['offset']} and {offset}. Multiple channel "
f"elements are trying to set different offsets to port {port}"
f"{analog_output['offset']} V and {offset} V. Multiple channel "
f"elements are trying to set different offsets to port {port}. "
f"Using the last offset {offset} V"
)
analog_output["offset"] = offset

Expand Down Expand Up @@ -707,10 +709,11 @@ def apply_to_config(self, config: dict):
# If no offset specified, it will be added at the end of config generation
if offset is not None:
if abs(analog_input.get("offset", offset) - offset) > 1e-4:
raise ValueError(
warnings.warn(
f"Channel {self.name} has conflicting input offsets: "
f"{analog_input['offset']} and {offset}. Multiple channel "
f"elements are trying to set different offsets to port {port}"
f"{analog_input['offset']} V and {offset} V. Multiple channel "
f"elements are trying to set different offsets to port {port}. "
f"Using the last offset {offset} V"
)
analog_input["offset"] = offset

Expand Down
2 changes: 1 addition & 1 deletion tests/components/channels/test_single_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_single_channel_differing_offsets(bare_cfg):

cfg = deepcopy(bare_cfg)
channel1.apply_to_config(cfg)
with pytest.raises(ValueError):
with pytest.warns(UserWarning):
channel2.apply_to_config(cfg)

cfg = deepcopy(bare_cfg)
Expand Down

0 comments on commit 5673a22

Please sign in to comment.