Skip to content

Commit

Permalink
add additional convert methods
Browse files Browse the repository at this point in the history
  • Loading branch information
matakleo committed Jun 3, 2024
1 parent e0cdc5e commit 79e4bec
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions cdm/core/src/main/java/ucar/nc2/filter/Classifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ public static Classifier createFromArray(Array arr, DataType type) {
return new Classifier();
}

@Override
public double convert(double val) {
return classifyArray(val);
}


/** Custom exception for invalid values */
public static class InvalidValueException extends Exception {
Expand All @@ -37,7 +34,7 @@ public InvalidValueException(String message) {
public int classifyArray(double val) {
int classifiedVal;
if (val >= 0) {
classifiedVal = 1;
classifiedVal = 10;
} else {
classifiedVal = 0;
}
Expand Down Expand Up @@ -124,6 +121,18 @@ public int[] classifyArray(float[] inputArray) throws InvalidValueException {
return classifiedArray;
}

@Override
public double convert(double val) {
return classifyArray(val);
}

public double convert(float val) {
return classifyArray(val);
}

public double convert(int val) {
return classifyArray(val);
}
}


0 comments on commit 79e4bec

Please sign in to comment.