nodes: 0, module; 1, function_definition; 2, function_name:voight_painting; 3, parameters; 4, block; 5, identifier:h; 6, expression_statement; 7, comment:# check inputs; 8, comment:# N.B., ensure int8 so we can use cython optimisation; 9, expression_statement; 10, if_statement; 11, if_statement; 12, comment:# sort by prefix; 13, expression_statement; 14, expression_statement; 15, comment:# paint; 16, expression_statement; 17, return_statement; 18, comment:"""Paint haplotypes, assigning a unique integer to each shared haplotype
      prefix.
  
      Parameters
      ----------
      h : array_like, int, shape (n_variants, n_haplotypes)
          Haplotype array.
  
      Returns
      -------
      painting : ndarray, int, shape (n_variants, n_haplotypes)
          Painting array.
      indices : ndarray, int, shape (n_hapotypes,)
          Haplotype indices after sorting by prefix.
  
      """; 19, assignment; 20, comparison_operator:h.max() > 1; 21, block; 22, comparison_operator:h.min() < 0; 23, block; 24, assignment; 25, assignment; 26, assignment; 27, expression_list; 28, identifier:h; 29, call; 30, call; 31, integer:1; 32, raise_statement; 33, call; 34, integer:0; 35, raise_statement; 36, identifier:indices; 37, call; 38, identifier:h; 39, call; 40, identifier:painting; 41, call; 42, identifier:painting; 43, identifier:indices; 44, identifier:HaplotypeArray; 45, argument_list; 46, attribute; 47, argument_list; 48, call; 49, attribute; 50, argument_list; 51, call; 52, attribute; 53, argument_list; 54, attribute; 55, argument_list; 56, identifier:paint_shared_prefixes; 57, argument_list; 58, call; 59, keyword_argument; 60, identifier:h; 61, identifier:max; 62, identifier:NotImplementedError; 63, argument_list; 64, identifier:h; 65, identifier:min; 66, identifier:NotImplementedError; 67, argument_list; 68, identifier:h; 69, identifier:prefix_argsort; 70, identifier:np; 71, identifier:take; 72, identifier:h; 73, identifier:indices; 74, keyword_argument; 75, call; 76, attribute; 77, argument_list; 78, identifier:copy; 79, False; 80, string; 81, string; 82, identifier:axis; 83, integer:1; 84, identifier:memoryview_safe; 85, argument_list; 86, identifier:np; 87, identifier:asarray; 88, identifier:h; 89, string_content:only biallelic variants are supported; 90, string_content:missing calls are not supported; 91, call; 92, attribute; 93, argument_list; 94, identifier:np; 95, identifier:asarray; 96, identifier:h
code: def voight_painting(h):
      """Paint haplotypes, assigning a unique integer to each shared haplotype
      prefix.
  
      Parameters
      ----------
      h : array_like, int, shape (n_variants, n_haplotypes)
          Haplotype array.
  
      Returns
      -------
      painting : ndarray, int, shape (n_variants, n_haplotypes)
          Painting array.
      indices : ndarray, int, shape (n_hapotypes,)
          Haplotype indices after sorting by prefix.
  
      """
  
      # check inputs
      # N.B., ensure int8 so we can use cython optimisation
      h = HaplotypeArray(np.asarray(h), copy=False)
      if h.max() > 1:
          raise NotImplementedError('only biallelic variants are supported')
      if h.min() < 0:
          raise NotImplementedError('missing calls are not supported')
  
      # sort by prefix
      indices = h.prefix_argsort()
      h = np.take(h, indices, axis=1)
  
      # paint
      painting = paint_shared_prefixes(memoryview_safe(np.asarray(h)))
  
      return painting, indices