fix stability test with correct data

This commit is contained in:
Jonathan Shook 2020-05-19 13:41:49 -05:00
parent 966b434fad
commit 63b203bc3e
2 changed files with 5 additions and 9 deletions

View File

@ -49,12 +49,9 @@ import java.util.function.LongFunction;
@ThreadSafeMapper
public class CSVFrequencySampler implements LongFunction<String> {
private final String filename;
private final String columnName;
private final String[] lines;
private final AliasSamplerDoubleInt sampler;
private Hash hash;
private final Hash hash;
/**
* Create a sampler of strings from the given CSV file. The CSV file must have plain CSV headers
@ -64,8 +61,7 @@ public class CSVFrequencySampler implements LongFunction<String> {
*/
@Example({"CSVFrequencySampler('values.csv','modelno')","Read values.csv, count the frequency of values in 'modelno' column, and sample from this column proportionally"})
public CSVFrequencySampler(String filename, String columnName) {
this.filename = filename;
this.columnName = columnName;
String filename1 = filename;
this.hash=new Hash();
@ -86,7 +82,7 @@ public class CSVFrequencySampler implements LongFunction<String> {
}
int i = 0;
for (String value : values) {
frequencies.add(new EvProbD(i++,Double.valueOf(freq.getCount(value))));
frequencies.add(new EvProbD(i++, (double) freq.getCount(value)));
}
sampler = new AliasSamplerDoubleInt(frequencies);
lines = values.toArray(new String[0]);

View File

@ -20,7 +20,7 @@ public class IntegratedAliasMethodTests {
public void testCSVFrequencySampler() {
CSVFrequencySampler names= new CSVFrequencySampler("data/countries", "COUNTRY_CODE" );
String n = names.apply(23);
assertThat(n).isEqualTo("CZ");
assertThat(n).isEqualTo("TK");
}
@Test
@ -31,6 +31,6 @@ public class IntegratedAliasMethodTests {
','
);
String n = names.apply(23);
assertThat(n).isEqualTo("CZ");
assertThat(n).isEqualTo("TK");
}
}