Class PairsTableCalculator
Object
PairsTableCalculator
- All Implemented Interfaces:
FeatureCalculatorMulti<FeatureInputPairObjects>
,FeatureTableCalculator<FeatureInputPairObjects>
public class PairsTableCalculator
extends Object
implements FeatureTableCalculator<FeatureInputPairObjects>
A feature-session to evaluate pairs of objects.
Successive pairs are evaluated in five different ways:
- the image in which the object exists (on {code listImage}) i.e. the energy-stack.
- the left-object in the pair (on
listSingle
) - the right-object in the pair (on
listSingle
) - the pair (on {code listPair})
- both objects merged together (on {code listSingle}}
Due to the predictable pattern, feature-calculations can be cached predictably and appropriately to avoid redundancies.
Two types of caching are applied to avoid redundancy:
- The internal calculation caches of first/second/merged are reused as the internal calculation sub-caches in pair.
- The entire results are cached (as a function of the input) for first/second, as the same inputs reappear multiple times.
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionPairsTableCalculator
(MergedPairsFeatures features) Constructs a PairsTableCalculator with default inclusion and error suppression.PairsTableCalculator
(MergedPairsFeatures features, MergedPairsInclude include, boolean suppressErrors) -
Method Summary
Modifier and TypeMethodDescriptioncalculate
(FeatureInputPairObjects input) Calculate the results of the features with a particular input.calculate
(FeatureInputPairObjects input, FeatureList<FeatureInputPairObjects> featuresSubset) Calculates the results of a subset of the features with a particular input.calculateMaybeSuppressErrors
(FeatureInputPairObjects input, ErrorReporter errorReporter) Calculates features for the input, optionally suppressing errors.calculateSuppressErrors
(FeatureInputPairObjects input, ErrorReporter errorReporter) Calculates the results for aninput
recording the error to anErrorReporter
if anything goes wrong, but throwing no exception.Creates a list of names for each feature (columns of the table).Makes a copy of the feature-store for a new thread.int
The number of features that is calculated on each call toFeatureCalculatorMulti.calculate(T)
, and therefore the size of the returnedResultsVector
.void
start
(ImageInitialization initializtion, Optional<EnergyStack> energyStack, Logger logger) Initializes a feature store that has the same structure as that previously created by createFeatures() from the same object.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.anchoranalysis.feature.calculate.bound.FeatureCalculatorMulti
calculate
-
Constructor Details
-
PairsTableCalculator
Constructs a PairsTableCalculator with default inclusion and error suppression.- Parameters:
features
- the merged pairs features to use
-
PairsTableCalculator
public PairsTableCalculator(MergedPairsFeatures features, MergedPairsInclude include, boolean suppressErrors)
-
-
Method Details
-
start
public void start(ImageInitialization initializtion, Optional<EnergyStack> energyStack, Logger logger) throws InitializeException Description copied from interface:FeatureTableCalculator
Initializes a feature store that has the same structure as that previously created by createFeatures() from the same object.- Specified by:
start
in interfaceFeatureTableCalculator<FeatureInputPairObjects>
- Parameters:
initializtion
- the image initialization contextenergyStack
- an optional energy stack for feature calculationlogger
- a logger for reporting initialization progress or errors- Throws:
InitializeException
- if initialization fails
-
calculate
Description copied from interface:FeatureCalculatorMulti
Calculate the results of the features with a particular input.- Specified by:
calculate
in interfaceFeatureCalculatorMulti<FeatureInputPairObjects>
- Parameters:
input
- the input to calculate.- Returns:
- the results of the calculation.
- Throws:
NamedFeatureCalculateException
- if any feature cannot be successfully calculated.
-
calculate
public ResultsVector calculate(FeatureInputPairObjects input, FeatureList<FeatureInputPairObjects> featuresSubset) Description copied from interface:FeatureCalculatorMulti
Calculates the results of a subset of the features with a particular input.- Specified by:
calculate
in interfaceFeatureCalculatorMulti<FeatureInputPairObjects>
- Parameters:
input
- the input to calculate.featuresSubset
- the subset of features (from those bound to the current instance) to calculate with.- Returns:
- the results of the calculation.
-
calculateSuppressErrors
public ResultsVector calculateSuppressErrors(FeatureInputPairObjects input, ErrorReporter errorReporter) Description copied from interface:FeatureCalculatorMulti
Calculates the results for aninput
recording the error to anErrorReporter
if anything goes wrong, but throwing no exception.- Specified by:
calculateSuppressErrors
in interfaceFeatureCalculatorMulti<FeatureInputPairObjects>
- Parameters:
input
- the input to calculate.errorReporter
- where errors are recorded.- Returns:
- the results of the calculation.
-
calculateMaybeSuppressErrors
public ResultsVector calculateMaybeSuppressErrors(FeatureInputPairObjects input, ErrorReporter errorReporter) throws NamedFeatureCalculateException Calculates features for the input, optionally suppressing errors.- Parameters:
input
- the input pair of objectserrorReporter
- the error reporter to use- Returns:
- the calculated feature results
- Throws:
NamedFeatureCalculateException
- if an error occurs during calculation and error suppression is disabled
-
createFeatureNames
Description copied from interface:FeatureTableCalculator
Creates a list of names for each feature (columns of the table).- Specified by:
createFeatureNames
in interfaceFeatureTableCalculator<FeatureInputPairObjects>
- Returns:
- the list of feature names
-
sizeFeatures
public int sizeFeatures()Description copied from interface:FeatureCalculatorMulti
The number of features that is calculated on each call toFeatureCalculatorMulti.calculate(T)
, and therefore the size of the returnedResultsVector
.- Specified by:
sizeFeatures
in interfaceFeatureCalculatorMulti<FeatureInputPairObjects>
- Returns:
- the number of features.
-
duplicateForNewThread
Description copied from interface:FeatureTableCalculator
Makes a copy of the feature-store for a new thread.Deep-copies the features. Shallow-copies everything else.
- Specified by:
duplicateForNewThread
in interfaceFeatureTableCalculator<FeatureInputPairObjects>
- Returns:
- the copied feature-store
-