Skip to content

Commit

Permalink
added check for LO frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
nulinspiratie committed Mar 8, 2024
1 parent d4befa0 commit d5c2d12
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 14 deletions.
26 changes: 14 additions & 12 deletions quam/components/octave.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,14 @@ def apply_to_config(self, config: Dict) -> None:
not exist.
KeyError: If the Octave already has an entry for the OctaveUpConverter.
"""
if self.channel is None:
return
if not isinstance(self.LO_frequency, (int, float)):
raise ValueError(
f"Error generating config for Octave upconverter id={self.id}: "
"LO_frequency must be specified."
)
if self.channel is None:
return
else:
raise ValueError(
f"Error generating config for Octave upconverter id={self.id}: "
"LO_frequency must be specified."
)

super().apply_to_config(config)

Expand Down Expand Up @@ -342,13 +343,14 @@ def apply_to_config(self, config: Dict) -> None:
ValueError: If the IF_output_I and IF_output_Q are already assigned to
other ports.
"""
if self.channel is None:
return
if not isinstance(self.LO_frequency, (int, float)):
raise ValueError(
f"Error generating config for Octave upconverter id={self.id}: "
"LO_frequency must be specified."
)
if self.channel is None:
return
else:
raise ValueError(
f"Error generating config for Octave upconverter id={self.id}: "
"LO_frequency must be specified."
)

super().apply_to_config(config)

Expand Down
54 changes: 52 additions & 2 deletions tests/components/test_octave.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def test_frequency_down_converter_with_single_channel_apply_to_config(octave):


def test_instantiate_octave_default_connectivity(octave):
octave.initialize_default_connectivity()
octave.initialize_frequency_converters()

assert list(octave.RF_outputs) == [1, 2, 3, 4, 5]
for idx, RF_output in octave.RF_outputs.items():
Expand Down Expand Up @@ -326,7 +326,7 @@ def test_channel_add_RF_inputs(octave):

def test_load_octave(octave):
machine = OctaveQuAM(octave=octave)
octave.initialize_default_connectivity()
octave.initialize_frequency_converters()

d = machine.to_dict()

Expand All @@ -351,3 +351,53 @@ def test_load_octave(octave):
machine2 = OctaveQuAM.load(d)

assert d == machine2.to_dict()


def test_frequency_converter_config_no_LO_frequency(octave):
cfg = {}
converter = octave.RF_outputs[1] = OctaveUpConverter(id=1)
octave.apply_to_config(config=cfg)

converter.apply_to_config(cfg)

expected_cfg = {
"octaves": {
"octave1": {
"RF_outputs": {},
"RF_inputs": {},
"IF_outputs": {},
"loopbacks": [],
}
}
}
assert cfg == expected_cfg

converter.channel = "something"

with pytest.raises(ValueError):
converter.apply_to_config(cfg)

converter.channel = None
converter.LO_frequency = 2e9

converter.apply_to_config(cfg)

expected_cfg = {
"octaves": {
"octave1": {
"IF_outputs": {},
"RF_inputs": {},
"RF_outputs": {
1: {
"LO_frequency": 2000000000.0,
"LO_source": "internal",
"gain": 0,
"input_attenuators": "off",
"output_mode": "always_off",
}
},
"loopbacks": [],
}
}
}
assert cfg == expected_cfg

0 comments on commit d5c2d12

Please sign in to comment.