Beispiel #1
0
def test_addArray():

    SR = 1e9
    N = 2500

    wfm = np.linspace(0, N / SR, N)
    m1 = np.zeros(N)
    m2 = np.ones(N)

    elem = Element()
    elem.addArray(1, wfm, SR, m1=m1, m2=m2)
    elem.addArray('2', wfm, SR, m1=m1)
    elem.addArray('readout_channel', wfm, SR, m2=m2)

    elem.validateDurations()

    M = 2400
    wfm2 = np.linspace(0, M / SR, M)
    elem.addArray(3, wfm2, SR)

    with pytest.raises(ElementDurationError):
        elem.validateDurations()

    with pytest.raises(ValueError):
        elem.addArray(1, wfm, SR, m1=m1[:-1])

    with pytest.raises(ValueError):
        elem.addArray(2, wfm, SR, m2=m2[3:])
Beispiel #2
0
    def addElement(self, position: int, element: Element) -> None:
        """
        Add an element to the sequence. Overwrites previous values.

        Args:
            position (int): The sequence position of the element (lowest: 1)
            element (Element): An element instance

        Raises:
            ValueError: If the element has inconsistent durations
        """

        # Validation
        element.validateDurations()

        # make a new copy of the element
        newelement = element.copy()

        # Data mutation
        self._data.update({position: newelement})

        # insert default sequencing settings
        self._sequencing[position] = {'twait': 0, 'nrep': 1,
                                      'jump_input': 0, 'jump_target': 0,
                                      'goto': 0}
Beispiel #3
0
def test_invalid_durations(SR1, SR2, N, M):
    """
    There are soooo many ways to have invalid durations, here
    we hit a couple of them
    """

    # differing sample rates

    elem = Element()
    bp = bb.BluePrint()

    bp.insertSegment(0, ramp, (0, 0), dur=N / SR2)
    bp.setSR(SR2)

    wfm = np.linspace(-1, 1, N)
    elem.addArray(1, wfm, SR1)
    elem.addBluePrint(2, bp)

    if SR1 == SR2:
        elem.validateDurations()
    else:
        with pytest.raises(ElementDurationError):
            elem.validateDurations()

    # differing durations
    bp1 = bb.BluePrint()
    bp1.insertSegment(0, ramp, (0, 1), dur=N / SR1)
    bp1.setSR(SR1)

    bp2 = bb.BluePrint()
    bp2.insertSegment(0, ramp, (0, 2), dur=M / SR1)
    bp2.setSR(SR1)

    elem = Element()
    elem.addBluePrint(1, bp1)
    elem.addBluePrint(2, bp2)

    if N == M:
        elem.validateDurations()
    else:
        with pytest.raises(ElementDurationError):
            elem.validateDurations()