Skip to content

Commit

Permalink
Merge pull request #202 from qua-platform/baking_with_OPX1000
Browse files Browse the repository at this point in the history
fixing a typo "mwInput" to "MWInput" in bakery
  • Loading branch information
deanpoulos authored Apr 20, 2024
2 parents 76907c5 + ccc7aaa commit b23f18e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed
- Only load DataHandler XarrayDataProcessor if xarray can be imported
- Fix bug with the data folder path.
- Fix typo in the `baking` tool config lookup (`mwInput` -> `MWInput`)

## [0.17.0] - 2024-04-18
### Added
Expand Down
32 changes: 16 additions & 16 deletions qualang_tools/bakery/bakery.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def _init_dict(self):
"freq": 0,
"time_track": 0, # Value used for negative waits, to know where to add the samples (negative int)
}
if any([key in self._local_config["elements"][qe] for key in ["mixInputs", "RF_inputs", "mwInput"]]):
if any([key in self._local_config["elements"][qe] for key in ["mixInputs", "RF_inputs", "MWInput"]]):
sample_dict[qe] = {"I": [], "Q": []}

elif "singleInput" in self._local_config["elements"][qe]:
Expand Down Expand Up @@ -209,7 +209,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
self._qe_set.add(qe)
qe_samples = self._samples_dict[qe]
if self.sampling_rate > int(1e9):
if any([key in elements[qe] for key in ["mixInputs", "RF_inputs", "mwInput"]]):
if any([key in elements[qe] for key in ["mixInputs", "RF_inputs", "MWInput"]]):
y1 = qe_samples["I"]
y2 = qe_samples["Q"]
dt = 1e9 / self.sampling_rate
Expand Down Expand Up @@ -246,7 +246,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
self.wait(4 - self._qe_dict[qe]["time"] % 4, qe)

end_samples = 0
if any([key in elements[qe] for key in ["mixInputs", "RF_inputs", "mwInput"]]):
if any([key in elements[qe] for key in ["mixInputs", "RF_inputs", "MWInput"]]):
end_samples = len(qe_samples["I"]) - wait_duration
elif "singleInput" in elements[qe]:
end_samples = len(qe_samples["single"]) - wait_duration
Expand All @@ -265,7 +265,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
)

