def test__UE_surrogate(self): mat = self.binary_sts pattern_hash = np.array([4]) N = 3 _, rate_avg_surr, _, n_emp_surr,indices_surr =\ ue._UE(mat, N, pattern_hash, method='surrogate_TrialByTrial', n_surr=100) _, rate_avg, _, n_emp,indices =\ ue._UE(mat, N, pattern_hash, method='analytic_TrialByTrial') self.assertTrue(np.allclose(n_emp ,n_emp_surr)) self.assertTrue(np.allclose(rate_avg ,rate_avg_surr)) for item0_cnt,item0 in enumerate(indices): for item1_cnt,item1 in enumerate(item0): self.assertTrue(np.allclose(indices_surr[item0_cnt][item1_cnt],item1))
def test__UE_surrogate(self): mat = self.binary_sts pattern_hash = np.array([4]) N = 3 _, rate_avg_surr, _, n_emp_surr,indices_surr =\ ue._UE(mat, N, pattern_hash, method='surrogate_TrialByTrial', n_surr=100) _, rate_avg, _, n_emp,indices =\ ue._UE(mat, N, pattern_hash, method='analytic_TrialByTrial') self.assertTrue(np.allclose(n_emp ,n_emp_surr)) self.assertTrue(np.allclose(rate_avg ,rate_avg_surr)) for item0_cnt,item0 in enumerate(indices): for item1_cnt,item1 in enumerate(item0): self.assertTrue(np.allclose(indices_surr[item0_cnt][item1_cnt],item1))
def test__UE_default(self): mat = self.binary_sts pattern_hash = np.array([4, 6]) expected_S = np.array([-0.26226523, 0.04959301]) expected_idx = [[[0], [3]], [[], [2, 4]]] expected_nemp = np.array([1., 3.]) expected_nexp = np.array([1.04, 2.56]) expected_rate = np.array([0.9, 0.7, 0.6]) S, rate_avg, n_exp, n_emp, indices = ue._UE(mat, pattern_hash) self.assertTrue(np.allclose(S, expected_S)) self.assertTrue(np.allclose(n_exp, expected_nexp)) self.assertTrue(np.allclose(n_emp, expected_nemp)) self.assertTrue(np.allclose(expected_rate, rate_avg)) for item0_cnt, item0 in enumerate(indices): for item1_cnt, item1 in enumerate(item0): self.assertTrue( np.allclose(expected_idx[item0_cnt][item1_cnt], item1))
def test__UE_default(self): mat = self.binary_sts pattern_hash = np.array([4,6]) N = 3 expected_S = np.array([-0.26226523, 0.04959301]) expected_idx = [[[0], [3]], [[], [2, 4]]] expected_nemp = np.array([ 1., 3.]) expected_nexp = np.array([ 1.04, 2.56]) expected_rate = np.array([ 0.9, 0.7, 0.6]) S, rate_avg, n_exp, n_emp,indices = ue._UE(mat,N,pattern_hash) self.assertTrue(np.allclose(S ,expected_S)) self.assertTrue(np.allclose(n_exp ,expected_nexp)) self.assertTrue(np.allclose(n_emp ,expected_nemp)) self.assertTrue(np.allclose(expected_rate ,rate_avg)) for item0_cnt,item0 in enumerate(indices): for item1_cnt,item1 in enumerate(item0): self.assertTrue(np.allclose(expected_idx[item0_cnt][item1_cnt],item1))