File: _utils.py

package info (click to toggle)
python-skbio 0.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,924 kB
  • sloc: python: 67,527; ansic: 672; makefile: 225
file content (18 lines) | stat: -rw-r--r-- 656 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# ----------------------------------------------------------------------------
# Copyright (c) 2013--, scikit-bio development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE.txt, distributed with this software.
# ----------------------------------------------------------------------------


def _check_dm(dm):
    if dm.shape[0] < 3:
        raise ValueError("Distance matrix must be at least 3x3 to generate a tree.")


def _check_dm_tree(dm, tree):
    _check_dm(dm)
    if frozenset(dm.ids) != tree.subset():
        raise ValueError("Inconsistent taxa between tree and distance matrix.")