Skip to content

IRSA-371:numbins sometimes ignored #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,19 @@ public class HistogramProcessor extends IpacTablePartProcessor {
// private final String ALGORITHM = "algorithm";
private final String FALSEPOSTIVERATE = "falsePositiveRate";
private final String PRESERVE_EMPTY_BIN="preserveEmptyBins";
private boolean showEmptyBin= true;
private String algorithm = null;// FIXED_SIZE_ALGORITHM;
private int numBins=0;
private double binWidth=0.0;
private String binSelection=null;
private String binSize;
private double min = Double.NaN;
private double max = Double.NaN;
private String columnExpression;
private double falsePostiveRate = 0.05;

//change to protected so that they can be set by unit test class
protected boolean showEmptyBin= true;
protected int numBins=0;
protected double min = Double.NaN;
protected double max = Double.NaN;


private static String[] getInputFilePath(String inputFileName) {
String[] dirs = inputFileName.split("/");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.caltech.ipac.firefly.server.query;
import edu.caltech.ipac.astro.IpacTableException;

import edu.caltech.ipac.firefly.ConfigTest;
import edu.caltech.ipac.util.DataGroup;
import edu.caltech.ipac.util.DataObject;
import edu.caltech.ipac.util.DataType;
Expand All @@ -13,14 +14,11 @@
/**
* Created by zhang on 10/29/15.
*/
public class HistogramProcessorTest {


public class HistogramProcessorTest extends ConfigTest {


@Test
public void testFixedBinSize() throws DataAccessException {

public void testFixedBinSize() throws DataAccessException {
//create five bin histData
double[] histData = {
0.00000,
Expand Down Expand Up @@ -53,8 +51,39 @@ public void testFixedBinSize() throws DataAccessException {
validateResult(expectedDG, outDG);


HistogramProcessor hp1 = new HistogramProcessor();
hp1.setBinNumber(6);
//showEmptyBins = true
double[] histData1 = {
2.70000,
2.50000,
6.00000,
6.20000,
7.00000,
4.05000,
7.10000,
7.30000,
7.40000,
9.8000,
9.20000,
8.50000,
};
hp1.showEmptyBin=true;
hp1.min= 0;
hp1.max = 12;
int[] expectedNumPointsInBin1={0, 2, 1, 6, 3, 0};
double[] expectedBinMin1={0.0, 2, 4, 6.0, 8.0, 10.0};
double[] expectedBinMax1={2, 4, 6, 8, 10, 12};
DataGroup expectedDG1= createDataGroup(expectedNumPointsInBin1, expectedBinMin1, expectedBinMax1);

DataGroup outDG1 = hp1.createHistogramTable(histData1);

validateResult(expectedDG1, outDG1);


}


private void validateResult(DataGroup expected, DataGroup calculated){
for (int i=0; i<expected.size(); i++ ){
Object[] expectedDJ = expected.get(i).getData();
Expand Down Expand Up @@ -105,8 +134,6 @@ private DataGroup createDataGroup( int[] numPointInBin, double[] binMin, double[
*
*
*/


public void testVariableBinSize() {

double[] histData = {
Expand Down Expand Up @@ -309,7 +336,7 @@ public void testVariableBinSize() {
int nbin=6;
double delta =( max -min)/100*nbin;
//double[] expectedBins={ -14.3997518146, -6.0146658712, 1.1825927451, 2.7383052264, 5.4734012726, 12.938348639};
boolean showEmptyBin=false;


int[] expectedNumPointInBin = {12, 59, 68, 36, 16};

Expand Down Expand Up @@ -337,6 +364,9 @@ public void testVariableBinSize() {
try {

HistogramProcessor hp = new HistogramProcessor();
hp.showEmptyBin=false;

//Algorithm=null, the variable bin size is used
DataGroup outDG = hp.createHistogramTable(histData);

DataGroup expectedDG = createDataGroup(expectedNumPointInBin, expectedBinMin, expectedBinMax );
Expand All @@ -346,17 +376,6 @@ public void testVariableBinSize() {
catch (Exception ex){
ex.printStackTrace();
}
;


}
public static void main(String args[]) throws IpacTableException, IOException, DataAccessException {
HistogramProcessorTest myTest = new HistogramProcessorTest();

myTest.testFixedBinSize();
myTest.testVariableBinSize();



}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ public void testStatisticDataArray(){


}

/*
public static void main(String args[]) throws IpacTableException, IOException, DataAccessException, FitsException, ClassNotFoundException {
String fileName = "ipacTableTestFile.tbl";
StatisticsProcessorTest myTest = new StatisticsProcessorTest();
sp = new StatisticsProcessor();
inDg = FileLoader.loadIpacTable(StatisticsProcessor.class, fileName );
myTest.testCreateStatisticTable();
myTest.testStatisticDataArray();
}
}*/

}