code: def to_genotypes(self, ploidy, copy=False):
          
  
          # check ploidy is compatible
          if (self.shape[1] % ploidy) > 0:
              raise ValueError('incompatible ploidy')
  
          # reshape
          newshape = (self.shape[0], -1, ploidy)
          data = self.reshape(newshape)
  
          # wrap
          g = GenotypeArray(data, copy=copy)
  
          return g
docs: Reshape a haplotype array to view it as genotypes by restoring the
          ploidy dimension.
  
          Parameters
          ----------
          ploidy : int
              The sample ploidy.
          copy : bool, optional
              If True, make a copy of data.
  
          Returns
          -------
          g : ndarray, int, shape (n_variants, n_samples, ploidy)
              Genotype array (sharing same underlying buffer).
          copy : bool, optional
              If True, copy the data.
  
          Examples
          --------
  
          >>> import allel
          >>> h = allel.HaplotypeArray([[0, 0, 0, 1],
          ...                           [0, 1, 1, 1],
          ...                           [0, 2, -1, -1]], dtype='i1')
          >>> h.to_genotypes(ploidy=2)
          <GenotypeArray shape=(3, 2, 2) dtype=int8>
          0/0 0/1
          0/1 1/1
          0/2 ./.