Example #1
0
def test_raiseinputerrors():
    """
    Confirm that ValueErrors from dumb user input are raised
    """
    # Load data
    data = np.load(os.path.dirname(pacpy.__file__) + '/tests/exampledata.npy')
    data2 = copy.copy(data)
    data2[-1] = np.nan

    with pytest.raises(ValueError) as excinfo:
        plv(data, data[:-1], (13, 30), (80, 200))
    assert 'same length' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        plv(data, data2, (13, 30), (80, 200))
    assert 'NaNs' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        plv(data, data, (13, 30, 31), (80, 200))
    assert 'two elements' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        plv(data, data, (13, 30), (80, 200, 201))
    assert 'two elements' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        plv(data, data, (-13, 30), (80, 200))
    assert 'must be > 0' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        plv(data, data, (13, 30), (-80, 200))
    assert 'must be > 0' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        mi_tort(data, data, (13, 30), (80, 200), Nbins=1)
    assert 'integer >1' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        mi_tort(data, data, (13, 30), (80, 200), Nbins=8.8)
    assert 'integer >1' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        otc(data, (80, 200), -1)
    assert 'positive number' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        otc(data, (80, 200), 4, t_modsig=(.5, -.5))
    assert 'Invalid time range' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        _peaktimes(data, prc=101)
    assert '0 and 100' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        _chunk_time(data, samp_buffer=-1)
    assert 'positive number' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        _chunk_time(data, samp_buffer=2.5)
    assert 'integer' in str(excinfo.value)
Example #2
0
def test_raiseinputerrors():
    """
    Confirm that ValueErrors from dumb user input are raised
    """
    # Load data
    data = np.load(os.path.dirname(pacpy.__file__) + '/tests/exampledata.npy')
    data2 = copy.copy(data)
    data2[-1] = np.nan

    with pytest.raises(ValueError) as excinfo:
        plv(data, data[:-1], (13, 30), (80, 200))
    assert 'same length' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        plv(data, data2, (13, 30), (80, 200))
    assert 'NaNs' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        plv(data, data, (13, 30, 31), (80, 200))
    assert 'two elements' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        plv(data, data, (13, 30), (80, 200, 201))
    assert 'two elements' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        plv(data, data, (-13, 30), (80, 200))
    assert 'must be > 0' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        plv(data, data, (13, 30), (-80, 200))
    assert 'must be > 0' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        mi_tort(data, data, (13, 30), (80, 200), Nbins=1)
    assert 'integer >1' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        mi_tort(data, data, (13, 30), (80, 200), Nbins=8.8)
    assert 'integer >1' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        otc(data, (80, 200), -1)
    assert 'positive number' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        otc(data, (80, 200), 4, t_modsig=(.5, -.5))
    assert 'Invalid time range' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        _peaktimes(data, prc=101)
    assert '0 and 100' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        _chunk_time(data, samp_buffer=-1)
    assert 'positive number' in str(excinfo.value)

    with pytest.raises(ValueError) as excinfo:
        _chunk_time(data, samp_buffer=2.5)
    assert 'integer' in str(excinfo.value)
Example #3
0
def test_peaktimes():
    """
    Test OTC helper function: _peaktimes
    """
    # Load data
    data = np.load(os.path.dirname(pacpy.__file__) + '/tests/exampledata.npy')

    # Confirm functionality
    assert _peaktimes(data[:1000], prc=99) == 344
    assert len(_peaktimes(data[:10000], prc=99)) == 11
Example #4
0
def test_peaktimes():
    """
    Test OTC helper function: _peaktimes
    """
    # Load data
    data = np.load(os.path.dirname(pacpy.__file__) + '/tests/exampledata.npy')

    # Confirm functionality
    assert _peaktimes(data[:1000], prc=99) == 344
    assert len(_peaktimes(data[:10000], prc=99)) == 11