High-level description
TheFitnessEstimator class in cassiopeia/tools/fitness_estimator/_FitnessEstimator.py defines an abstract base class for all fitness estimation algorithms in the Cassiopeia library. It mandates that all derived classes implement the estimate_fitness method, which calculates and assigns a ‘fitness’ attribute to each node in a given CassiopeiaTree.
Code Structure
The code defines an abstract base classFitnessEstimator and a custom exception class FitnessEstimatorError. The FitnessEstimator class has a single abstract method, estimate_fitness, which needs to be implemented by concrete fitness estimation algorithm classes.
References
This code references theCassiopeiaTree class from cassiopeia.data.
Symbols
FitnessEstimatorError
Description
This class represents an exception specific to theFitnessEstimator class and its subclasses. It is raised when errors occur during fitness estimation.
Inputs
This class does not have any inputs.Outputs
This class does not have any outputs.FitnessEstimator
Description
This abstract base class defines the interface for all fitness estimation algorithms. It requires derived classes to implement theestimate_fitness method.
Inputs
This class does not have any inputs.Outputs
This class does not have any outputs.Internal Logic
This class does not have any internal logic.FitnessEstimator.estimate_fitness
Description
This abstract method defines the interface for estimating the fitness of nodes in aCassiopeiaTree. Concrete fitness estimation algorithms must implement this method.
Inputs
| Name | Type | Description |
|---|---|---|
| tree | CassiopeiaTree | A CassiopeiaTree object representing the tree for which to estimate fitness. |
Outputs
This method does not return any values. It modifies the inputCassiopeiaTree object directly.
Internal Logic
This method is abstract and therefore has no implementation in the base class.Side Effects
This code modifies the inputCassiopeiaTree object in the estimate_fitness method by adding a ‘fitness’ attribute to each node.
