-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
147 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 54 additions & 54 deletions
108
cdm/core/src/test/data/ncml/enhance/testClassifier.ncml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 1998-2023 University Corporation for Atmospheric Research/Unidata | ||
~ See LICENSE for license information. | ||
--> | ||
|
||
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" enhance="all"> | ||
|
||
<variable name="doublePositives" shape="5" type="double"> | ||
<attribute name="classify"/> | ||
<values>1.0 2.0 3.0 4.0 5.0</values> | ||
</variable> | ||
|
||
<variable name="doubleNegatives" shape="5" type="double"> | ||
<attribute name="classify"/> | ||
<values>-1.0 -2.0 -3.0 -4.0 -5.0</values> | ||
</variable> | ||
|
||
<variable name="doubleMix" shape="5" type="double"> | ||
<attribute name="classify"/> | ||
<values>1.0 -2.0 0.0 4.0 -5.0</values> | ||
</variable> | ||
|
||
<variable name="floatPositives" shape="5" type="float"> | ||
<attribute name="classify"/> | ||
<values>1.0 2.0 3.0 4.0 5.0</values> | ||
</variable> | ||
|
||
<variable name="floatNegatives" shape="5" type="float"> | ||
<attribute name="classify"/> | ||
<values>-1.0 -2.0 -3.0 -4.0 -5.0</values> | ||
</variable> | ||
<variable name="floatMix" shape="5" type="float"> | ||
<attribute name="classify"/> | ||
<values>1.0 -2.0 0.0 4.0 -5.0</values> | ||
</variable> | ||
|
||
<variable name="intPositives" shape="5" type="int"> | ||
<attribute name="classify"/> | ||
<values>1 2 3 4 5</values> | ||
</variable> | ||
|
||
<variable name="intNegatives" shape="5" type="int"> | ||
<attribute name="classify"/> | ||
<values>-1 -2 -3 -4 -5</values> | ||
</variable> | ||
<variable name="intMix" shape="5" type="int"> | ||
<attribute name="classify"/> | ||
<values>1 -2 0 4 -5</values> | ||
</variable> | ||
|
||
|
||
|
||
</netcdf> | ||
<!--<?xml version="1.0" encoding="UTF-8"?>--> | ||
<!--<!–--> | ||
<!-- ~ Copyright (c) 1998-2023 University Corporation for Atmospheric Research/Unidata--> | ||
<!-- ~ See LICENSE for license information.--> | ||
<!-- –>--> | ||
|
||
<!--<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" enhance="all">--> | ||
|
||
<!-- <variable name="doublePositives" shape="5" type="double">--> | ||
<!-- <attribute name="classify"/>--> | ||
<!-- <values>1.0 2.0 3.0 4.0 5.0</values>--> | ||
<!-- </variable>--> | ||
|
||
<!-- <variable name="doubleNegatives" shape="5" type="double">--> | ||
<!-- <attribute name="classify"/>--> | ||
<!-- <values>-1.0 -2.0 -3.0 -4.0 -5.0</values>--> | ||
<!-- </variable>--> | ||
|
||
<!-- <variable name="doubleMix" shape="5" type="double">--> | ||
<!-- <attribute name="classify"/>--> | ||
<!-- <values>1.0 -2.0 0.0 4.0 -5.0</values>--> | ||
<!-- </variable>--> | ||
|
||
<!-- <variable name="floatPositives" shape="5" type="float">--> | ||
<!-- <attribute name="classify"/>--> | ||
<!-- <values>1.0 2.0 3.0 4.0 5.0</values>--> | ||
<!-- </variable>--> | ||
|
||
<!-- <variable name="floatNegatives" shape="5" type="float">--> | ||
<!-- <attribute name="classify"/>--> | ||
<!-- <values>-1.0 -2.0 -3.0 -4.0 -5.0</values>--> | ||
<!-- </variable>--> | ||
<!-- <variable name="floatMix" shape="5" type="float">--> | ||
<!-- <attribute name="classify"/>--> | ||
<!-- <values>1.0 -2.0 0.0 4.0 -5.0</values>--> | ||
<!-- </variable>--> | ||
|
||
<!-- <variable name="intPositives" shape="5" type="int">--> | ||
<!-- <attribute name="classify"/>--> | ||
<!-- <values>1 2 3 4 5</values>--> | ||
<!-- </variable>--> | ||
|
||
<!-- <variable name="intNegatives" shape="5" type="int">--> | ||
<!-- <attribute name="classify"/>--> | ||
<!-- <values>-1 -2 -3 -4 -5</values>--> | ||
<!-- </variable>--> | ||
<!-- <variable name="intMix" shape="5" type="int">--> | ||
<!-- <attribute name="classify"/>--> | ||
<!-- <values>1 -2 0 4 -5</values>--> | ||
<!-- </variable>--> | ||
|
||
|
||
|
||
<!--</netcdf>--> |
102 changes: 51 additions & 51 deletions
102
cdm/core/src/test/java/ucar/nc2/filter/TestClassifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
package ucar.nc2.filter; | ||
|
||
import static org.junit.Assert.*; | ||
import org.junit.Test; | ||
import ucar.ma2.Array; | ||
|
||
|
||
public class TestClassifier { | ||
|
||
|
||
|
||
/** test doubles */ | ||
@Test | ||
public void testClassifyDoubleArray_AllPositive() { | ||
Classifier classifier = new Classifier(); | ||
double[] input = {1.1, 2.2, 3.3}; | ||
int[] expected = {1, 1, 1}; | ||
Array DATA = Array.makeFromJavaArray(input); | ||
assertArrayEquals(expected, classifier.classifyDoubleArray(DATA)); | ||
} | ||
|
||
@Test | ||
public void testClassifyDoubleArray_AllNegative() { | ||
Classifier classifier = new Classifier(); | ||
double[] input = {-1.1, -2.2, -3.3}; | ||
int[] expected = {0, 0, 0}; | ||
Array DATA = Array.makeFromJavaArray(input); | ||
assertArrayEquals(expected, classifier.classifyDoubleArray(DATA)); | ||
} | ||
|
||
@Test | ||
public void testClassifyDoubleArray_Mixed() { | ||
Classifier classifier = new Classifier(); | ||
double[] input = {-1.1, 2.2, -3.3, 4.4}; | ||
int[] expected = {0, 1, 0, 1}; | ||
Array DATA = Array.makeFromJavaArray(input); | ||
assertArrayEquals(expected, classifier.classifyDoubleArray(DATA)); | ||
} | ||
|
||
@Test | ||
public void testClassifyDoubleArray_WithZero() { | ||
Classifier classifier = new Classifier(); | ||
double[] input = {0.0, -1.1, 1.1, 0.0, 0.0, 0.0}; | ||
int[] expected = {1, 0, 1, 1, 1, 1}; | ||
Array DATA = Array.makeFromJavaArray(input); | ||
assertArrayEquals(expected, classifier.classifyDoubleArray(DATA)); | ||
} | ||
|
||
|
||
|
||
} | ||
// package ucar.nc2.filter; | ||
// | ||
// import static org.junit.Assert.*; | ||
// import org.junit.Test; | ||
// import ucar.ma2.Array; | ||
// | ||
// | ||
// public class TestClassifier { | ||
// | ||
// | ||
// | ||
// /** test doubles */ | ||
// @Test | ||
// public void testClassifyDoubleArray_AllPositive() { | ||
// Classifier classifier = new Classifier(); | ||
// double[] input = {1.1, 2.2, 3.3}; | ||
// int[] expected = {1, 1, 1}; | ||
// Array DATA = Array.makeFromJavaArray(input); | ||
// assertArrayEquals(expected, classifier.classifyDoubleArray(DATA)); | ||
// } | ||
// | ||
// @Test | ||
// public void testClassifyDoubleArray_AllNegative() { | ||
// Classifier classifier = new Classifier(); | ||
// double[] input = {-1.1, -2.2, -3.3}; | ||
// int[] expected = {0, 0, 0}; | ||
// Array DATA = Array.makeFromJavaArray(input); | ||
// assertArrayEquals(expected, classifier.classifyDoubleArray(DATA)); | ||
// } | ||
// | ||
// @Test | ||
// public void testClassifyDoubleArray_Mixed() { | ||
// Classifier classifier = new Classifier(); | ||
// double[] input = {-1.1, 2.2, -3.3, 4.4}; | ||
// int[] expected = {0, 1, 0, 1}; | ||
// Array DATA = Array.makeFromJavaArray(input); | ||
// assertArrayEquals(expected, classifier.classifyDoubleArray(DATA)); | ||
// } | ||
// | ||
// @Test | ||
// public void testClassifyDoubleArray_WithZero() { | ||
// Classifier classifier = new Classifier(); | ||
// double[] input = {0.0, -1.1, 1.1, 0.0, 0.0, 0.0}; | ||
// int[] expected = {1, 0, 1, 1, 1, 1}; | ||
// Array DATA = Array.makeFromJavaArray(input); | ||
// assertArrayEquals(expected, classifier.classifyDoubleArray(DATA)); | ||
// } | ||
// | ||
// | ||
// | ||
// } |
Oops, something went wrong.