> ## 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.

# local_3d_test.py

## High-level description

This file contains unit tests for the `local_3d` module in the Cassiopeia package. It tests various functions and classes related to 3D plotting of tree structures, including coordinate interpolation, color manipulation, label generation, and the main `Tree3D` class.

## Code Structure

The main test class `TestLocal3DPlotting` inherits from `unittest.TestCase`. It sets up a simulated tree and spatial data in the `setUp` method, which is then used across multiple test methods. Each test method focuses on a specific function or aspect of the `local_3d` module.

## Symbols

### TestLocal3DPlotting

#### Description

A test class that contains multiple unit tests for the `local_3d` module.

#### Internal Logic

1. Sets up a simulated tree and spatial data in `setUp`.
2. Tests individual functions like `interpolate_branch`, `polyline_from_points`, `average_mixing`, etc.
3. Tests the `labels_from_coordinates` function with various inputs and edge cases.
4. Tests the initialization of the `Tree3D` class.

### test\_interpolate\_branch

#### Description

Tests the `interpolate_branch` function from the `local_3d` module.

#### Internal Logic

Checks if the function correctly interpolates a branch between two 3D points.

### test\_polyline\_from\_points

#### Description

Tests the `polyline_from_points` function from the `local_3d` module.

#### Internal Logic

Verifies if the function correctly creates a polyline from a set of 3D points.

### test\_average\_mixing

#### Description

Tests the `average_mixing` function from the `local_3d` module.

#### Internal Logic

Checks if the function correctly averages multiple colors.

### test\_highlight

#### Description

Tests the `highlight` function from the `local_3d` module.

#### Internal Logic

Verifies if the function correctly brightens a given color.

### test\_lowlight

#### Description

Tests the `lowlight` function from the `local_3d` module.

#### Internal Logic

Checks if the function correctly dims a given color.

### test\_labels\_from\_coordinates

#### Description

Tests the `labels_from_coordinates` function from the `local_3d` module.

#### Internal Logic

1. Tests various invalid inputs (shape, attribute key).
2. Checks if the function correctly generates labels and updates tree metadata.
3. Tests with non-square shapes and dense spatial positions.

### test\_Tree3D

#### Description

Tests the initialization of the `Tree3D` class from the `local_3d` module.

#### Internal Logic

Initializes `Tree3D` objects with and without labels and calls the `plot` method to ensure no errors occur.

## Dependencies

The test file depends on the following modules:

| Dependency    | Purpose                                                                |
| :------------ | :--------------------------------------------------------------------- |
| unittest      | Provides the testing framework                                         |
| unittest.mock | Used for mocking objects in tests                                      |
| networkx      | Graph library (imported but not used in the provided code)             |
| numpy         | Used for numerical operations and assertions                           |
| pandas        | Data manipulation library (imported but not used in the provided code) |
| cassiopeia    | The main package being tested                                          |

## Error Handling

The test methods use various `assert` statements and `self.assertRaises` to check for expected behaviors and error conditions.
