Exceptions and warnings#

Every error raised by forestpd derives from ForestPDError, and also from the matching built-in exception (ValueError, ImportError), so code that catches the built-in keeps working.

exception forestpd.ForestPDError[source]#

Bases: Exception

Base exception for all forestpd errors.

Catch this to handle any forestpd-specific error with a single except clause.

exception forestpd.ForestPDValueError[source]#

Bases: ForestPDError, ValueError

Raised when a value passed to a forestpd function is invalid.

Inherits from both ForestPDError and ValueError.

exception forestpd.ForestPDInputError[source]#

Bases: ForestPDValueError

Raised when the input trees, weights, costs, survival probabilities or budget are invalid.

This covers malformed input (unparsable Newick, missing branch lengths, non-positive costs, survival probabilities outside [0, 1), unknown taxon labels) as well as input outside the supported scope (differing leaf sets), and a MAF stage that does not return an agreement forest.

exception forestpd.ForestPDImportError[source]#

Bases: ForestPDError, ImportError

Raised when an optional dependency is needed but not installed.

Converting to and from PhyloZoo objects requires the phylozoo extra (pip install forestpd[phylozoo]). Inherits from both ForestPDError and ImportError.

exception forestpd.ForestPDWarning[source]#

Bases: UserWarning

Warning for input that is valid but probably not what was intended.

For example, trees that look rooted while PD is computed on unrooted trees.