Example #1
0
def test_spin_echo():
    """
    Test for Spin Echo Sequence
    """

    duration = 10.0

    sequence = new_predefined_dds(scheme=SPIN_ECHO, duration=duration)

    _offsets = np.array([duration / 2.0])
    _rabi_rotations = np.array([np.pi])
    _azimuthal_angles = np.array([0])
    _detuning_rotations = np.array([0])

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)

    sequence = new_predefined_dds(scheme=SPIN_ECHO,
                                  duration=duration,
                                  pre_post_rotation=True)

    _offsets = np.array([0, duration / 2.0, duration])
    _rabi_rotations = np.array([np.pi / 2, np.pi, np.pi / 2])
    _azimuthal_angles = np.array([0, 0, 0])
    _detuning_rotations = np.array([0, 0, 0])

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)
Example #2
0
def test_ramsey():

    """Tests Ramsey sequence
    """

    duration = 10.

    sequence = new_predefined_dds(
        scheme='Ramsey',
        duration=duration)

    _offsets = np.array([])
    _rabi_rotations = np.array([])
    _azimuthal_angles = np.array([])
    _detuning_rotations = np.array([])

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)

    sequence = new_predefined_dds(
        scheme='Ramsey',
        duration=duration,
        pre_post_rotation=True)

    _rabi_rotations = np.array([np.pi/2, np.pi/2])
    _azimuthal_angles = np.array([0., 0.])
    _detuning_rotations = np.array([0., 0.])

    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)
