Skip to content

Commit

Permalink
Added tests for cut_segments
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrnr committed Jan 27, 2016
1 parent 5bff939 commit 02413e0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/test_datatools.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@ def test_cut_epochs(self):
rawdata = np.random.randn(1000, 5)
rawcopy = rawdata.copy()

start = -10
stop = 50

x = datatools.cut_segments(rawdata, triggers, -10, 50)

start, stop = -10, 50
x = datatools.cut_segments(rawdata, triggers, start, stop)
self.assertTrue(np.all(rawdata == rawcopy))
self.assertEqual(x.shape, (stop - start, x.shape[1], len(triggers)))

# test if it works with float indices
start, stop = -10.0, 50.0
x = datatools.cut_segments(rawdata, triggers, start, stop)
self.assertEqual(x.shape, (stop - start, x.shape[1], len(triggers)))

self.assertRaises(ValueError, datatools.cut_segments,
rawdata, triggers, 0, 10.001)
self.assertRaises(ValueError, datatools.cut_segments,
rawdata, triggers, -10.1, 50)

for it in range(len(triggers)):
a = rawdata[triggers[it] + start: triggers[it] + stop, :]
b = x[:, :, it]
Expand Down

0 comments on commit 02413e0

Please sign in to comment.