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 classTestLocalPlotting 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
CassiopeiaTreeand allele table in thesetUpmethod. - 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 aCassiopeiaTree object.
test_compute_colorstrip_size
Description
Tests thecompute_colorstrip_size function for various locations (up, right, left, polar).
test_create_categorical_colorstrip
Description
Tests thecreate_categorical_colorstrip function for creating a color strip based on categorical data.
test_create_continous_colorstrip
Description
Tests thecreate_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 thecreate_indel_heatmap function for generating a heatmap of indels.
test_plot_matplotlib
Description
Tests theplot_matplotlib function with various parameters and checks for error handling with invalid metadata.
test_plot_plotly
Description
Tests theplot_plotly function with various parameters.
test_create_clade_colors
Description
Tests thecreate_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.
