Skip to content

Commit

Permalink
Merge branch 'main' into shpface-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
speller26 committed Jul 11, 2023
2 parents 3f3a072 + f37837e commit 8124787
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/braket/pulse/waveforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self, amplitudes: List[complex], id: Optional[str] = None):
id (Optional[str]): The identifier used for declaring this waveform. A random string of
ascii characters is assigned by default.
"""
self.amplitudes = amplitudes
self.amplitudes = list(amplitudes)
self.id = id or _make_identifier_name()

def __eq__(self, other):
Expand Down
22 changes: 18 additions & 4 deletions test/unit_tests/braket/pulse/test_waveforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,29 @@
import re
from copy import deepcopy

import numpy as np
import pytest
from oqpy import Program

from braket.circuits.free_parameter import FreeParameter
from braket.pulse import ArbitraryWaveform, ConstantWaveform, DragGaussianWaveform, GaussianWaveform
from braket.pulse.ast.qasm_parser import ast_to_qasm


def test_arbitrary_waveform():
amps = [complex(1, 2), complex(0.3, -1), 0, 4.2]
@pytest.mark.parametrize(
"amps",
[
[complex(1, 2), complex(0.3, -1), 0, 4.2],
np.array([complex(1, 2), complex(0.3, -1), 0, 4.2]),
],
)
def test_arbitrary_waveform(amps):
id = "arb_wf_x"
wf = ArbitraryWaveform(amps, id)
assert wf.amplitudes == amps
assert wf.amplitudes == list(amps)
assert wf.id == id
oq_exp = wf._to_oqpy_expression()
assert oq_exp.init_expression == amps
assert oq_exp.init_expression == list(amps)
assert oq_exp.name == wf.id


Expand All @@ -49,6 +57,12 @@ def test_arbitrary_wf_eq():
assert wf != wfc


def test_arbitrary_waveform_not_castable_into_list():
amps = 1
with pytest.raises(TypeError):
wf = ArbitraryWaveform(amps)


def test_constant_waveform():
length = 4e-3
iq = 4
Expand Down

0 comments on commit 8124787

Please sign in to comment.