_FitnessEstimator.py
High-level description
The FitnessEstimator
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 class FitnessEstimator
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 the CassiopeiaTree
class from cassiopeia.data
.
Symbols
FitnessEstimatorError
Description
This class represents an exception specific to the FitnessEstimator
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 the estimate_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 a CassiopeiaTree
. 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 input CassiopeiaTree
object directly.
Internal Logic
This method is abstract and therefore has no implementation in the base class.
Side Effects
This code modifies the input CassiopeiaTree
object in the estimate_fitness
method by adding a ‘fitness’ attribute to each node.
TODOs
This code does not contain any TODOs.