High-level description
This file contains unit tests for the LBIJungle fitness estimator in the cassiopeia.tools module. It tests the functionality of the LBIJungle class on a small tree to ensure that fitness estimates are calculated correctly and make sense based on the tree structure.Code Structure
The file defines a single test classTestLBIJungle
which inherits from unittest.TestCase
. This class contains two test methods: test_small_tree
and test_raises_error_if_leaf_name_startswith_underscore
.
Symbols
TestLBIJungle
Description
A test class that contains unit tests for the LBIJungle fitness estimator.Internal Logic
The class sets up test scenarios and asserts expected outcomes for the LBIJungle fitness estimator.test_small_tree
Description
Tests the LBIJungle fitness estimator on a small, manually constructed tree to verify that the fitness estimates are sensible.Internal Logic
- Constructs a small tree using networkx.
- Converts the networkx tree to a CassiopeiaTree.
- Sets node times for the tree.
- Creates an LBIJungle fitness estimator and applies it to the tree.
- Retrieves fitness estimates for all nodes except the root.
- Performs several assertions to check if the fitness estimates make sense based on the tree structure:
- Compares fitness of internal nodes.
- Checks equality of fitness for leaves with the same parent.
- Compares fitness between different groups of leaves.
- Verifies that parent nodes have higher fitness than their children.
test_raises_error_if_leaf_name_startswith_underscore
Description
Tests that the LBIJungle fitness estimator raises a FitnessEstimatorError when a leaf name starts with an underscore.Internal Logic
- Constructs a small tree with a leaf name starting with an underscore.
- Converts the networkx tree to a CassiopeiaTree.
- Creates an LBIJungle fitness estimator.
- Asserts that applying the estimator to the tree raises a FitnessEstimatorError.
Dependencies
- unittest: Python’s built-in unit testing framework
- networkx: For creating and manipulating graph structures
- cassiopeia.data.CassiopeiaTree: The tree data structure used in Cassiopeia
- cassiopeia.tools.FitnessEstimatorError: Custom error for fitness estimation issues
- cassiopeia.tools.LBIJungle: The fitness estimator being tested