def test_timecorr(): data_dl = hyp.tools.format_data(data_list) data_pdf = hyp.tools.format_data(pandas_dataframe) data_npa = hyp.tools.format_data(numpy_array) # data_npl = hyp.tools.format_data(numpy_array_list) # data_rand = hyp.tools.format_data(random_numbers) # these are now lists assert isinstance(data_dl, list) Test_dl = data_dl[0].shape[0] Test_pdf = data_pdf[0].shape[0] Test_npa = data_npa[0].shape[0] #Test returns the shape of the weights_function # Test_npl= data_npl[0].shape[0] # Test_rand= data_rn[0].shape[0] assert isinstance(Test_pdf, int) dl_tester = gaussian_weights(Test_dl, params=gaussian_params) pdf_tester = gaussian_weights(Test_pdf, params=gaussian_params) npa_tester = gaussian_weights(Test_npa, params=gaussian_params) # thrid_tester = gaussian_weights(T3, params=gaussian_params) # fourth_tester = gaussian_weights(T4, params=gaussian_params) assert isinstance(npa_tester, np.ndarray)
def test_wisfc(): weights = gaussian_weights(T, params=gaussian_params) w_list = wisfc(data, weights) assert isinstance(w_list, list) w_array = wisfc(template_data, weights) assert isinstance(w_array, np.ndarray)
def test_wcorr(): weights = gaussian_weights(T, params=gaussian_params) corrs = wcorr(template_data[:, 0][:, np.newaxis], template_data[:, 1][:, np.newaxis], weights) col_1 = np.atleast_2d(data_sim[:, 0]).T col_2 = np.atleast_2d(data_sim[:, 1]).T corrs_col_arrays = np.squeeze(wcorr(data_sim, data_sim, weights_sim)) corrs_multidim = wcorr(col_1, data_sim, weights_sim) corrs_col = np.squeeze(wcorr(col_1, col_1, weights_sim)) corrs_col_neg = np.squeeze(wcorr(-col_1, col_1, weights_sim)) corrs_col_12 = np.squeeze(wcorr(col_2, col_1, weights_sim)) # correlate one column with itself and the same column in larger array is the same assert (np.allclose(corrs_col, corrs_multidim[0][0])) # correlating a timeseries with -1 times itself produces -1's assert corrs_col.mean() == 1 # correlate one column with the second column and the same column in larger array is the same assert (np.allclose(corrs_col_12, corrs_multidim[0][1])) # correlating a timeseries with -1 times itself produces negative correlations assert (np.allclose(-corrs_col, corrs_col_neg)) # correlating a timeseries with -1 times itself produces -1's assert corrs_col_neg.mean() == -1 # check if corresponding columns in 3d array produces 1 assert (np.isclose(corrs_col_arrays[4, 4, 500], 1)) # check if toeplitz matrix is produced assert (np.allclose(corrs_col_arrays[:, :, 500], R, atol=.2)) # check if corrs is a numpy array assert isinstance(corrs, np.ndarray)
def test_gaussian_weights(): test_gw = gaussian_weights(T, params=gaussian_params) assert isinstance(test_gw, np.ndarray)
'params': { 'scale': width } } try_data = [] repdata = 4 for i in range(repdata): try_data.append(data_sim) try_data = np.array(try_data) gps = {'var': 100} T_sim = data_sim.shape[0] weights_sim = gaussian_weights(T_sim, gps) template_data = np.cumsum(np.random.randn(T, D), axis=0) data = [] for s in np.arange(S): data.append(template_data + np.multiply( 0.1, np.random.randn(template_data.shape[0], template_data.shape[1]))) def test_gaussian_weights(): test_gw = gaussian_weights(T, params=gaussian_params) assert isinstance(test_gw, np.ndarray)