code: def wardq_test_basic(n=100, k=5):
      # Basic check of ward's algorithm
      np.random.seed(0)
      x = np.random.randn(n, 2)
      x[: int(0.7 * n)] += 3
      G = knn(x, k)
      t = ward_quick(G, x)
      u = t.split(2)
      v = np.zeros(n)
      v[: int(0.7 * n)] = 1
      w = np.absolute(u - v)
      assert np.sum(w * (1 - w)) == 0
  
file_path: nipy/nipy/algorithms/clustering/tests/test_hierarchical_clustering.py
imports: import math
  import numpy
  from numpy.random import randn
  from nipy.algorithms.graph.field import field_from_graph_and_data
  from nipy.algorithms.graph.graph import knn
  from ..hierarchical_clustering import average_link_graph, average_link_graph_segment, ward, ward_field_segment, ward_quick, ward_quick_segment, ward_segment
label_desc: Use image node_id 5 for calling a global function with example usage: wardq_test_basic(n, k) without return types