<commit_before>package datafu.test.pig.stats;

import static org.testng.Assert.*;

import java.util.ArrayList;
import java.util.List;

import org.apache.pig.data.Tuple;
import org.apache.pig.pigunit.PigTest;
import org.testng.annotations.Test;

import datafu.pig.stats.QuantileUtil;
import datafu.test.pig.PigTests;

public class QuantileTests  extends PigTests
{
  @Test
  public void quantileTest() throws Exception
  {
    PigTest test = createPigTest("test/pig/datafu/test/pig/stats/quantileTest.pig",
                                 "QUANTILES='0.0','0.25','0.5','0.75','1.0'");

    String[] input = {"1","2","3","4","10","5","6","7","8","9"};
    writeLinesToFile("input", input);
        
    test.runScript();
    
    List<Tuple> output = getLinesForAlias(test, "data_out", true);
    
    assertEquals(output.size(),1);
    assertEquals(output.get(0).toString(), "(1.0,3.0,5.5,8.0,10.0)");
  }
  
  @Test 
  public void applyQuantilesTest() throws Exception {
    PigTest test = createPigTest("test/pig/datafu/test/pig/stats/applyQuantilesTest.pig",
                                 "QUANTILES='0.0','0.25','0.5','0.75','1.0'");

    // should yield quantiles (1.0,3.0,5.5,8.0,10.0)
    <commit_msg>Break test on purpose to test travis status image<commit_after>package datafu.test.pig.stats;

import static org.testng.Assert.*;

import java.util.ArrayList;
import java.util.List;

import org.apache.pig.data.Tuple;
import org.apache.pig.pigunit.PigTest;
import org.testng.annotations.Test;

import datafu.pig.stats.QuantileUtil;
import datafu.test.pig.PigTests;

public class QuantileTests  extends PigTests
{
  @Test
  public void quantileTest() throws Exception
  {
    PigTest test = createPigTest("test/pig/datafu/test/pig/stats/quantileTest.pig",
                                 "QUANTILES='0.0','0.25','0.5','0.75','1.0'");

    String[] input = {"2","2","3","4","10","5","6","7","8","9"};
    writeLinesToFile("input", input);
        
    test.runScript();
    
    List<Tuple> output = getLinesForAlias(test, "data_out", true);
    
    assertEquals(output.size(),1);
    assertEquals(output.get(0).toString(), "(1.0,3.0,5.5,8.0,10.0)");
  }
  
  @Test 
  public void applyQuantilesTest() throws Exception {
    PigTest test = createPigTest("test/pig/datafu/test/pig/stats/applyQuantilesTest.pig",
                                 "QUANTILES='0.0','0.25','0.5','0.75','1.0'");

    // should yield quantiles (1.0,3.0,5.5,8.0,10.0)
    
{'fraction_non_alphanumeric': 0.1790073230268511, 'fraction_numerical': 0.04800650935720097, 'mean_word_length': 3.2178387650085765, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '523392', 'n_tokens_mistral': 922, 'n_tokens_neox': 901, 'n_words': 132}