def test_permutation_step_down_p():
 try:
  try:
   from sklearn.feature_extraction.image import grid_to_graph
  except ImportError:
   from scikits.learn.feature_extraction.image import grid_to_graph
 except ImportError:
  return
 rng = np.random.RandomState(0)
 X = rng.randn(9, 2, 10)
 X[:, 0:2, 0:2] += 2
 X[:, 1, 5:9] += 0.5
 thresh = 2
 (t, clusters, p, H0) = permutation_cluster_1samp_test(X, threshold=thresh, step_down_p=1.0)
 (t, clusters, p_old, H0) = permutation_cluster_1samp_test(X, threshold=thresh, step_down_p=0.0)
 assert_equal(np.sum((p_old < 0.05)), 1)
 (t, clusters, p_new, H0) = permutation_cluster_1samp_test(X, threshold=thresh, step_down_p=0.05)
 assert_equal(np.sum((p_new < 0.05)), 2)
 assert_true(np.all((p_old >= p_new)))

def test_permutation_step_down_p ( ) : try : try : from sklearn . feature_extraction . image import grid_to_graph except ImportError : from scikits . learn . feature_extraction . image import grid_to_graph except ImportError : return rng = np . random . RandomState ( 0 ) X = rng . randn ( 9 , 2 , 10 ) X [ : , 0 : 2 , 0 : 2 ] += 2 X [ : , 1 , 5 : 9 ] += 0.5 thresh = 2 ( t , clusters , p , H0 ) = permutation_cluster_1samp_test ( X , threshold = thresh , step_down_p = 1.0 ) ( t , clusters , p_old , H0 ) = permutation_cluster_1samp_test ( X , threshold = thresh , step_down_p = 0.0 ) assert_equal ( np . sum ( ( p_old < 0.05 ) ) , 1 ) ( t , clusters , p_new , H0 ) = permutation_cluster_1samp_test ( X , threshold = thresh , step_down_p = 0.05 ) assert_equal ( np . sum ( ( p_new < 0.05 ) ) , 2 ) assert_true ( np . all ( ( p_old >= p_new ) ) )
test cluster level permutations with step_down_p .