def test_cluster_permutation_test():
 (condition1_1d, condition2_1d, condition1_2d, condition2_2d) = _get_conditions()
 for (condition1, condition2) in zip((condition1_1d, condition1_2d), (condition2_1d, condition2_2d)):
  (T_obs, clusters, cluster_p_values, hist) = permutation_cluster_test([condition1, condition2], n_permutations=100, tail=1, seed=1, buffer_size=None)
  assert_equal(np.sum((cluster_p_values < 0.05)), 1)
  (T_obs, clusters, cluster_p_values, hist) = permutation_cluster_test([condition1, condition2], n_permutations=100, tail=0, seed=1, buffer_size=None)
  assert_equal(np.sum((cluster_p_values < 0.05)), 1)
  buffer_size = (condition1.shape[1] // 10)
  (T_obs, clusters, cluster_p_values_buff, hist) = permutation_cluster_test([condition1, condition2], n_permutations=100, tail=0, seed=1, n_jobs=2, buffer_size=buffer_size)
  assert_array_equal(cluster_p_values, cluster_p_values_buff)

def test_cluster_permutation_test ( ) : ( condition1_1d , condition2_1d , condition1_2d , condition2_2d ) = _get_conditions ( ) for ( condition1 , condition2 ) in zip ( ( condition1_1d , condition1_2d ) , ( condition2_1d , condition2_2d ) ) : ( T_obs , clusters , cluster_p_values , hist ) = permutation_cluster_test ( [ condition1 , condition2 ] , n_permutations = 100 , tail = 1 , seed = 1 , buffer_size = None ) assert_equal ( np . sum ( ( cluster_p_values < 0.05 ) ) , 1 ) ( T_obs , clusters , cluster_p_values , hist ) = permutation_cluster_test ( [ condition1 , condition2 ] , n_permutations = 100 , tail = 0 , seed = 1 , buffer_size = None ) assert_equal ( np . sum ( ( cluster_p_values < 0.05 ) ) , 1 ) buffer_size = ( condition1 . shape [ 1 ] // 10 ) ( T_obs , clusters , cluster_p_values_buff , hist ) = permutation_cluster_test ( [ condition1 , condition2 ] , n_permutations = 100 , tail = 0 , seed = 1 , n_jobs = 2 , buffer_size = buffer_size ) assert_array_equal ( cluster_p_values , cluster_p_values_buff )
test cluster level permutations tests .