High-level description
This file contains unit tests for the utility functions defined incassiopeia/mixins/utilities.py. It tests the functionality of various utility functions related to handling ambiguous states in character matrices and finding duplicate groups.
Symbols
TestMixinUtilities
Description
This is a test class that inherits fromunittest.TestCase. It contains several test methods to verify the functionality of utility functions from the cassiopeia.mixins.utilities module.
Internal Logic
The class defines three test methods:test_is_ambiguous_state: Tests theis_ambiguous_statefunction.test_unravel_states: Tests theunravel_ambiguous_statesfunction.test_find_duplicated_character_states: Tests thefind_duplicate_groupsfunction.
test_is_ambiguous_state
Description
This method tests theis_ambiguous_state function from the utilities module.
Internal Logic
- Asserts that
(1, 2)is recognized as an ambiguous state. - Asserts that
1is not recognized as an ambiguous state.
test_unravel_states
Description
This method tests theunravel_ambiguous_states function from the utilities module.
Internal Logic
- Tests the function with an array containing both ambiguous and non-ambiguous states.
- Tests the function with an array containing only non-ambiguous states.
- Asserts that the output matches the expected unraveled list in both cases.
test_find_duplicated_character_states
Description
This method tests thefind_duplicate_groups function from the utilities module.
Internal Logic
- Creates a sample character matrix using pandas DataFrame.
- Calls the
find_duplicate_groupsfunction on the character matrix. - Checks if the returned duplicate mappings contain the expected entries.
- Verifies that the keys and values in the duplicate mappings match the expected groups.
Dependencies
Error Handling
The test methods use assertions to verify the correctness of the utility functions. If any assertion fails, anAssertionError will be raised, indicating a test failure.
Notes
- The test file uses the
unittestframework, which is a standard Python testing library. - The tests cover various scenarios, including ambiguous states and duplicate character states in matrices.
- The
test_find_duplicated_character_statesmethod uses a complex character matrix with ambiguous states to thoroughly test thefind_duplicate_groupsfunction.
