1
1
package edu .caltech .ipac .firefly .server .query ;
2
2
import edu .caltech .ipac .astro .IpacTableException ;
3
3
4
+ import edu .caltech .ipac .firefly .ConfigTest ;
4
5
import edu .caltech .ipac .util .DataGroup ;
5
6
import edu .caltech .ipac .util .DataObject ;
6
7
import edu .caltech .ipac .util .DataType ;
13
14
/**
14
15
* Created by zhang on 10/29/15.
15
16
*/
16
- public class HistogramProcessorTest {
17
-
18
-
17
+ public class HistogramProcessorTest extends ConfigTest {
19
18
20
19
21
20
@ Test
22
- public void testFixedBinSize () throws DataAccessException {
23
-
21
+ public void testFixedBinSize () throws DataAccessException {
24
22
//create five bin histData
25
23
double [] histData = {
26
24
0.00000 ,
@@ -53,8 +51,39 @@ public void testFixedBinSize() throws DataAccessException {
53
51
validateResult (expectedDG , outDG );
54
52
55
53
54
+ HistogramProcessor hp1 = new HistogramProcessor ();
55
+ hp1 .setBinNumber (6 );
56
+ //showEmptyBins = true
57
+ double [] histData1 = {
58
+ 2.70000 ,
59
+ 2.50000 ,
60
+ 6.00000 ,
61
+ 6.20000 ,
62
+ 7.00000 ,
63
+ 4.05000 ,
64
+ 7.10000 ,
65
+ 7.30000 ,
66
+ 7.40000 ,
67
+ 9.8000 ,
68
+ 9.20000 ,
69
+ 8.50000 ,
70
+ };
71
+ hp1 .showEmptyBin =true ;
72
+ hp1 .min = 0 ;
73
+ hp1 .max = 12 ;
74
+ int [] expectedNumPointsInBin1 ={0 , 2 , 1 , 6 , 3 , 0 };
75
+ double [] expectedBinMin1 ={0.0 , 2 , 4 , 6.0 , 8.0 , 10.0 };
76
+ double [] expectedBinMax1 ={2 , 4 , 6 , 8 , 10 , 12 };
77
+ DataGroup expectedDG1 = createDataGroup (expectedNumPointsInBin1 , expectedBinMin1 , expectedBinMax1 );
78
+
79
+ DataGroup outDG1 = hp1 .createHistogramTable (histData1 );
80
+
81
+ validateResult (expectedDG1 , outDG1 );
82
+
83
+
56
84
}
57
85
86
+
58
87
private void validateResult (DataGroup expected , DataGroup calculated ){
59
88
for (int i =0 ; i <expected .size (); i ++ ){
60
89
Object [] expectedDJ = expected .get (i ).getData ();
@@ -105,8 +134,6 @@ private DataGroup createDataGroup( int[] numPointInBin, double[] binMin, double[
105
134
*
106
135
*
107
136
*/
108
-
109
-
110
137
public void testVariableBinSize () {
111
138
112
139
double [] histData = {
@@ -309,7 +336,7 @@ public void testVariableBinSize() {
309
336
int nbin =6 ;
310
337
double delta =( max -min )/100 *nbin ;
311
338
//double[] expectedBins={ -14.3997518146, -6.0146658712, 1.1825927451, 2.7383052264, 5.4734012726, 12.938348639};
312
- boolean showEmptyBin = false ;
339
+
313
340
314
341
int [] expectedNumPointInBin = {12 , 59 , 68 , 36 , 16 };
315
342
@@ -337,6 +364,9 @@ public void testVariableBinSize() {
337
364
try {
338
365
339
366
HistogramProcessor hp = new HistogramProcessor ();
367
+ hp .showEmptyBin =false ;
368
+
369
+ //Algorithm=null, the variable bin size is used
340
370
DataGroup outDG = hp .createHistogramTable (histData );
341
371
342
372
DataGroup expectedDG = createDataGroup (expectedNumPointInBin , expectedBinMin , expectedBinMax );
@@ -346,17 +376,6 @@ public void testVariableBinSize() {
346
376
catch (Exception ex ){
347
377
ex .printStackTrace ();
348
378
}
349
- ;
350
-
351
-
352
- }
353
- public static void main (String args []) throws IpacTableException , IOException , DataAccessException {
354
- HistogramProcessorTest myTest = new HistogramProcessorTest ();
355
-
356
- myTest .testFixedBinSize ();
357
- myTest .testVariableBinSize ();
358
-
359
-
360
379
361
380
}
362
381
0 commit comments