Skip to content

Commit

Permalink
Add __pow__ convenience repetition operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
terrorfisch committed Aug 25, 2023
1 parent e36e4cc commit 935dd30
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions qupulse/pulses/pulse_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ def __rmatmul__(self, other: MappingTuple) -> 'SequencePulseTemplate':

return SequencePulseTemplate.concatenate(other, self)

def __pow__(self, power: ExpressionLike):
"""This is a convenience wrapper for :func:`.with_repetition`."""
return self.with_repetition(power)

@property
@abstractmethod
def integral(self) -> Dict[ChannelID, ExpressionScalar]:
Expand Down
5 changes: 5 additions & 0 deletions tests/pulses/pulse_template_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,11 @@ def test_matmul(self):
self.assertEqual(a @ b, 'concat')
mock_concatenate.assert_called_once_with(a, b)

def test_pow(self):
pt = PulseTemplateStub()
pow_pt = pt ** 5
self.assertEqual(pow_pt, pt.with_repetition(5))

def test_rmatmul(self):
a = PulseTemplateStub()
b = (1, 2, 3)
Expand Down

0 comments on commit 935dd30

Please sign in to comment.