def test_gen_1D_gauss_even_spacing(): n_vox = 9 res = 180 rfs, centers = sim.generate_1d_gaussian_rfs(n_vox, res, (0, res - 1), random_tuning=False) assert np.all(centers == np.array([0, 19, 39, 59, 79, 99, 119, 139, 159]))
def test_gen_1d_gauss_range(): res = 180 range_values = (-10, res - 11) rfs, centers = sim.generate_1d_gaussian_rfs(1, res, range_values, random_tuning=False) sim_data = sim.generate_1d_rf_responses(rfs, np.array([-10]), res, range_values, 0) assert sim_data[0, ] > 0 range_values = (10, res + 10) rfs, centers = sim.generate_1d_gaussian_rfs(1, res, range_values, random_tuning=False) sim_data = sim.generate_1d_rf_responses(rfs, np.array([10]), res, range_values, 0) assert sim_data[0, ] > 0
def test_gen_1D_gauss_shape(): n_vox = 10 res = 180 rfs, centers = sim.generate_1d_gaussian_rfs(n_vox, res, (0, res - 1)) assert rfs.shape == (n_vox, res) assert centers.size == n_vox sim_data = sim.generate_1d_rf_responses(rfs, np.array([0, 10, 20]), res, (0, res - 1)) assert sim_data.shape == (n_vox, 3)
assert s, "Invalid data" # Test number of data dimensions def test_data_dimensions(): x = np.random.rand(5, 10, 2) s = InvertedEncoding() with pytest.raises(ValueError): s.fit(x, np.random.rand(5)) # Define some data to use in the following tests. n, dim = 297, 9 n_ = n // dim y = np.repeat(np.linspace(0, 180-(180/dim), dim), n_) voxel_rfs, _ = generate_1d_gaussian_rfs(dim, 180, (0, 179), random_tuning=False) X = generate_1d_rf_responses(voxel_rfs, y, 180, (0, 179), trial_noise=0.25).transpose() X2 = generate_1d_rf_responses(voxel_rfs, y, 180, (0, 179), trial_noise=0.25).transpose() # Test if valid data can be fit. def test_can_fit_data(): Invt_model = InvertedEncoding() Invt_model.fit(X, y) # Test if valid data can be fit in circular space. def test_can_fit_circular_space(): s = InvertedEncoding(6, 5, 'circular', range_stop=360)