Example #3
0
def test_xyconcatenated_sequence():
    """
    Test XY4-CDD Sequence
    """

    duration = 10.
    concatenation_order = 2

    sequence = new_predefined_dds(
        scheme=XY_CONCATENATED,
        duration=duration,
        concatenation_order=concatenation_order)

    _spacing = duration / (2 ** (concatenation_order*2))
    _offsets = [_spacing, 2*_spacing, 3 * _spacing, 4 * _spacing,
                5 * _spacing, 6 * _spacing, 7 * _spacing, 9 * _spacing,
                10 * _spacing, 11 * _spacing, 12 * _spacing, 13 * _spacing,
                14 * _spacing, 15 * _spacing]
    _offsets = np.array(_offsets)
    _rabi_rotations = [np.pi, np.pi, np.pi, 0., np.pi, np.pi, np.pi,
                       np.pi, np.pi, np.pi, 0, np.pi, np.pi, np.pi]
    _rabi_rotations = np.array(_rabi_rotations)
    _azimuthal_angles = [0, np.pi/2, 0, 0, 0, np.pi/2, 0, 0, np.pi/2, 0, 0, 0, np.pi/2, 0]
    _azimuthal_angles = np.array(_azimuthal_angles)
    _detuning_rotations = [0, 0, 0, np.pi, 0, 0, 0, 0, 0, 0, np.pi, 0, 0, 0]
    _detuning_rotations = np.array(_detuning_rotations)

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)

    sequence = new_predefined_dds(
        scheme=XY_CONCATENATED,
        duration=duration,
        concatenation_order=concatenation_order,
        pre_post_rotation=True)

    _offsets = np.insert(_offsets,
                         [0, _offsets.shape[0]],    # pylint: disable=unsubscriptable-object
                         [0, duration])
    _rabi_rotations = np.insert(
        _rabi_rotations,
        [0, _rabi_rotations.shape[0]],  # pylint: disable=unsubscriptable-object
        [np.pi/2, np.pi/2])
    _azimuthal_angles = np.insert(
        _azimuthal_angles,
        [0, _azimuthal_angles.shape[0]],    # pylint: disable=unsubscriptable-object
        [0, 0])
    _detuning_rotations = np.insert(
        _detuning_rotations,
        [0, _detuning_rotations.shape[0]],  # pylint: disable=unsubscriptable-object
        [0, 0])

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)
Example #4
0
def test_walsh_single_axis_sequence():
    """
    Test for Periodic Single Axis Sequence
    """

    duration = 10.
    paley_order = 20

    sequence = new_predefined_dds(
        scheme=WALSH_SINGLE_AXIS,
        duration=duration,
        paley_order=paley_order)

    hamming_weight = 5
    samples = 2 ** hamming_weight
    relative_offset = np.arange(1. / (2 * samples), 1., 1. / samples)
    binary_string = np.binary_repr(paley_order)
    binary_order = [int(binary_string[i]) for i in range(hamming_weight)]
    walsh_array = np.ones([samples])
    for i in range(hamming_weight):
        walsh_array *= np.sign(np.sin(2 ** (i + 1) * np.pi
                                      * relative_offset)) ** binary_order[hamming_weight - 1 - i]

    walsh_relative_offsets = []
    for i in range(samples - 1):
        if walsh_array[i] != walsh_array[i + 1]:
            walsh_relative_offsets.append((i + 1) * (1. / samples))
    walsh_relative_offsets = np.array(walsh_relative_offsets, dtype=np.float)
    _offsets = duration * walsh_relative_offsets
    _offsets = np.array(_offsets)

    _rabi_rotations = np.pi * np.ones(_offsets.shape)
    _azimuthal_angles = np.zeros(_offsets.shape)
    _detuning_rotations = np.zeros(_offsets.shape)

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)

    sequence = new_predefined_dds(
        scheme=WALSH_SINGLE_AXIS,
        duration=duration,
        paley_order=paley_order,
        pre_post_rotation=True)

    _offsets = np.insert(_offsets,
                         [0, _offsets.shape[0]],    # pylint: disable=unsubscriptable-object
                         [0, duration])
    _rabi_rotations = np.insert(_rabi_rotations, [0, _rabi_rotations.shape[0]],
                                [np.pi/2, np.pi/2])
    _azimuthal_angles = np.zeros(_offsets.shape)
    _detuning_rotations = np.zeros(_offsets.shape)

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)
Example #5
0
def test_curr_purcell_meiboom_sequence():
    """
    Test for Carr-Purcell-Meiboom-Sequence (CPMG) sequence
    """

    duration = 10.0
    number_of_offsets = 4

    sequence = new_predefined_dds(
        scheme=CARR_PURCELL_MEIBOOM_GILL,
        duration=duration,
        number_of_offsets=number_of_offsets,
    )

    _spacing = duration / number_of_offsets
    _offsets = np.array([
        _spacing * 0.5,
        _spacing * 0.5 + _spacing,
        _spacing * 0.5 + 2 * _spacing,
        _spacing * 0.5 + 3 * _spacing,
    ])
    _rabi_rotations = np.array([np.pi, np.pi, np.pi, np.pi])
    _azimuthal_angles = np.array([np.pi / 2, np.pi / 2, np.pi / 2, np.pi / 2])
    _detuning_rotations = np.array([0, 0, 0, 0])

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)

    sequence = new_predefined_dds(
        scheme=CARR_PURCELL_MEIBOOM_GILL,
        duration=duration,
        number_of_offsets=number_of_offsets,
        pre_post_rotation=True,
    )

    _offsets = np.array([
        0,
        _spacing * 0.5,
        _spacing * 0.5 + _spacing,
        _spacing * 0.5 + 2 * _spacing,
        _spacing * 0.5 + 3 * _spacing,
        duration,
    ])
    _rabi_rotations = np.array(
        [np.pi / 2, np.pi, np.pi, np.pi, np.pi, np.pi / 2])
    _azimuthal_angles = np.array(
        [0, np.pi / 2, np.pi / 2, np.pi / 2, np.pi / 2, np.pi])
    _detuning_rotations = np.array([0, 0, 0, 0, 0, 0])

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)
Example #6
0
def test_xconcatenated_sequence():
    """
    Test X-CDD Sequence
    """

    duration = 10.0
    concatenation_order = 3

    sequence = new_predefined_dds(
        scheme=X_CONCATENATED,
        duration=duration,
        concatenation_order=concatenation_order,
    )

    _spacing = duration / (2**concatenation_order)
    _offsets = [
        _spacing, 3 * _spacing, 4 * _spacing, 5 * _spacing, 7 * _spacing
    ]
    _offsets = np.array(_offsets)
    _rabi_rotations = np.pi * np.ones(_offsets.shape)

    _azimuthal_angles = np.zeros(_offsets.shape)
    _detuning_rotations = np.zeros(_offsets.shape)

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)

    sequence = new_predefined_dds(
        scheme=X_CONCATENATED,
        duration=duration,
        concatenation_order=concatenation_order,
        pre_post_rotation=True,
    )

    _offsets = np.insert(
        _offsets,
        [0, _offsets.shape[0]],
        [0, duration],
    )
    _rabi_rotations = np.insert(
        _rabi_rotations,
        [0, _rabi_rotations.shape[0]],
        [np.pi / 2, np.pi / 2],
    )
    _azimuthal_angles = np.zeros(_offsets.shape)
    _detuning_rotations = np.zeros(_offsets.shape)

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)
Example #7
0
def test_uhrig_single_axis_sequence():
    """
    Test for Uhrig Single Axis Sequence
    """

    duration = 10.0
    number_of_offsets = 4

    sequence = new_predefined_dds(scheme=UHRIG_SINGLE_AXIS,
                                  duration=duration,
                                  number_of_offsets=number_of_offsets)

    constant = 0.5 / (number_of_offsets + 1)
    _delta_positions = [
        duration * (np.sin(np.pi * (k + 1) * constant))**2
        for k in range(number_of_offsets)
    ]

    _offsets = np.array(_delta_positions)
    _rabi_rotations = np.array([np.pi, np.pi, np.pi, np.pi])
    _azimuthal_angles = np.array([np.pi / 2, np.pi / 2, np.pi / 2, np.pi / 2])
    _detuning_rotations = np.array([0, 0, 0, 0])

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)

    sequence = new_predefined_dds(
        scheme=UHRIG_SINGLE_AXIS,
        duration=duration,
        number_of_offsets=number_of_offsets,
        pre_post_rotation=True,
    )

    _offsets = np.array(_delta_positions)
    _offsets = np.insert(
        _offsets,
        [0, _offsets.shape[0]],
        [0, duration],
    )

    _rabi_rotations = np.array(
        [np.pi / 2, np.pi, np.pi, np.pi, np.pi, np.pi / 2])
    _azimuthal_angles = np.array(
        [0.0, np.pi / 2, np.pi / 2, np.pi / 2, np.pi / 2, np.pi])
    _detuning_rotations = np.array([0.0, 0, 0, 0, 0, 0.0])

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)
Example #8
0
def test_periodic_single_axis_sequence():
    """
    Test for Periodic Single Axis Sequence
    """

    duration = 10.0
    number_of_offsets = 4

    sequence = new_predefined_dds(
        scheme=PERIODIC_SINGLE_AXIS,
        duration=duration,
        number_of_offsets=number_of_offsets,
    )

    constant = 1 / (number_of_offsets + 1)
    # prepare the offsets for delta comb
    _delta_positions = [
        duration * k * constant for k in range(1, number_of_offsets + 1)
    ]
    _offsets = np.array(_delta_positions)
    _rabi_rotations = np.array([np.pi, np.pi, np.pi, np.pi])
    _azimuthal_angles = np.array([0, 0, 0, 0])
    _detuning_rotations = np.array([0, 0, 0, 0])

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)

    sequence = new_predefined_dds(
        scheme=PERIODIC_SINGLE_AXIS,
        duration=duration,
        number_of_offsets=number_of_offsets,
        pre_post_rotation=True,
    )

    _offsets = np.array(_delta_positions)
    _offsets = np.insert(
        _offsets,
        [0, _offsets.shape[0]],
        [0, duration],
    )

    _rabi_rotations = np.array(
        [np.pi / 2, np.pi, np.pi, np.pi, np.pi, np.pi / 2])
    _azimuthal_angles = np.array([0, 0, 0, 0, 0, np.pi])
    _detuning_rotations = np.array([0, 0, 0, 0, 0, 0])

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)
Example #9
0
def test_if_spin_echo_sequence_is_identity():
    """
    Tests if the product of the pulses in a Spin Echo sequence with pre/post
    pi/2-pulses is an identity.
    """
    spin_echo_sequence = new_predefined_dds(scheme=SPIN_ECHO,
                                            duration=10.0,
                                            pre_post_rotation=True)

    assert _pulses_produce_identity(spin_echo_sequence)
