def test_random(): stim = Stimulus2D.random(8) assert stim._v.shape[0] == 8 for i in xrange(20): stim = Stimulus2D.random((6, 8)) n = stim._v.shape[0] assert n >= 6 and n <= 8 with pytest.raises(ValueError): stim = Stimulus2D.random((8, 6)) with pytest.raises(ValueError): stim = Stimulus2D.random((8, 6, 8)) with pytest.raises(ValueError): stim = Stimulus2D.random((8,))
def test_io(X0): fh = NamedTemporaryFile() X0.save(fh.name, force=True) X1 = Stimulus2D.load(fh.name) assert X0 == X1