-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
time extension via SequencePT #830
Draft
Nomos11
wants to merge
14
commits into
master
Choose a base branch
from
feat_time_extension_pulse_template_2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
972db1d
First draft of time extensions pulse template
terrorfisch fb968e3
Merge pull request #829 from qutech/master
Nomos11 f27b7bb
test simple sequencPT based time extension pt
Nomos11 8ec6ac0
bugfix
Nomos11 ed6b8d0
further bugfix
Nomos11 3188ce0
stricter check in SequencePT to not unroll TimeExtPT
Nomos11 108b665
divide between singleWFextension and other extension
Nomos11 4d31e59
pad_to with option for single_wf
Nomos11 10e90fd
adapt pad_to & tests
Nomos11 a8b0d48
TimeExtension/pad_to combined example test
Nomos11 75436d3
barebone new_subprogram for LinSpaceBuilder
Nomos11 647a561
forgot that hold already contains voltages
Nomos11 9271e42
delete potentially wrong if case
Nomos11 db9f56c
list append & from_mapping
Nomos11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import numbers | ||
from typing import Dict, Optional, Set, Union, List, Iterable | ||
|
||
from qupulse import ChannelID | ||
from qupulse._program.transformation import Transformation | ||
from qupulse.parameter_scope import Scope | ||
from qupulse.pulses.pulse_template import PulseTemplate | ||
from qupulse.pulses import ConstantPT, SequencePT | ||
from qupulse.expressions import ExpressionLike, ExpressionScalar | ||
from qupulse._program.waveforms import ConstantWaveform | ||
from qupulse.program import ProgramBuilder | ||
from qupulse.pulses.parameters import ConstraintLike | ||
from qupulse.pulses.measurement import MeasurementDeclaration | ||
from qupulse.serialization import PulseRegistryType | ||
|
||
|
||
def _evaluate_expression_dict(expression_dict: Dict[str, ExpressionScalar], scope: Scope) -> Dict[str, float]: | ||
return {ch: value.evaluate_in_scope(scope) | ||
for ch, value in expression_dict.items()} | ||
|
||
|
||
class TimeExtensionPulseTemplate(SequencePT): | ||
"""Extend the given pulse template with a constant(?) prefix and/or suffix. | ||
Both start and stop are defined as positive quantities. | ||
""" | ||
|
||
@property | ||
def parameter_names(self) -> Set[str]: | ||
return self._extend_inner.parameter_names | set(self._extend_stop.variables) | set(self._extend_start.variables) | ||
|
||
def __init__(self, inner: PulseTemplate, start: ExpressionLike, stop: ExpressionLike, | ||
*, | ||
parameter_constraints: Optional[Iterable[ConstraintLike]]=None, | ||
measurements: Optional[List[MeasurementDeclaration]]=None, | ||
identifier: Optional[str] = None, | ||
registry: PulseRegistryType = None): | ||
|
||
self._extend_inner = inner | ||
self._extend_start = ExpressionScalar(start) | ||
self._extend_stop = ExpressionScalar(stop) | ||
|
||
id_base = identifier if identifier is not None else "" | ||
|
||
start_pt = ConstantPT(self._extend_start,self._extend_inner.initial_values,identifier=id_base+f"__prepend_{id(self)}") | ||
stop_pt = ConstantPT(self._extend_stop,self._extend_inner.final_values,identifier=id_base+f"__postpend_{id(self)}") | ||
|
||
super().__init__(start_pt,self._extend_inner,stop_pt,identifier=identifier, | ||
parameter_constraints=parameter_constraints, | ||
measurements=measurements, | ||
registry=registry) | ||
|
||
|
||
class SingleWFTimeExtensionPulseTemplate(SequencePT): | ||
"""Extend the given pulse template with a constant(?) prefix and/or suffix. | ||
Both start and stop are defined as positive quantities. | ||
""" | ||
|
||
@property | ||
def parameter_names(self) -> Set[str]: | ||
return self._extend_inner.parameter_names | set(self._extend_stop.variables) | set(self._extend_start.variables) | ||
|
||
def _create_program(self, *, | ||
scope: Scope, | ||
measurement_mapping: Dict[str, Optional[str]], | ||
channel_mapping: Dict[ChannelID, Optional[ChannelID]], | ||
global_transformation: Optional[Transformation], | ||
to_single_waveform: Set[Union[str, 'PulseTemplate']], | ||
program_builder: ProgramBuilder): | ||
|
||
super()._create_program(scope=scope, | ||
measurement_mapping=measurement_mapping, | ||
channel_mapping=channel_mapping, | ||
global_transformation=global_transformation, | ||
to_single_waveform=to_single_waveform | {self}, | ||
program_builder=program_builder) | ||
|
||
def __init__(self, inner: PulseTemplate, start: ExpressionLike, stop: ExpressionLike, | ||
*, | ||
parameter_constraints: Optional[Iterable[ConstraintLike]]=None, | ||
measurements: Optional[List[MeasurementDeclaration]]=None, | ||
identifier: Optional[str] = None, | ||
registry: PulseRegistryType = None): | ||
|
||
self._extend_inner = inner | ||
self._extend_start = ExpressionScalar(start) | ||
self._extend_stop = ExpressionScalar(stop) | ||
|
||
id_base = identifier if identifier is not None else "" | ||
|
||
start_pt = ConstantPT(self._extend_start,self._extend_inner.initial_values,identifier=id_base+f"__prepend_{id(self)}") | ||
stop_pt = ConstantPT(self._extend_stop,self._extend_inner.final_values,identifier=id_base+f"__postpend_{id(self)}") | ||
|
||
super().__init__(start_pt,self._extend_inner,stop_pt,identifier=identifier, | ||
parameter_constraints=parameter_constraints, | ||
measurements=measurements, | ||
registry=registry, | ||
allow_subtemplate_concatenation=False) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The linspace builder ignores measurements. The idea is to have a dedicated
MeasurementBuilder
to extract them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok