Skip to main contentHere’s a comprehensive documentation for the test/plotting_tests/local_test.py file:
High-level description
This file contains unit tests for the local plotting functionality in the Cassiopeia package. It tests various aspects of the local plotting module, including color strip creation, indel heatmap generation, and the main plotting functions for both matplotlib and plotly.
Code Structure
The main class TestLocalPlotting inherits from unittest.TestCase and contains multiple test methods. Each method tests a specific functionality of the local plotting module. The class uses a setUp method to create a sample CassiopeiaTree and allele table for testing purposes.
Symbols
TestLocalPlotting
Description
A test class that contains unit tests for the local plotting functionality in Cassiopeia.
Internal Logic
- Sets up a sample
CassiopeiaTree and allele table in the setUp method.
- Contains multiple test methods, each testing a specific aspect of the local plotting module.
setUp
Description
Initializes the test environment by creating a sample allele table, graph, cell metadata, and a CassiopeiaTree object.
test_compute_colorstrip_size
Description
Tests the compute_colorstrip_size function for various locations (up, right, left, polar).
test_create_categorical_colorstrip
Description
Tests the create_categorical_colorstrip function for creating a color strip based on categorical data.
test_create_continous_colorstrip
Description
Tests the create_continuous_colorstrip function for creating a color strip based on continuous data. Also tests for a warning when invalid vmin and vmax are provided.
test_create_indel_heatmap
Description
Tests the create_indel_heatmap function for generating a heatmap of indels.
test_plot_matplotlib
Description
Tests the plot_matplotlib function with various parameters and checks for error handling with invalid metadata.
test_plot_plotly
Description
Tests the plot_plotly function with various parameters.
test_create_clade_colors
Description
Tests the create_clade_colors function for generating node and branch colors based on clades.
Dependencies
- unittest
- mock
- networkx
- numpy
- pandas
- cassiopeia
Error Handling
The test methods include assertions to check for expected behavior and error handling. For example, test_plot_matplotlib checks for PlottingError when invalid metadata is provided.
Logging
The test file doesn’t implement any specific logging mechanisms, but it uses assertions and unittest’s built-in reporting for test results.
TODOs
There are no explicit TODOs in the code.
This test file is crucial for ensuring the correctness and robustness of the local plotting functionality in the Cassiopeia package. It covers various aspects of the plotting module, including color generation, heatmap creation, and the main plotting functions for both matplotlib and plotly backends.