biom.table.Table.iter_pairwise — biom-format.org

# biom-format.org

## biom.table.Table.iter_pairwise

`Table.` `iter_pairwise`(dense=True, axis='sample', tri=True, diag=False)

  Pairwise iteration over self

  Parameters: | dense : bool, optional Defaults to `True`. If `False`, yield compressed sparse row or compressed sparse columns if axis is ‘observation’ or ‘sample’, respectively. axis : {‘sample’, ‘observation’}, optional The axis to iterate over. tri : bool, optional If `True`, just yield [i, j] and not [j, i] diag : bool, optional If `True`, yield [i, i]
  Returns: | GeneratorType Yields [(val_i, id_i, metadata_i), (val_j, id_j, metadata_j)]
  Raises: | UnknownAxisError

  Examples

      >>> from biom import example_table

  By default, only the upper triangle without the diagonal of the resulting pairwise combinations is yielded.

      >>> iter_ = example_table.iter_pairwise()
      >>> for (val_i, id_i, md_i), (val_j, id_j, md_j) in iter_:
      ...     print id_i, id_j
      S1 S2
      S1 S3
      S2 S3

  The full pairwise combinations can also be yielded though.

      >>> iter_ = example_table.iter_pairwise(tri=False, diag=True)
      >>> for (val_i, id_i, md_i), (val_j, id_j, md_j) in iter_:
      ...     print id_i, id_j
      S1 S1
      S1 S2
      S1 S3
      S2 S1
      S2 S2
      S2 S3
      S3 S1
      S3 S2
      S3 S3