def test_bad_model(self): X = data.sim_data(10) Y = models.bad_model(X) assert pl.allclose(Y.sum(axis=2), 1), 'should be all ones, (%s found)' % str(Y.sum(axis=2)) # test again for 10x2x3 dataset X = data.sim_data(10, [[.1, .4, .5]], [.1, .1, .1]) Y = models.bad_model(X) assert pl.allclose(Y.sum(axis=2), 1), 'should be all ones, (%s found)' % str(Y.sum(axis=2))
def test_sim_data(self): sim_data = data.sim_data(10) assert sim_data.shape == ( 10, 2, 3), 'Should be 10x2x3 matrix of data (%s found)' % str( sim_data.shape) sim_data = data.sim_data(10, [[.1, .4, .5]], [.1, .1, .1]) assert sim_data.shape == ( 10, 1, 3), 'Should be 10x1x3 matrix of data (%s found)' % str( sim_data.shape)
def test_sim_data_2(self): sims = 10000 return # skip for now test1 = pl.zeros(3, dtype='f').view(pl.recarray) for i in range(sims): temp = data.sim_data(1, [0.1,0.1,0.8], [0.01,0.01,0.01]) test1 = pl.vstack((test1, temp)) test1 = test1[1:,] test2 = data.sim_data(sims, [0.1,0.1,0.8], [0.01, 0.01, 0.01]) diff = (test1.mean(0) - test2.mean(0))/test1.mean(0) assert pl.allclose(diff, 0, atol=0.01), 'should be close to zero, (%s found)' % str(diff)
def test_bad_model(self): X = data.sim_data(10) Y = models.bad_model(X) assert pl.allclose( Y.sum(axis=2), 1), 'should be all ones, (%s found)' % str(Y.sum(axis=2)) # test again for 10x2x3 dataset X = data.sim_data(10, [[.1, .4, .5]], [.1, .1, .1]) Y = models.bad_model(X) assert pl.allclose( Y.sum(axis=2), 1), 'should be all ones, (%s found)' % str(Y.sum(axis=2))
def test_sim_data_2(self): sims = 10000 return # skip for now test1 = pl.zeros(3, dtype='f').view(pl.recarray) for i in range(sims): temp = data.sim_data(1, [0.1, 0.1, 0.8], [0.01, 0.01, 0.01]) test1 = pl.vstack((test1, temp)) test1 = test1[1:, ] test2 = data.sim_data(sims, [0.1, 0.1, 0.8], [0.01, 0.01, 0.01]) diff = (test1.mean(0) - test2.mean(0)) / test1.mean(0) assert pl.allclose( diff, 0, atol=0.01), 'should be close to zero, (%s found)' % str(diff)
def test_plot_sim_data(self): return # skip for now X = data.sim_data(10, [.1, .4, .5], [.1, .1, .1]) graphics.plot_sim_data(X) assert list(pl.axis()) == [ 0., 1., 0., 1. ], 'plot limits should be unit square, (%s found)' % str(pl.axis()) graphics.plot_all_sim_data(X)
def setUp(self): self.X = data.sim_data(10)
def test_plot_sim_data(self): return # skip for now X = data.sim_data(10, [.1, .4, .5], [.1, .1, .1]) graphics.plot_sim_data(X) assert list(pl.axis()) == [0., 1., 0., 1.], 'plot limits should be unit square, (%s found)' % str(pl.axis()) graphics.plot_all_sim_data(X)
def test_sim_data(self): sim_data = data.sim_data(10) assert sim_data.shape == (10,2,3), 'Should be 10x2x3 matrix of data (%s found)' % str(sim_data.shape) sim_data = data.sim_data(10, [[.1, .4, .5]], [.1, .1, .1]) assert sim_data.shape == (10,1,3), 'Should be 10x1x3 matrix of data (%s found)' % str(sim_data.shape)