> ## Documentation Index
> Fetch the complete documentation index at: https://demo.agenticlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# complete_binary_simulator_test.py

## High-level description

This file contains unit tests for the `CompleteBinarySimulator` class, which is responsible for simulating complete binary trees. The tests verify the initialization of the simulator and the structure of the simulated tree, including its nodes, edges, and branch lengths.

## Symbols

### TestCompleteBinarySimulator

#### Description

This is a test class that inherits from `unittest.TestCase`. It contains two test methods to verify the functionality of the `CompleteBinarySimulator` class.

### test\_init

#### Description

This method tests the initialization of the `CompleteBinarySimulator` class.

#### Internal Logic

1. It checks that the simulator raises a `TreeSimulatorError` when initialized without arguments.
2. It verifies that the simulator raises an error when initialized with an invalid number of cells (not a power of 2).
3. It ensures that the simulator raises an error when initialized with a depth of 0.
4. It confirms that the simulator correctly calculates the depth when initialized with a valid number of cells.

### test\_simulate\_tree

#### Description

This method tests the `simulate_tree` method of the `CompleteBinarySimulator` class.

#### Internal Logic

1. It creates a simulator with a depth of 2 and simulates a tree.
2. It verifies the correct set of nodes in the simulated tree.
3. It checks the correct set of leaf nodes.
4. It confirms the correct set of edges in the tree.
5. It validates the branch lengths (times) for each node in the tree.

## Dependencies

| Dependency           | Purpose                                                              |
| :------------------- | :------------------------------------------------------------------- |
| numpy                | Used for numerical operations (not explicitly used in the test file) |
| unittest             | Provides the testing framework                                       |
| cassiopeia.mixins    | Imports the `TreeSimulatorError` exception                           |
| cassiopeia.simulator | Imports the `CompleteBinarySimulator` class                          |

## Error Handling

The test cases check for proper error handling in the `CompleteBinarySimulator` class by asserting that `TreeSimulatorError` is raised under specific conditions.

## References

* `CompleteBinarySimulator`: The main class being tested, imported from `cassiopeia.simulator`.
* `TreeSimulatorError`: An exception class used for error handling, imported from `cassiopeia.mixins`.

This test file ensures that the `CompleteBinarySimulator` class correctly initializes and generates complete binary trees with the expected structure and properties.