Example #10
0
def test_if_ramsey_sequence_is_identity():
    """
    Tests if the product of the pulses in the Ramsey sequence with pre/post
    pi/2-pulses is an identity.
    """
    ramsey_sequence = new_predefined_dds(scheme="Ramsey",
                                         duration=10.0,
                                         pre_post_rotation=True)

    assert _pulses_produce_identity(ramsey_sequence)
Example #11
0
def test_if_carr_purcell_sequence_with_even_pulses_is_identity():
    """
    Tests if the product of the pulses in a Carr-Purcell sequence with pre/post
    pi/2-pulses is an identity, when the number of pulses is even.
    """
    even_carr_purcell_sequence = new_predefined_dds(scheme=CARR_PURCELL,
                                                    duration=10.0,
                                                    number_of_offsets=8,
                                                    pre_post_rotation=True)

    assert _pulses_produce_identity(even_carr_purcell_sequence)
Example #12
0
def test_if_x_concatenated_sequence_is_identity():
    """
    Tests if the product of the pulses in an X concatenated sequence with pre/post
    pi/2-pulses is an identity.
    """
    x_concat_sequence = new_predefined_dds(
        scheme=X_CONCATENATED,
        duration=10.0,
        concatenation_order=4,
        pre_post_rotation=True,
    )

    assert _pulses_produce_identity(x_concat_sequence)
