Here’s a comprehensive documentation for the test/solver_tests/ilp_solver_test.py
file:
This file contains unit tests for the ILPSolver class in Cassiopeia’s solver module. It tests various aspects of the ILP (Integer Linear Programming) solver, including its ability to handle perfect phylogenies, duplicates, missing data, and edge cases.
The main class TestILPSolver
inherits from unittest.TestCase
and contains multiple test methods. It sets up test data in the setUp
method and defines helper functions for specific test scenarios. The tests cover different aspects of the ILPSolver, from basic functionality to edge cases and error handling.
A test class that inherits from unittest.TestCase
, containing various test methods for the ILPSolver.
setUp
method.find_triplet_structure
.A helper function that determines the structure of a triplet in a given tree.
Name | Type | Description |
---|---|---|
triplet | tuple | A tuple of three nodes |
T | networkx.DiGraph | The tree to analyze |
Name | Type | Description |
---|---|---|
structure | str | The structure of the triplet (“ab”, “ac”, “bc”, or ”-“) |
Sets up the test environment by creating test data and initializing the ILPSolver.
Tests if the ILPSolver raises an error when given ambiguous data.
Tests the functionality of the get_lca_characters_cython function.
Tests the Cython implementation of the Hamming distance function.
Tests the ILPSolver with a single sample input.
Tests the basic constructor of the ILPSolver.
Tests the functionality of inferring a layer of the potential graph.
Tests the inference of a simple potential graph.
Tests the post-processing of a Steiner tree solution.
Tests the functionality of appending sample nodes and removing spurious leaves.
Tests the ILPSolver with a perfect phylogeny scenario.
Tests the potential graph inference with duplicate samples.
Tests the ILPSolver with duplicate samples.
Tests the ILPSolver with missing data.
Tests if the ILPSolver throws an error when a potential graph cannot be found.
Dependency | Purpose |
---|---|
unittest | Provides testing framework |
networkx | Used for graph operations |
numpy | Used for numerical operations |
pandas | Used for data manipulation |
cassiopeia | The main package being tested |
gurobipy | Used for ILP optimization (optional) |
The tests include various assertions to check for expected behavior and raise appropriate errors. The ILPSolverError
is used to handle specific errors related to the ILPSolver.
Some tests may be skipped if Gurobi is not installed, as indicated by the @unittest.skipUnless(GUROBI_INSTALLED, "Gurobi installation not found.")
decorator.
There are no explicit TODOs in the code.
This documentation provides a comprehensive overview of the ilp_solver_test.py
file, covering its purpose, structure, and key components. It should help developers understand the testing suite for the ILPSolver in Cassiopeia.
Here’s a comprehensive documentation for the test/solver_tests/ilp_solver_test.py
file:
This file contains unit tests for the ILPSolver class in Cassiopeia’s solver module. It tests various aspects of the ILP (Integer Linear Programming) solver, including its ability to handle perfect phylogenies, duplicates, missing data, and edge cases.
The main class TestILPSolver
inherits from unittest.TestCase
and contains multiple test methods. It sets up test data in the setUp
method and defines helper functions for specific test scenarios. The tests cover different aspects of the ILPSolver, from basic functionality to edge cases and error handling.
A test class that inherits from unittest.TestCase
, containing various test methods for the ILPSolver.
setUp
method.find_triplet_structure
.A helper function that determines the structure of a triplet in a given tree.
Name | Type | Description |
---|---|---|
triplet | tuple | A tuple of three nodes |
T | networkx.DiGraph | The tree to analyze |
Name | Type | Description |
---|---|---|
structure | str | The structure of the triplet (“ab”, “ac”, “bc”, or ”-“) |
Sets up the test environment by creating test data and initializing the ILPSolver.
Tests if the ILPSolver raises an error when given ambiguous data.
Tests the functionality of the get_lca_characters_cython function.
Tests the Cython implementation of the Hamming distance function.
Tests the ILPSolver with a single sample input.
Tests the basic constructor of the ILPSolver.
Tests the functionality of inferring a layer of the potential graph.
Tests the inference of a simple potential graph.
Tests the post-processing of a Steiner tree solution.
Tests the functionality of appending sample nodes and removing spurious leaves.
Tests the ILPSolver with a perfect phylogeny scenario.
Tests the potential graph inference with duplicate samples.
Tests the ILPSolver with duplicate samples.
Tests the ILPSolver with missing data.
Tests if the ILPSolver throws an error when a potential graph cannot be found.
Dependency | Purpose |
---|---|
unittest | Provides testing framework |
networkx | Used for graph operations |
numpy | Used for numerical operations |
pandas | Used for data manipulation |
cassiopeia | The main package being tested |
gurobipy | Used for ILP optimization (optional) |
The tests include various assertions to check for expected behavior and raise appropriate errors. The ILPSolverError
is used to handle specific errors related to the ILPSolver.
Some tests may be skipped if Gurobi is not installed, as indicated by the @unittest.skipUnless(GUROBI_INSTALLED, "Gurobi installation not found.")
decorator.
There are no explicit TODOs in the code.
This documentation provides a comprehensive overview of the ilp_solver_test.py
file, covering its purpose, structure, and key components. It should help developers understand the testing suite for the ILPSolver in Cassiopeia.