def check_clusterer_compute_labels_predict(name, Clusterer):
 (X, y) = make_blobs(n_samples=20, random_state=0)
 clusterer = Clusterer()
 if hasattr(clusterer, 'compute_labels'):
  if hasattr(clusterer, 'random_state'):
   clusterer.set_params(random_state=0)
  X_pred1 = clusterer.fit(X).predict(X)
  clusterer.set_params(compute_labels=False)
  X_pred2 = clusterer.fit(X).predict(X)
  assert_array_equal(X_pred1, X_pred2)

def check_clusterer_compute_labels_predict ( name , Clusterer ) : ( X , y ) = make_blobs ( n_samples = 20 , random_state = 0 ) clusterer = Clusterer ( ) if hasattr ( clusterer , 'compute_labels' ) : if hasattr ( clusterer , 'random_state' ) : clusterer . set_params ( random_state = 0 ) X_pred1 = clusterer . fit ( X ) . predict ( X ) clusterer . set_params ( compute_labels = False ) X_pred2 = clusterer . fit ( X ) . predict ( X ) assert_array_equal ( X_pred1 , X_pred2 )
check that predict is invariant of compute_labels .