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)
def test_chunktime(): """ Test OTC helper function: _chunk_time """ assert np.array_equal(_chunk_time([5, 6, 7, 8, 10, 55, 56], samp_buffer=0), np.array([[5, 8], [10, 10], [55, 56]])) assert np.array_equal(_chunk_time([5, 6, 7, 8, 10, 55, 56], samp_buffer=2), np.array([[5, 10], [55, 56]]))
def test_chunktime(): """ Test OTC helper function: _chunk_time """ assert np.array_equal(_chunk_time( [5, 6, 7, 8, 10, 55, 56], samp_buffer=0), np.array([[5, 8], [10, 10], [55, 56]])) assert np.array_equal(_chunk_time( [5, 6, 7, 8, 10, 55, 56], samp_buffer=2), np.array([[5, 10], [55, 56]]))