Example #13
0
def test_if_uhrig_sequence_with_odd_pulses_is_identity():
    """
    Tests if the product of the pulses in an Uhrig sequence with pre/post
    pi/2-pulses is an identity, when the number of pulses is odd.
    """
    odd_uhrig_sequence = new_predefined_dds(
        scheme=UHRIG_SINGLE_AXIS,
        duration=10.0,
        number_of_offsets=7,
        pre_post_rotation=True,
    )

    assert _pulses_produce_identity(odd_uhrig_sequence)
Example #14
0
def test_if_cpmg_sequence_with_odd_pulses_is_identity():
    """
    Tests if the product of the pulses in a CPMG sequence with pre/post
    pi/2-pulses is an identity, when the number of pulses is odd.
    """
    odd_cpmg_sequence = new_predefined_dds(
        scheme=CARR_PURCELL_MEIBOOM_GILL,
        duration=10.0,
        number_of_offsets=7,
        pre_post_rotation=True,
    )

    assert _pulses_produce_identity(odd_cpmg_sequence)
Example #15
0
def test_if_periodic_sequence_with_even_pulses_is_identity():
    """
    Tests if the product of the pulses in a periodic DDS with pre/post
    pi/2-pulses is an identity, when the number of pulses is even.
    """
    even_periodic_sequence = new_predefined_dds(
        scheme=PERIODIC_SINGLE_AXIS,
        duration=10.0,
        number_of_offsets=8,
        pre_post_rotation=True,
    )

    assert _pulses_produce_identity(even_periodic_sequence)
