<s> from skbio . util . _decorator import experimental <EOL> from skbio . diversity . _util import ( _validate_counts_vector , <EOL> _validate_otu_ids_and_tree , <EOL> _vectorize_counts_and_tree ) <EOL> def _faith_pd ( counts_by_node , branch_lengths ) : <EOL> return ( branch_lengths * ( counts_by_node > <NUM_LIT:0> ) ) . sum ( ) <EOL> @ experimental ( as_of = "<STR_LIT>" ) <EOL> def faith_pd ( counts , otu_ids , tree , validate = True ) : <EOL> """<STR_LIT>""" <EOL> counts_by_node , branch_lengths = _setup_faith_pd ( <EOL> counts , otu_ids , tree , validate , single_sample = True ) <EOL> return _faith_pd ( counts_by_node , branch_lengths ) <EOL> def _setup_faith_pd ( counts , otu_ids , tree , validate , single_sample ) : <EOL> if validate : <EOL> if single_sample : <EOL> counts = _validate_counts_vector ( counts ) <EOL> _validate_otu_ids_and_tree ( counts , otu_ids , tree ) <EOL> else : <EOL> _validate_otu_ids_and_tree ( counts [ <NUM_LIT:0> ] , otu_ids , tree ) <EOL> counts_by_node , tree_index , branch_lengths = _vectorize_counts_and_tree ( counts , otu_ids , tree ) <EOL> return counts_by_node , branch_lengths </s>
