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:

DependencyPurpose
unittestProvides the testing framework
unittest.mockUsed for mocking objects in tests
networkxGraph library (imported but not used in the provided code)
numpyUsed for numerical operations and assertions
pandasData manipulation library (imported but not used in the provided code)
cassiopeiaThe main package being tested

Error Handling

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