Example #16
0
def _create_test_sequence(sequence_scheme, pre_post_rotation):
    """Create a DD sequence of choice'''

    Parameters
    ----------
    sequence_scheme : str
        One of 'Spin echo', 'Carr-Purcell', 'Carr-Purcell-Meiboom-Gill',
        'Uhrig single-axis', 'Periodic single-axis', 'Walsh single-axis',
        'Quadratic', 'X concatenated',
        'XY concatenated'
    pre_post_rotation : bool
        If True, adds a :math:`X_{\\pi/2}` gate on either ends

    Returns
    -------
    DynamicDecouplingSequence
        The Dynamical Decoupling Sequence instance built from supplied
        schema information
    """

    dd_sequence_params = dict()
    dd_sequence_params['scheme'] = sequence_scheme
    dd_sequence_params['duration'] = 4
    dd_sequence_params['pre_post_rotation'] = pre_post_rotation

    # 'spin_echo' does not need any additional parameter

    if dd_sequence_params['scheme'] in [
            'Carr-Purcell', 'Carr-Purcell-Meiboom-Gill', 'Uhrig single-axis',
            'periodic single-axis'
    ]:

        dd_sequence_params['number_of_offsets'] = 2

    elif dd_sequence_params['scheme'] in ['Walsh single-axis']:

        dd_sequence_params['paley_order'] = 5

    elif dd_sequence_params['scheme'] in ['quadratic']:

        dd_sequence_params['duration'] = 16
        dd_sequence_params['number_outer_offsets'] = 4
        dd_sequence_params['number_inner_offsets'] = 4

    elif dd_sequence_params['scheme'] in ['X concatenated', 'XY concatenated']:

        dd_sequence_params['duration'] = 16
        dd_sequence_params['concatenation_order'] = 2

    sequence = new_predefined_dds(**dd_sequence_params)
    return sequence
Example #17
0
def test_if_walsh_sequence_with_even_pulses_is_identity():
    """
    Tests if the product of the pulses in a quadratic sequence with pre/post
    pi/2-pulses is an identity, when the number of pulses is even.
    """
    even_walsh_sequence = new_predefined_dds(scheme=WALSH_SINGLE_AXIS,
                                             duration=10.0,
                                             paley_order=6,
                                             pre_post_rotation=True)

    # A Walsh sequence with paley_order 6 has 4 pi-pulses + 2 pi/2-pulses,
    # see https://arxiv.org/pdf/1109.6002.pdf
    assert len(even_walsh_sequence.offsets) == 4 + 2

    assert _pulses_produce_identity(even_walsh_sequence)
Example #18
0
def test_if_quadratic_sequence_with_even_inner_pulses_is_identity():
    """
    Tests if the product of the pulses in a quadratic sequence with pre/post
    pi/2-pulses is an identity, when the total number of inner pulses is even.
    """
    inner_even_quadratic_sequence = new_predefined_dds(
        scheme=QUADRATIC,
        duration=10.0,
        number_inner_offsets=8,
        number_outer_offsets=7,
        pre_post_rotation=True,
    )

    # n_outer + n_inner*(n_outer+1) pi-pulses + 2 pi/2-pulses
    # total number here is even
    assert len(inner_even_quadratic_sequence.offsets) == 7 + 8 * (7 + 1) + 2

    assert _pulses_produce_identity(inner_even_quadratic_sequence)
Example #19
0
def test_attribute_values():
    """
    Test for the correctness of the attribute values
    """

    # Check that errors are raised correctly

    # duration cannot be <= 0
    with pytest.raises(ArgumentsValueError):
        _ = new_predefined_dds(scheme=SPIN_ECHO, duration=-2)

        # number_of_offsets cannot be <= 0
        _ = new_predefined_dds(
            scheme=CARR_PURCELL_MEIBOOM_GILL, duration=2,
            number_of_offsets=-1)
        # for QDD, none of the offsets can be <=0
        _ = new_predefined_dds(
            scheme=QUADRATIC, duration=2,
            number_inner_offsets=-1, number_outer_offsets=2)
        _ = new_predefined_dds(
            scheme=QUADRATIC, duration=2,
            number_inner_offsets=1, number_outer_offsets=-2)
        _ = new_predefined_dds(
            scheme=QUADRATIC, duration=2,
            number_inner_offsets=-1, number_outer_offsets=-2)

        # for x-cdd and xy-cdd concatenation_order cannot be <=0
        _ = new_predefined_dds(
            scheme=X_CONCATENATED, duration=2,
            concatenation_order=-1)
        _ = new_predefined_dds(
            scheme=X_CONCATENATED, duration=-2,
            concatenation_order=1)
        _ = new_predefined_dds(
            scheme=X_CONCATENATED, duration=-2,
            concatenation_order=-1)
        _ = new_predefined_dds(
            scheme=XY_CONCATENATED, duration=2,
            concatenation_order=-1)
        _ = new_predefined_dds(
            scheme=XY_CONCATENATED, duration=-2,
            concatenation_order=1)
        _ = new_predefined_dds(
            scheme=XY_CONCATENATED, duration=-2,
            concatenation_order=-1)