elif self._padding_method == "left":
if any([key in elements[qe] for key in ["mixInputs", "RF_inputs", "mwInput"]]):
if any([key in elements[qe] for key in ["mixInputs", "RF_inputs", "MWInput"]]):
qe_samples["I"] = qe_samples["I"][end_samples:] + qe_samples["I"][0:end_samples]
qe_samples["Q"] = qe_samples["Q"][end_samples:] + qe_samples["Q"][0:end_samples]
elif "singleInput" in elements[qe]:
Expand All @@ -274,7 +274,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
elif self._padding_method == "symmetric_l" or (
self._padding_method == "symmetric_r" and wait_duration % 2 == 0
):
if any([key in elements[qe] for key in ["mixInputs", "RF_inputs", "mwInput"]]):
if any([key in elements[qe] for key in ["mixInputs", "RF_inputs", "MWInput"]]):
qe_samples["I"] = (
qe_samples["I"][end_samples + wait_duration // 2 :]
+ qe_samples["I"][0 : end_samples + wait_duration // 2]
Expand All @@ -292,7 +292,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
)

elif self._padding_method == "symmetric_r" and wait_duration % 2 != 0:
if any([key in elements[qe] for key in ["mixInputs", "RF_inputs", "mwInput"]]):
if any([key in elements[qe] for key in ["mixInputs", "RF_inputs", "MWInput"]]):
qe_samples["I"] = (
qe_samples["I"][end_samples + wait_duration // 2 + 1 :]
+ qe_samples["I"][0 : end_samples + wait_duration // 2 + 1]
Expand All @@ -310,7 +310,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
if self.update_config:
self._update_config(qe, qe_samples)

if any([key in elements[qe] for key in ["mixInputs", "RF_inputs", "mwInput"]]):
if any([key in elements[qe] for key in ["mixInputs", "RF_inputs", "MWInput"]]):
self.override_waveforms_dict["waveforms"][f"{qe}_baked_wf_I_{self._ctr}"] = qe_samples["I"]
self.override_waveforms_dict["waveforms"][f"{qe}_baked_wf_Q_{self._ctr}"] = qe_samples["Q"]

Expand Down Expand Up @@ -412,7 +412,7 @@ def get_current_length(self, qe: Optional[str] = None) -> int:
max_length = length
return max_length
else:
if any([key in self._local_config["elements"][qe] for key in ["mixInputs", "RF_inputs", "mwInput"]]):
if any([key in self._local_config["elements"][qe] for key in ["mixInputs", "RF_inputs", "MWInput"]]):
return len(self._samples_dict[qe]["I"])
elif "singleInput" in self._local_config["elements"][qe]:
return len(self._samples_dict[qe]["single"])
Expand Down Expand Up @@ -468,7 +468,7 @@ def delete_for_el(qe_internal, t_start_internal, t_stop_internal):
if any(
[
key in self._local_config["elements"][qe_internal]
for key in ["mixInputs", "RF_inputs", "mwInput"]
for key in ["mixInputs", "RF_inputs", "MWInput"]
]
):
input_type.append("I")
Expand Down Expand Up @@ -531,7 +531,7 @@ def remove_op(q):
if f"baked_Op_{self._ctr}" in self.config["elements"][q]["operations"]:
del self.config["elements"][q]["operations"][f"baked_Op_{self._ctr}"]
del self.config["pulses"][f"{q}_baked_pulse_{self._ctr}"]
if any([key in self.config["elements"][q] for key in ["mixInputs", "RF_inputs", "mwInput"]]):
if any([key in self.config["elements"][q] for key in ["mixInputs", "RF_inputs", "MWInput"]]):
del self.config["waveforms"][f"{q}_baked_wf_I_{self._ctr}"]
del self.config["waveforms"][f"{q}_baked_wf_Q_{self._ctr}"]
elif "singleInput" in self.config["elements"][q]:
Expand Down Expand Up @@ -581,7 +581,7 @@ def get_op_length(self, qe: Optional[str] = None) -> int:
if not (qe in self._qe_set):
raise KeyError(f"{qe} is not in the set of quantum elements of the baking object ")
else:
if any([key in self._config["elements"][qe] for key in ["mixInputs", "RF_inputs", "mwInput"]]):
if any([key in self._config["elements"][qe] for key in ["mixInputs", "RF_inputs", "MWInput"]]):
return len(self._config["waveforms"][f"{qe}_baked_wf_I_{self._ctr}"]["samples"])
else:
return len(self._config["waveforms"][f"{qe}_baked_wf_{self._ctr}"]["samples"])
Expand Down Expand Up @@ -643,7 +643,7 @@ def add_op(

index = self._get_pulse_index(qe)
Op = {name: f"{qe}_baked_pulse_b{self._ctr}_{index}"}
if any([key in self._local_config["elements"][qe] for key in ["mixInputs", "RF_inputs", "mwInput"]]):
if any([key in self._local_config["elements"][qe] for key in ["mixInputs", "RF_inputs", "MWInput"]]):
assert len(samples) == 2, f"{qe} is a mixInputs/RF_inputs element, two lists should be provided"
assert len(samples[0]) == len(
samples[1]
Expand Down Expand Up @@ -718,7 +718,7 @@ def play(self, Op: str, qe: str, amp: Union[float, Tuple[float]] = 1.0) -> None:
phi = self._qe_dict[qe]["phase"]

if self._qe_dict[qe]["time_track"] == 0:
if any([key in self._local_config["elements"][qe] for key in ["mixInputs", "RF_inputs", "mwInput"]]):
if any([key in self._local_config["elements"][qe] for key in ["mixInputs", "RF_inputs", "MWInput"]]):
assert isinstance(
samples, list
), f"{qe} is a mixInputs/RF_inputs element, two lists should be provided"
Expand Down Expand Up @@ -809,7 +809,7 @@ def play_at(self, Op: str, qe: str, t: int, amp: Union[float, Tuple[float]] = 1.
pulse = self._local_config["elements"][qe]["operations"][Op]
samples = self._get_samples(pulse)
new_samples = 0
if any([key in self._local_config["elements"][qe] for key in ["mixInputs", "RF_inputs", "mwInput"]]):
if any([key in self._local_config["elements"][qe] for key in ["mixInputs", "RF_inputs", "MWInput"]]):
assert isinstance(
samples, list
), f"{qe} is a mixInputs/RF_inputs element, two lists should be provided"
Expand Down Expand Up @@ -941,7 +941,7 @@ def ramp(self, amp: float, duration: int, qe: str) -> None:
ramp_sample = [amp * t for t in range(duration)]
if "singleInput" in self._local_config["elements"][qe]:
self._samples_dict[qe]["single"] += ramp_sample
elif any([key in self._local_config["elements"][qe] for key in ["mixInputs", "RF_inputs", "mwInput"]]):
elif any([key in self._local_config["elements"][qe] for key in ["mixInputs", "RF_inputs", "MWInput"]]):
self._samples_dict[qe]["Q"] += ramp_sample
self._samples_dict[qe]["I"] += [0] * duration
self._update_qe_time(qe, duration)
Expand All @@ -967,7 +967,7 @@ def wait(self, duration: int, *qe_set: str) -> None:
if any(
[
key in self._local_config["elements"][qe].keys()
for key in ["mixInputs", "RF_inputs", "mwInput"]
for key in ["mixInputs", "RF_inputs", "MWInput"]
]
):
self._samples_dict[qe]["I"] += [0] * duration
Expand Down

0 comments on commit b23f18e

Please sign in to comment.