@@ -376,7 +376,7 @@ def with_appended(self, *appended: 'PulseTemplate'):
376376 return self
377377
378378 def pad_to (self , to_new_duration : Union [ExpressionLike , Callable [[Expression ], ExpressionLike ]],
379- as_single_wf : bool = True ,
379+ as_single_wf : bool = False ,
380380 pt_kwargs : Mapping [str , Any ] = {}) -> 'PulseTemplate' :
381381 """Pad this pulse template to the given duration.
382382 The target duration can be numeric, symbolic or a callable that returns a new duration from the current
@@ -405,7 +405,7 @@ def pad_to(self, to_new_duration: Union[ExpressionLike, Callable[[Expression], E
405405
406406 Returns:
407407 A pulse template that has the duration given by ``to_new_duration``.
408- self if ConstantPT,
408+ XXX# self if ConstantPT,
409409 else SingleWFTimeExtensionPulseTemplate if as_single_wf,
410410 else SequencePT
411411 """
@@ -418,12 +418,13 @@ def pad_to(self, to_new_duration: Union[ExpressionLike, Callable[[Expression], E
418418 new_duration = ExpressionScalar (to_new_duration )
419419 pad_duration = new_duration - current_duration
420420
421- #shortcut
422- if isinstance (self ,ConstantPT ):
423- if pt_kwargs :
424- raise NotImplementedError ()
425- self ._duration = new_duration
426- return self
421+ #maybe leads to inconsistencies if self may be returned
422+ # #shortcut
423+ # if isinstance(self,ConstantPT):
424+ # if pt_kwargs:
425+ # raise NotImplementedError()
426+ # self._duration = new_duration
427+ # return self
427428
428429 if as_single_wf :
429430 return SingleWFTimeExtensionPulseTemplate (self , new_duration , ** pt_kwargs )
@@ -436,7 +437,16 @@ def pad_to(self, to_new_duration: Union[ExpressionLike, Callable[[Expression], E
436437 return SequencePT (self , pad_pt , ** pt_kwargs )
437438 else :
438439 return self @ pad_pt
439-
440+
441+ # @abstractmethod
442+ def pad_all_atomic_subtemplates_to (self ,
443+ to_new_duration : Callable [[Expression ], ExpressionLike ]) -> 'PulseTemplate' :
444+ """pad ll atomic subtemplates to a new duration determiend from callable
445+ to_new_duration, e.g. from qupulse.utils.to_next_multiple for waveform
446+ granularity.
447+ """
448+ raise NotImplementedError ()
449+
440450 def __format__ (self , format_spec : str ):
441451 if format_spec == '' :
442452 format_spec = self ._DEFAULT_FORMAT_SPEC
@@ -611,7 +621,15 @@ def final_values(self) -> Dict[ChannelID, ExpressionScalar]:
611621 for ch , value in values .items ():
612622 values [ch ] = value .evaluate_symbolic ({self ._AS_EXPRESSION_TIME : self .duration })
613623 return values
614-
624+
625+ def pad_to (self , to_new_duration : Union [ExpressionLike , Callable [[Expression ], ExpressionLike ]],
626+ pt_kwargs : Mapping [str , Any ] = {}) -> 'PulseTemplate' :
627+ return super ().pad_to (to_new_duration ,as_single_wf = True ,pt_kwargs = pt_kwargs )
628+
629+ def pad_all_atomic_subtemplates_to (self ,
630+ to_new_duration : Callable [[Expression ], ExpressionLike ]) -> 'PulseTemplate' :
631+ return self .pad_to (to_new_duration )
632+
615633
616634class DoubleParameterNameException (Exception ):
617635
0 commit comments