Example #20
0
def test_quadratic_sequence():
    """
    Test for Quadratic Sequence
    """

    duration = 10.
    number_inner_offsets = 4
    number_outer_offsets = 4

    sequence = new_predefined_dds(
        scheme=QUADRATIC, duration=duration,
        number_inner_offsets=number_inner_offsets,
        number_outer_offsets=number_outer_offsets)

    _offsets = np.zeros((number_outer_offsets+1, number_inner_offsets + 1))

    constant = 0.5 / (number_outer_offsets + 1)
    _delta_positions = [duration * (np.sin(np.pi * (k + 1) * constant)) ** 2
                        for k in range(number_outer_offsets)]

    _outer_offsets = np.array(_delta_positions)
    _offsets[0:number_outer_offsets, -1] = _outer_offsets

    _outer_offsets = np.insert(
        _outer_offsets,
        [0, _outer_offsets.shape[0]],   # pylint: disable=unsubscriptable-object
        [0, duration])
    _inner_durations = _outer_offsets[1:] - _outer_offsets[0:-1]

    constant = 0.5 / (number_inner_offsets+1)
    _delta_positions = [(np.sin(np.pi * (k + 1) * constant)) ** 2
                        for k in range(number_inner_offsets)]
    _delta_positions = np.array(_delta_positions)
    for inner_sequence_idx in range(_inner_durations.shape[0]):
        _inner_deltas = _inner_durations[inner_sequence_idx] * _delta_positions
        _inner_deltas = _outer_offsets[inner_sequence_idx] + _inner_deltas
        _offsets[inner_sequence_idx, 0:number_inner_offsets] = _inner_deltas

    _rabi_rotations = np.zeros(_offsets.shape)
    _detuning_rotations = np.zeros(_offsets.shape)

    _rabi_rotations[0:number_outer_offsets, -1] = np.pi
    _detuning_rotations[0:(number_outer_offsets+1), 0:number_inner_offsets] = np.pi

    _offsets = np.reshape(_offsets, (-1,))
    _rabi_rotations = np.reshape(_rabi_rotations, (-1,))
    _detuning_rotations = np.reshape(_detuning_rotations, (-1,))

    _offsets = _offsets[0:-1]
    _rabi_rotations = _rabi_rotations[0:-1]
    _detuning_rotations = _detuning_rotations[0:-1]

    _azimuthal_angles = np.zeros(_offsets.shape)

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)

    sequence = new_predefined_dds(
        scheme=QUADRATIC, duration=duration,
        number_inner_offsets=number_inner_offsets,
        number_outer_offsets=number_outer_offsets,
        pre_post_rotation=True)

    _offsets = np.insert(_offsets, [0, _offsets.shape[0]], [0, duration])
    _rabi_rotations = np.insert(_rabi_rotations, [0, _rabi_rotations.shape[0]],
                                [np.pi/2, np.pi/2])
    _detuning_rotations = np.insert(_detuning_rotations, [0, _detuning_rotations.shape[0]],
                                    [0, 0])

    _azimuthal_angles = np.zeros(_offsets.shape)

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)