couple of final neatenings up of CTD

This commit is contained in:
Douglas Gillespie 2022-09-30 14:49:33 +01:00
parent de809b6572
commit 682715018f
4 changed files with 24 additions and 4 deletions

View File

@ -36,7 +36,7 @@ public class CTClassifierParams implements Cloneable, Serializable, ManagedParam
/** /**
* A unique ID for the classifier that never changes. This is important for accessing data selectors. * A unique ID for the classifier that never changes. This is important for accessing data selectors.
*/ */
public String uniqueID = UUID.randomUUID().toString(); private String uniqueID = UUID.randomUUID().toString();
/** /**
@ -72,4 +72,21 @@ public class CTClassifierParams implements Cloneable, Serializable, ManagedParam
return ps; return ps;
} }
/**
* @return the uniqueID
*/
public String getUniqueID() {
if (uniqueID == null) {
uniqueID = UUID.randomUUID().toString();
}
return uniqueID;
}
/**
* @param uniqueID the uniqueID to set
*/
public void setUniqueID(String uniqueID) {
this.uniqueID = uniqueID;
}
} }

View File

@ -119,14 +119,13 @@ public class Chi2ThresholdClassifier implements CTClassifier {
public void createDataSelector(PamDataBlock<?> source) { public void createDataSelector(PamDataBlock<?> source) {
//System.out.println("Create data selector " +" " + clssfrParams.classifierName + " " + clssfrParams.speciesFlag + " " + clssfrParams.uniqueID ); //System.out.println("Create data selector " +" " + clssfrParams.classifierName + " " + clssfrParams.speciesFlag + " " + clssfrParams.uniqueID );
if (clssfrParams.uniqueID==null) clssfrParams.newUniqueID();
if (dataSelector==null || dataSelector.getPamDataBlock()!=source) { if (dataSelector==null || dataSelector.getPamDataBlock()!=source) {
//create the data selector //create the data selector
//System.out.println("Data selector: " + dataSelector); //System.out.println("Data selector: " + dataSelector);
if (source!=null) { if (source!=null) {
dataSelector=source.getDataSelectCreator().getDataSelector(clickTrainControl.getUnitName() + "_" + clssfrParams.uniqueID dataSelector=source.getDataSelectCreator().getDataSelector(clickTrainControl.getUnitName() + "_" + clssfrParams.getUniqueID()
+ "_X2_threshold_classifier", false, null); + "_X2_threshold_classifier", false, null);
} }
else { else {

View File

@ -132,6 +132,10 @@ public class CTDataSelector extends DataSelector {
if (clickTrain.ctClassifications==null) return false; if (clickTrain.ctClassifications==null) return false;
if (ctSelectParams.classifier == null) {
return false;
}
int nClass = clickTrain.ctClassifications.size(); int nClass = clickTrain.ctClassifications.size();
if (ctSelectParams.allowMultipleChoices == false) { if (ctSelectParams.allowMultipleChoices == false) {
int clsInd = clickTrain.getClassificationIndex(); int clsInd = clickTrain.getClassificationIndex();

View File

@ -229,7 +229,7 @@ public class SimpleCTClassifierPane extends SettingsPane<Chi2ThresholdParams> {
simpleChi2Classifier.getDataSelector().getDialogPaneFX().getParams(true); simpleChi2Classifier.getDataSelector().getDialogPaneFX().getParams(true);
} }
if (this.currParams != null) { if (this.currParams != null) {
currParams.uniqueID = this.currParams.uniqueID; currParams.setUniqueID(this.currParams.getUniqueID());
} }
return this.currParams=currParams; return this.currParams=currParams;