text:
SEQAN_DEFINE_TEST(test_vcf_io_read_vcf_header)
{
    seqan::CharString vcfPath = SEQAN_PATH_TO_ROOT();
    append(vcfPath, "/extras/tests/vcf_io/example.vcf");

    std::fstream inF(toCString(vcfPath), std::ios::in | std::ios::binary);
    SEQAN_ASSERT(inF.good());

    seqan::RecordReader<std::fstream, seqan::SinglePass<> > reader(inF);
    seqan::VcfHeader vcfHeader;
    seqan::VcfIOContext vcfIOContext(vcfHeader.sequenceNames, vcfHeader.sampleNames);

    SEQAN_ASSERT_EQ(read(vcfHeader, reader, vcfIOContext, seqan::Vcf()), 0);

    SEQAN_ASSERT_EQ(length(vcfHeader.headerRecords), 18u);
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[0].key, "fileformat");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[0].value, "VCFv4.1");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[1].key, "fileDate");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[1].value, "20090805");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[2].key, "source");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[2].value, "myImputationProgramV3.1");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[3].key, "reference");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[3].value, "file:///seq/references/1000GenomesPilot-NCBI36.fasta");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[4].key, "contig");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[4].value, "<ID=20,length=62435964,assembly=B36,md5=f126cdf8a6e0c7f379d618ff66beb2da,species=\"Homo sapiens\",taxonomy=x>");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[5].key, "phasing");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[5].value, "partial");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[6].key, "INFO");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[6].value, "<ID=NS,Number=1,Type=Integer,Description=\"Number of Samples With Data\">");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[7].key, "INFO");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[7].value, "<ID=DP,Number=1,Type=Integer,Description=\"Total Depth\">");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[8].key, "INFO");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[8].value, "<ID=AF,Number=A,Type=Float,Description=\"Allele Frequency\">");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[9].key, "INFO");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[9].value, "<ID=AA,Number=1,Type=String,Description=\"Ancestral Allele\">");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[10].key, "INFO");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[10].value, "<ID=DB,Number=0,Type=Flag,Description=\"dbSNP membership, build 129\">");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[11].key, "INFO");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[11].value, "<ID=H2,Number=0,Type=Flag,Description=\"HapMap2 membership\">");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[12].key, "FILTER");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[12].value, "<ID=q10,Description=\"Quality below 10\">");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[13].key, "FILTER");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[13].value, "<ID=s50,Description=\"Less than 50% of samples have data\">");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[14].key, "FORMAT");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[14].value, "<ID=GT,Number=1,Type=String,Description=\"Genotype\">");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[15].key, "FORMAT");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[15].value, "<ID=GQ,Number=1,Type=Integer,Description=\"Genotype Quality\">");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[16].key, "FORMAT");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[16].value, "<ID=DP,Number=1,Type=Integer,Description=\"Read Depth\">");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[17].key, "FORMAT");
    SEQAN_ASSERT_EQ(vcfHeader.headerRecords[17].value, "<ID=HQ,Number=2,Type=Integer,Description=\"Haplotype Quality\">");

    SEQAN_ASSERT_EQ(length(vcfHeader.sequenceNames), 1u);
    SEQAN_ASSERT_EQ(vcfHeader.sequenceNames[0], "20");

    SEQAN_ASSERT_EQ(length(vcfHeader.sampleNames), 3u);
    SEQAN_ASSERT_EQ(vcfHeader.sampleNames[0], "NA00001");
    SEQAN_ASSERT_EQ(vcfHeader.sampleNames[1], "NA00002");
    SEQAN_ASSERT_EQ(vcfHeader.sampleNames[2], "NA00003");
}

SEQAN_DEFINE_TEST(test_vcf_io_read_vcf_record)
{
    seqan::CharString vcfPath = SEQAN_PATH_TO_ROOT();
    append(vcfPath, "/extras/tests/vcf_io/example.vcf");

    std::fstream inF(toCString(vcfPath), std::ios::in | std::ios::binary);
    SEQAN_ASSERT(inF.good());

    seqan::RecordReader<std::fstream, seqan::SinglePass<> > reader(inF);
    seqan::VcfHeader vcfHeader;
    seqan::VcfIOContext vcfIOContext(vcfHeader.sequenceNames, vcfHeader.sampleNames);

    SEQAN_ASSERT_EQ(read(vcfHeader, reader, vcfIOContext, seqan::Vcf()), 0);

    seqan::String<seqan::VcfRecord> records;
    while (!atEnd(reader))
    {
        seqan::VcfRecord record;
        SEQAN_ASSERT_EQ(readRecord(record, reader, vcfIOContext, seqan::Vcf()), 0);
        appendValue(records, record);
    }

    SEQAN_ASSERT_EQ(length(records), 3u);

    SEQAN_ASSERT_EQ(records[0].rID, 0);
    SEQAN_ASSERT_EQ(records[0].beginPos, 14369);
    SEQAN_ASSERT_EQ(records[0].id, "rs6054257");
    SEQAN_ASSERT_EQ(records[0].ref, "G");
    SEQAN_ASSERT_EQ(records[0].alt, "A");
    SEQAN_ASSERT_EQ(records[0].qual, 29);
    SEQAN_ASSERT_EQ(records[0].filter, "PASS");
    SEQAN_ASSERT_EQ(records[0].info, "NS=3;DP=14;AF=0.5;DB;H2");
    SEQAN_ASSERT_EQ(records[0].format, "GT:GQ:DP:HQ");
    SEQAN_ASSERT_EQ(length(records[0].genotypeInfos), 3u);

    SEQAN_ASSERT_EQ(records[1].rID, 0);
    SEQAN_ASSERT_EQ(records[1].beginPos, 17329);
    SEQAN_ASSERT_EQ(records[1].id, ".");
    SEQAN_ASSERT_EQ(records[1].ref, "T");
    SEQAN_ASSERT_EQ(records[1].alt, "A");
    SEQAN_ASSERT_EQ(records[1].qual, 3);
    SEQAN_ASSERT_EQ(records[1].filter, "q10");
    SEQAN_ASSERT_EQ(records[1].info, "NS=3;DP=11;AF=0.017");
    SEQAN_ASSERT_EQ(records[1].format, "GT:GQ:DP:HQ");
    SEQAN_ASSERT_EQ(length(records[1].genotypeInfos), 3u);

    SEQAN_ASSERT_EQ(records[2].rID, 0);
    SEQAN_ASSERT_EQ(records[2].beginPos, 1110695);
    SEQAN_ASSERT_EQ(records[2].id, "rs6040355");
    SEQAN_ASSERT_EQ(records[2].ref, "A");
    SEQAN_ASSERT_EQ(records[2].alt, "G,T");
    SEQAN_ASSERT_EQ(records[2].qual, 67);
    SEQAN_ASSERT_EQ(records[2].filter, "PASS");
    SEQAN_ASSERT_EQ(records[2].info, "NS=2;DP=10;AF=0.333,0.667;AA=T;DB");
    SEQAN_ASSERT_EQ(records[2].format, "GT:GQ:DP:HQ");
    SEQAN_ASSERT_EQ(length(records[2].genotypeInfos), 3u);
}

SEQAN_DEFINE_TEST(test_vcf_io_vcf_stream_read_record)
{
    seqan::CharString vcfPath = SEQAN_PATH_TO_ROOT();
    append(vcfPath, "/extras/tests/vcf_io/example.vcf");

    seqan::VcfStream vcfStream(toCString(vcfPath));
    SEQAN_ASSERT(isGood(vcfStream));

    SEQAN_ASSERT_EQ(length(vcfStream.header.headerRecords), 18u);
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[0].key, "fileformat");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[0].value, "VCFv4.1");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[1].key, "fileDate");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[1].value, "20090805");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[2].key, "source");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[2].value, "myImputationProgramV3.1");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[3].key, "reference");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[3].value, "file:///seq/references/1000GenomesPilot-NCBI36.fasta");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[4].key, "contig");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[4].value, "<ID=20,length=62435964,assembly=B36,md5=f126cdf8a6e0c7f379d618ff66beb2da,species=\"Homo sapiens\",taxonomy=x>");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[5].key, "phasing");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[5].value, "partial");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[6].key, "INFO");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[6].value, "<ID=NS,Number=1,Type=Integer,Description=\"Number of Samples With Data\">");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[7].key, "INFO");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[7].value, "<ID=DP,Number=1,Type=Integer,Description=\"Total Depth\">");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[8].key, "INFO");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[8].value, "<ID=AF,Number=A,Type=Float,Description=\"Allele Frequency\">");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[9].key, "INFO");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[9].value, "<ID=AA,Number=1,Type=String,Description=\"Ancestral Allele\">");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[10].key, "INFO");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[10].value, "<ID=DB,Number=0,Type=Flag,Description=\"dbSNP membership, build 129\">");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[11].key, "INFO");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[11].value, "<ID=H2,Number=0,Type=Flag,Description=\"HapMap2 membership\">");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[12].key, "FILTER");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[12].value, "<ID=q10,Description=\"Quality below 10\">");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[13].key, "FILTER");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[13].value, "<ID=s50,Description=\"Less than 50% of samples have data\">");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[14].key, "FORMAT");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[14].value, "<ID=GT,Number=1,Type=String,Description=\"Genotype\">");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[15].key, "FORMAT");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[15].value, "<ID=GQ,Number=1,Type=Integer,Description=\"Genotype Quality\">");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[16].key, "FORMAT");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[16].value, "<ID=DP,Number=1,Type=Integer,Description=\"Read Depth\">");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[17].key, "FORMAT");
    SEQAN_ASSERT_EQ(vcfStream.header.headerRecords[17].value, "<ID=HQ,Number=2,Type=Integer,Description=\"Haplotype Quality\">");

    SEQAN_ASSERT_EQ(length(vcfStream.header.sequenceNames), 1u);
    SEQAN_ASSERT_EQ(vcfStream.header.sequenceNames[0], "20");

    SEQAN_ASSERT_EQ(length(vcfStream.header.sampleNames), 3u);
    SEQAN_ASSERT_EQ(vcfStream.header.sampleNames[0], "NA00001");
    SEQAN_ASSERT_EQ(vcfStream.header.sampleNames[1], "NA00002");
    SEQAN_ASSERT_EQ(vcfStream.header.sampleNames[2], "NA00003");

    seqan::String<seqan::VcfRecord> records;
    while (!atEnd(vcfStream))
    {
        seqan::VcfRecord record;
        SEQAN_ASSERT_EQ(readRecord(record, vcfStream), 0);
        appendValue(records, record);
    }

    SEQAN_ASSERT_EQ(length(records), 3u);

    SEQAN_ASSERT_EQ(records[0].rID, 0);
    SEQAN_ASSERT_EQ(records[0].beginPos, 14369);
    SEQAN_ASSERT_EQ(records[0].id, "rs6054257");
    SEQAN_ASSERT_EQ(records[0].ref, "G");
    SEQAN_ASSERT_EQ(records[0].alt, "A");
    SEQAN_ASSERT_EQ(records[0].qual, 29);
    SEQAN_ASSERT_EQ(records[0].filter, "PASS");
    SEQAN_ASSERT_EQ(records[0].info, "NS=3;DP=14;AF=0.5;DB;H2");
    SEQAN_ASSERT_EQ(records[0].format, "GT:GQ:DP:HQ");
    SEQAN_ASSERT_EQ(length(records[0].genotypeInfos), 3u);

    SEQAN_ASSERT_EQ(records[1].rID, 0);
    SEQAN_ASSERT_EQ(records[1].beginPos, 17329);
    SEQAN_ASSERT_EQ(records[1].id, ".");
    SEQAN_ASSERT_EQ(records[1].ref, "T");
    SEQAN_ASSERT_EQ(records[1].alt, "A");
    SEQAN_ASSERT_EQ(records[1].qual, 3);
    SEQAN_ASSERT_EQ(records[1].filter, "q10");
    SEQAN_ASSERT_EQ(records[1].info, "NS=3;DP=11;AF=0.017");
    SEQAN_ASSERT_EQ(records[1].format, "GT:GQ:DP:HQ");
    SEQAN_ASSERT_EQ(length(records[1].genotypeInfos), 3u);

    SEQAN_ASSERT_EQ(records[2].rID, 0);
    SEQAN_ASSERT_EQ(records[2].beginPos, 1110695);
    SEQAN_ASSERT_EQ(records[2].id, "rs6040355");
    SEQAN_ASSERT_EQ(records[2].ref, "A");
    SEQAN_ASSERT_EQ(records[2].alt, "G,T");
    SEQAN_ASSERT_EQ(records[2].qual, 67);
    SEQAN_ASSERT_EQ(records[2].filter, "PASS");
    SEQAN_ASSERT_EQ(records[2].info, "NS=2;DP=10;AF=0.333,0.667;AA=T;DB");
    SEQAN_ASSERT_EQ(records[2].format, "GT:GQ:DP:HQ");
    SEQAN_ASSERT_EQ(length(records[2].genotypeInfos), 3u);
}

SEQAN_DEFINE_TEST(test_vcf_io_write_vcf_header)
{
    seqan::CharString tmpPath(SEQAN_TEMP_FILENAME());
    std::fstream outF(toCString(tmpPath), std::ios::out | std::ios::binary);
    SEQAN_ASSERT(outF.good());

    seqan::VcfHeader vcfHeader;
    appendValue(vcfHeader.sequenceNames, "20");
    appendValue(vcfHeader.sampleNames, "NA00001");
    appendValue(vcfHeader.sampleNames, "NA00002");
    appendValue(vcfHeader.sampleNames, "NA00003");

    resize(vcfHeader.headerRecords, 18);
    vcfHeader.headerRecords[0].key = "fileformat";
    vcfHeader.headerRecords[0].value = "VCFv4.1";
    vcfHeader.headerRecords[1].key = "fileDate";
    vcfHeader.headerRecords[1].value = "20090805";
    vcfHeader.headerRecords[2].key = "source";
    vcfHeader.headerRecords[2].value = "myImputationProgramV3.1";
    vcfHeader.headerRecords[3].key = "reference";
    vcfHeader.headerRecords[3].value = "file:///seq/references/1000GenomesPilot-NCBI36.fasta";
    vcfHeader.headerRecords[4].key = "contig";
    vcfHeader.headerRecords[4].value = "<ID=20,length=62435964,assembly=B36,md5=f126cdf8a6e0c7f379d618ff66beb2da,species=\"Homo sapiens\",taxonomy=x>";
    vcfHeader.headerRecords[5].key = "phasing";
    vcfHeader.headerRecords[5].value = "partial";
    vcfHeader.headerRecords[6].key = "INFO";
    vcfHeader.headerRecords[6].value = "<ID=NS,Number=1,Type=Integer,Description=\"Number of Samples With Data\">";
    vcfHeader.headerRecords[7].key = "INFO";
    vcfHeader.headerRecords[7].value = "<ID=DP,Number=1,Type=Integer,Description=\"Total Depth\">";
    vcfHeader.headerRecords[8].key = "INFO";
    vcfHeader.headerRecords[8].value = "<ID=AF,Number=A,Type=Float,Description=\"Allele Frequency\">";
    vcfHeader.headerRecords[9].key = "INFO";
    vcfHeader.headerRecords[9].value = "<ID=AA,Number=1,Type=String,Description=\"Ancestral Allele\">";
    vcfHeader.headerRecords[10].key = "INFO";
    vcfHeader.headerRecords[10].value = "<ID=DB,Number=0,Type=Flag,Description=\"dbSNP membership, build 129\">";
    vcfHeader.headerRecords[11].key = "INFO";
    vcfHeader.headerRecords[11].value = "<ID=H2,Number=0,Type=Flag,Description=\"HapMap2 membership\">";
    vcfHeader.headerRecords[12].key = "FILTER";
    vcfHeader.headerRecords[12].value = "<ID=q10,Description=\"Quality below 10\">";
    vcfHeader.headerRecords[13].key = "FILTER";
    vcfHeader.headerRecords[13].value = "<ID=s50,Description=\"Less than 50% of samples have data\">";
    vcfHeader.headerRecords[14].key = "FORMAT";
    vcfHeader.headerRecords[14].value = "<ID=GT,Number=1,Type=String,Description=\"Genotype\">";
    vcfHeader.headerRecords[15].key = "FORMAT";
    vcfHeader.headerRecords[15].value = "<ID=GQ,Number=1,Type=Integer,Description=\"Genotype Quality\">";
    vcfHeader.headerRecords[16].key = "FORMAT";
    vcfHeader.headerRecords[16].value = "<ID=DP,Number=1,Type=Integer,Description=\"Read Depth\">";
    vcfHeader.headerRecords[17].key = "FORMAT";
    vcfHeader.headerRecords[17].value = "<ID=HQ,Number=2,Type=Integer,Description=\"Haplotype Quality\">";

    seqan::VcfIOContext vcfIOContext(vcfHeader.sequenceNames, vcfHeader.sampleNames);
    SEQAN_ASSERT_EQ(write(outF, vcfHeader, vcfIOContext, seqan::Vcf()), 0);
    outF.close();

    seqan::CharString goldPath(SEQAN_PATH_TO_ROOT());
    append(goldPath, "/extras/tests/vcf_io/vcf_header.vcf");
    SEQAN_ASSERT(seqan::_compareTextFiles(toCString(tmpPath), toCString(goldPath)));
}

SEQAN_DEFINE_TEST(test_vcf_io_write_vcf_record)
{
    seqan::CharString tmpPath(SEQAN_TEMP_FILENAME());
    std::fstream outF(toCString(tmpPath), std::ios::out | std::ios::binary);
    SEQAN_ASSERT(outF.good());

    seqan::VcfHeader vcfHeader;
    appendValue(vcfHeader.sequenceNames, "20");
    appendValue(vcfHeader.sampleNames, "NA00001");
    appendValue(vcfHeader.sampleNames, "NA00002");
    appendValue(vcfHeader.sampleNames, "NA00003");

    resize(vcfHeader.headerRecords, 18);
    vcfHeader.headerRecords[0].key = "fileformat";
    vcfHeader.headerRecords[0].value = "VCFv4.1";
    vcfHeader.headerRecords[1].key = "fileDate";
    vcfHeader.headerRecords[1].value = "20090805";
    vcfHeader.headerRecords[2].key = "source";
    vcfHeader.headerRecords[2].value = "myImputationProgramV3.1";
    vcfHeader.headerRecords[3].key = "reference";
    vcfHeader.headerRecords[3].value = "file:///seq/references/1000GenomesPilot-NCBI36.fasta";
    vcfHeader.headerRecords[4].key = "contig";
    vcfHeader.headerRecords[4].value = "<ID=20,length=62435964,assembly=B36,md5=f126cdf8a6e0c7f379d618ff66beb2da,species=\"Homo sapiens\",taxonomy=x>";
    vcfHeader.headerRecords[5].key = "phasing";
    vcfHeader.headerRecords[5].value = "partial";
    vcfHeader.headerRecords[6].key = "INFO";
    vcfHeader.headerRecords[6].value = "<ID=NS,Number=1,Type=Integer,Description=\"Number of Samples With Data\">";
    vcfHeader.headerRecords[7].key = "INFO";
    vcfHeader.headerRecords[7].value = "<ID=DP,Number=1,Type=Integer,Description=\"Total Depth\">";
    vcfHeader.headerRecords[8].key = "INFO";
    vcfHeader.headerRecords[8].value = "<ID=AF,Number=A,Type=Float,Description=\"Allele Frequency\">";
    vcfHeader.headerRecords[9].key = "INFO";
    vcfHeader.headerRecords[9].value = "<ID=AA,Number=1,Type=String,Description=\"Ancestral Allele\">";
    vcfHeader.headerRecords[10].key = "INFO";
    vcfHeader.headerRecords[10].value = "<ID=DB,Number=0,Type=Flag,Description=\"dbSNP membership, build 129\">";
    vcfHeader.headerRecords[11].key = "INFO";
    vcfHeader.headerRecords[11].value = "<ID=H2,Number=0,Type=Flag,Description=\"HapMap2 membership\">";
    vcfHeader.headerRecords[12].key = "FILTER";
    vcfHeader.headerRecords[12].value = "<ID=q10,Description=\"Quality below 10\">";
    vcfHeader.headerRecords[13].key = "FILTER";
    vcfHeader.headerRecords[13].value = "<ID=s50,Description=\"Less than 50% of samples have data\">";
    vcfHeader.headerRecords[14].key = "FORMAT";
    vcfHeader.headerRecords[14].value = "<ID=GT,Number=1,Type=String,Description=\"Genotype\">";
    vcfHeader.headerRecords[15].key = "FORMAT";
    vcfHeader.headerRecords[15].value = "<ID=GQ,Number=1,Type=Integer,Description=\"Genotype Quality\">";
    vcfHeader.headerRecords[16].key = "FORMAT";
    vcfHeader.headerRecords[16].value = "<ID=DP,Number=1,Type=Integer,Description=\"Read Depth\">";
    vcfHeader.headerRecords[17].key = "FORMAT";
    vcfHeader.headerRecords[17].value = "<ID=HQ,Number=2,Type=Integer,Description=\"Haplotype Quality\">";

    seqan::VcfIOContext vcfIOContext(vcfHeader.sequenceNames, vcfHeader.sampleNames);

    seqan::VcfRecord vcfRecord;
    vcfRecord.rID = 0;
    vcfRecord.beginPos = 14369;
    vcfRecord.id = "rs6054257";
    vcfRecord.ref = "G";
    vcfRecord.alt = "A";
    vcfRecord.qual = 29;
    vcfRecord.filter = "PASS";
    vcfRecord.info = "NS=3;DP=14;AF=0.5;DB;H2";
    vcfRecord.format = "GT:GQ:DP:HQ";
    appendValue(vcfRecord.genotypeInfos, "0|0:48:1:51,51");
    appendValue(vcfRecord.genotypeInfos, "1|0:48:8:51,51");
    appendValue(vcfRecord.genotypeInfos, "1/1:43:5:.,.");
    SEQAN_ASSERT_EQ(writeRecord(outF, vcfRecord, vcfIOContext, seqan::Vcf()), 0);
    outF.close();

    seqan::CharString goldPath(SEQAN_PATH_TO_ROOT());
    append(goldPath, "/extras/tests/vcf_io/vcf_record.vcf");
    SEQAN_ASSERT(seqan::_compareTextFiles(toCString(tmpPath), toCString(goldPath)));
}

SEQAN_DEFINE_TEST(test_vcf_io_vcf_stream_write_record)
{
    seqan::CharString tmpPath(SEQAN_TEMP_FILENAME());
    seqan::VcfStream vcfStream(toCString(tmpPath), seqan::VcfStream::WRITE);
    SEQAN_ASSERT(isGood(vcfStream));

    // Build header.
    appendValue(vcfStream.header.sequenceNames, "20");
    appendValue(vcfStream.header.sampleNames, "NA00001");
    appendValue(vcfStream.header.sampleNames, "NA00002");
    appendValue(vcfStream.header.sampleNames, "NA00003");

    resize(vcfStream.header.headerRecords, 18);
    vcfStream.header.headerRecords[0].key = "fileformat";
    vcfStream.header.headerRecords[0].value = "VCFv4.1";
    vcfStream.header.headerRecords[1].key = "fileDate";
    vcfStream.header.headerRecords[1].value = "20090805";
    vcfStream.header.headerRecords[2].key = "source";
    vcfStream.header.headerRecords[2].value = "myImputationProgramV3.1";
    vcfStream.header.headerRecords[3].key = "reference";
    vcfStream.header.headerRecords[3].value = "file:///seq/references/1000GenomesPilot-NCBI36.fasta";
    vcfStream.header.headerRecords[4].key = "contig";
    vcfStream.header.headerRecords[4].value = "<ID=20,length=62435964,assembly=B36,md5=f126cdf8a6e0c7f379d618ff66beb2da,species=\"Homo sapiens\",taxonomy=x>";
    vcfStream.header.headerRecords[5].key = "phasing";
    vcfStream.header.headerRecords[5].value = "partial";
    vcfStream.header.headerRecords[6].key = "INFO";
    vcfStream.header.headerRecords[6].value = "<ID=NS,Number=1,Type=Integer,Description=\"Number of Samples With Data\">";
    vcfStream.header.headerRecords[7].key = "INFO";
    vcfStream.header.headerRecords[7].value = "<ID=DP,Number=1,Type=Integer,Description=\"Total Depth\">";
    vcfStream.header.headerRecords[8].key = "INFO";
    vcfStream.header.headerRecords[8].value = "<ID=AF,Number=A,Type=Float,Description=\"Allele Frequency\">";
    vcfStream.header.headerRecords[9].key = "INFO";
    vcfStream.header.headerRecords[9].value = "<ID=AA,Number=1,Type=String,Description=\"Ancestral Allele\">";
    vcfStream.header.headerRecords[10].key = "INFO";
    vcfStream.header.headerRecords[10].value = "<ID=DB,Number=0,Type=Flag,Description=\"dbSNP membership, build 129\">";
    vcfStream.header.headerRecords[11].key = "INFO";
    vcfStream.header.headerRecords[11].value = "<ID=H2,Number=0,Type=Flag,Description=\"HapMap2 membership\">";
    vcfStream.header.headerRecords[12].key = "FILTER";
    vcfStream.header.headerRecords[12].value = "<ID=q10,Description=\"Quality below 10\">";
    vcfStream.header.headerRecords[13].key = "FILTER";
    vcfStream.header.headerRecords[13].value = "<ID=s50,Description=\"Less than 50% of samples have data\">";
    vcfStream.header.headerRecords[14].key = "FORMAT";
    vcfStream.header.headerRecords[14].value = "<ID=GT,Number=1,Type=String,Description=\"Genotype\">";
    vcfStream.header.headerRecords[15].key = "FORMAT";
    vcfStream.header.headerRecords[15].value = "<ID=GQ,Number=1,Type=Integer,Description=\"Genotype Quality\">";
    vcfStream.header.headerRecords[16].key = "FORMAT";
    vcfStream.header.headerRecords[16].value = "<ID=DP,Number=1,Type=Integer,Description=\"Read Depth\">";
    vcfStream.header.headerRecords[17].key = "FORMAT";
    vcfStream.header.headerRecords[17].value = "<ID=HQ,Number=2,Type=Integer,Description=\"Haplotype Quality\">";

    // Write first record.
    {
        seqan::VcfRecord vcfRecord;
        vcfRecord.rID = 0;
        vcfRecord.beginPos = 14369;
        vcfRecord.id = "rs6054257";
        vcfRecord.ref = "G";
        vcfRecord.alt = "A";
        vcfRecord.qual = 29;
        vcfRecord.filter = "PASS";
        vcfRecord.info = "NS=3;DP=14;AF=0.5;DB;H2";
        vcfRecord.format = "GT:GQ:DP:HQ";
        appendValue(vcfRecord.genotypeInfos, "0|0:48:1:51,51");
        appendValue(vcfRecord.genotypeInfos, "1|0:48:8:51,51");
        appendValue(vcfRecord.genotypeInfos, "1/1:43:5:.,.");
        SEQAN_ASSERT_EQ(writeRecord(vcfStream, vcfRecord), 0);
    }

    // Write second record.
    {
        seqan::VcfRecord vcfRecord;
        vcfRecord.rID = 0;
        vcfRecord.beginPos = 17329;
        vcfRecord.id = ".";
        vcfRecord.ref = "T";
        vcfRecord.alt = "A";
        vcfRecord.qual = 3;
        vcfRecord.filter = "q10";
        vcfRecord.info = "NS=3;DP=11;AF=0.017";
        vcfRecord.format = "GT:GQ:DP:HQ";
        appendValue(vcfRecord.genotypeInfos, "0|0:49:3:58,50");
        appendValue(vcfRecord.genotypeInfos, "0|1:3:5:65,3");
        appendValue(vcfRecord.genotypeInfos, "0/0:41:3");
        SEQAN_ASSERT_EQ(writeRecord(vcfStream, vcfRecord), 0);
    }

    // Write third record.
    {
        seqan::VcfRecord vcfRecord;
        vcfRecord.rID = 0;
        vcfRecord.beginPos = 1110695;
        vcfRecord.id = "rs6040355";
        vcfRecord.ref = "A";
        vcfRecord.alt = "G,T";
        vcfRecord.qual = 67;
        vcfRecord.filter = "PASS";
        vcfRecord.info = "NS=2;DP=10;AF=0.333,0.667;AA=T;DB";
        vcfRecord.format = "GT:GQ:DP:HQ";
        appendValue(vcfRecord.genotypeInfos, "1|2:21:6:23,27");
        appendValue(vcfRecord.genotypeInfos, "2|1:2:0:18,2");
        appendValue(vcfRecord.genotypeInfos, "2/2:35:4");
        SEQAN_ASSERT_EQ(writeRecord(vcfStream, vcfRecord), 0);
    }

    close(vcfStream);

    seqan::CharString goldPath(SEQAN_PATH_TO_ROOT());
    append(goldPath, "/extras/tests/vcf_io/example.vcf");
    SEQAN_ASSERT(seqan::_compareTextFiles(toCString(tmpPath), toCString(goldPath)));
}

#endif  // SEQAN_EXTRAS_TESTS_VCF_TEST_VCF_IO_H_


text:
package com.easemob.chatuidemo.activity;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.easemob.EMError;
import com.easemob.chat.EMGroup;
import com.easemob.chat.EMGroupManager;
import com.easemob.exceptions.EaseMobException;
import com.easemob.qixin.R;

public class PublicGroupsSeachActivity extends BaseActivity{
    private RelativeLayout containerLayout;
    private EditText idET;
    private TextView nameText;
    public static EMGroup searchedGroup;

    @Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        setContentView(R.layout.activity_public_groups_search);

        containerLayout = (RelativeLayout) findViewById(R.id.rl_searched_group);
        idET = (EditText) findViewById(R.id.et_search_id);
        nameText = (TextView) findViewById(R.id.name);

        searchedGroup = null;
    }

    /**
     * 搜索
     * @param v
     */
    public void searchGroup(View v){
        if(TextUtils.isEmpty(idET.getText())){
            return;
        }

        final ProgressDialog pd = new ProgressDialog(this);
        pd.setMessage(getResources().getString(R.string.searching));
        pd.setCancelable(false);
        pd.show();

        new Thread(new Runnable() {

            public void run() {
                try {
                    searchedGroup = EMGroupManager.getInstance().getGroupFromServer(idET.getText().toString());
                    runOnUiThread(new Runnable() {
                        public void run() {
                            pd.dismiss();
                            containerLayout.setVisibility(View.VISIBLE);
                            nameText.setText(searchedGroup.getGroupName());
                        }
                    });

                } catch (final EaseMobException e) {
                    e.printStackTrace();
                    runOnUiThread(new Runnable() {
                        public void run() {
                            pd.dismiss();
                            searchedGroup = null;
                            containerLayout.setVisibility(View.GONE);
                            if(e.getErrorCode() == EMError.GROUP_NOT_EXIST){
                                Toast.makeText(getApplicationContext(), getResources().getString(R.string.group_not_existed), 0).show();
                            }else{
                                Toast.makeText(getApplicationContext(), getResources().getString(R.string.group_search_failed) + " : " + getString(R.string.connect_failuer_toast), 0).show();
                            }
                        }
                    });
                }
            }
        }).start();

    }

    /**
     * 点击搜索到的群组进入群组信息页面
     * @param view
     */
    public void enterToDetails(View view){
        startActivity(new Intent(this, GroupSimpleDetailActivity.class));
    }
}

redpajama_set_name: RedPajamaGithub


text:
package jacobi.core.decomp.svd;

import jacobi.api.Matrices;
import jacobi.api.Matrix;
import jacobi.test.annotations.JacobiEquals;
import jacobi.test.annotations.JacobiImport;
import jacobi.test.annotations.JacobiInject;
import jacobi.test.annotations.JacobiResult;
import jacobi.test.util.Jacobi;
import jacobi.test.util.JacobiJUnit4ClassRunner;
import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
 *
 * @author Y.K. Chan
 */
@JacobiImport("/jacobi/test/data/GolubKahanSVDTest.xlsx")
@RunWith(JacobiJUnit4ClassRunner.class)
public class GolubKahanSVDTest {

    @JacobiInject(0)
    public Matrix input;

    @JacobiResult(10)
    public Matrix uMat;

    @JacobiResult(11)
    public Matrix vMat;

    @JacobiInject(-1)
    public Map<Integer, Matrix> steps;

    @JacobiResult(100)
    public Matrix result;

    @Test
    @JacobiImport("Wilkinson 5x5")
    @JacobiEquals(expected = 100, actual = 100)
    public void testWilkinson5x5() {
        double shift = new GolubKahanSVD().wilkinson(this.input.getRow(0), this.input.getRow(1), 0, 5);
        this.result = Matrices.scalar(shift);
    }

    @Test
    @JacobiImport("Wilkinson 2x2 in 4x4")
    @JacobiEquals(expected = 100, actual = 100)
    public void testWilkinson2x2In4x4() {
        double shift = new GolubKahanSVD().wilkinson(this.input.getRow(0), this.input.getRow(1), 2, 4);
        this.result = Matrices.scalar(shift);
    }

    @Test
    @JacobiImport("Wilkinson 2x2 in 4x4 (2)")
    @JacobiEquals(expected = 100, actual = 100)
    public void testWilkinson2x2In4x4Two() {
        double shift = new GolubKahanSVD().wilkinson(this.input.getRow(0), this.input.getRow(1), 0, 2);
        this.result = Matrices.scalar(shift);
    }

    @Test
    @JacobiImport("5x5")
    public void test5x5() {
        this.mock().compute(this.input.getRow(0), this.input.getRow(1), 0, 5, null, null);
        this.result = this.input;
    }

    @Test
    @JacobiImport("5x5(2)")
    public void test5x5Two() {
        this.mock().compute(this.input.getRow(0), this.input.getRow(1), 0, 5, null, null);
        this.result = this.input;
    }

    @Test
    @JacobiImport("5x5(3)")
    public void test5x5Three() {
        this.mock().compute(this.input.getRow(0), this.input.getRow(1), 0, 5, null, null);
        this.result = this.input;
    }

    @Test
    @JacobiImport("5x5(4)")
    public void test5x5Four() {
        this.mock().compute(this.input.getRow(0), this.input.getRow(1), 0, 5, null, null);
        this.result = this.input;
    }

    @Test
    @JacobiImport("Full 5x5")
    @JacobiEquals(expected = 10, actual = 10)
    @JacobiEquals(expected = 11, actual = 11)
    public void testFull5x5() {
        this.uMat = Matrices.identity(5);
        this.vMat = Matrices.identity(5);
        this.mock().compute(this.input.getRow(0), this.input.getRow(1), 0, 5, uMat, vMat);
        this.result = this.input;
    }

    @Test
    @JacobiImport("3x3 In 6x6")
    public void test3x3In6x6() {
        this.mock().compute(this.input.getRow(0), this.input.getRow(1), 1, 4, null, null);
        this.result = this.input;
    }

    @Test
    @JacobiImport("3x3 In 6x6 (2)")
    public void test3x3In6x6Two() {
        this.mock().compute(this.input.getRow(0), this.input.getRow(1), 1, 4, null, null);
        this.result = this.input;
    }

    @Test
    @JacobiImport("Full 4x4 In 6x6")
    @JacobiEquals(expected = 10, actual = 10)
    @JacobiEquals(expected = 11, actual = 11)
    public void testFull4x4In6x6() {
        this.uMat = Matrices.identity(6);
        this.vMat = Matrices.identity(6);
        this.mock().compute(this.input.getRow(0), this.input.getRow(1), 1, 5, uMat, vMat);
        this.result = this.input;
    }

    private GolubKahanSVD mock() {
        AtomicInteger count = new AtomicInteger(0);
        return new GolubKahanSVD() {

            @Override
            protected GolubKahanSVD.Step createBulge(double[] diag, double[] supDiag, int at, double shift) {
                Step step = super.createBulge(diag, supDiag, at, shift);
                double[] padded = Arrays.copyOf(supDiag, supDiag.length);
                padded[padded.length - 1] = step.bulge;
                Jacobi.assertEquals(steps.get(count.incrementAndGet()), Matrices.of(new double[][]{diag, padded}));
                return step;
            }

            @Override
            protected GolubKahanSVD.Step pushDown(double[] diag, double[] supDiag, int at, double bulge) {
                Step step = super.pushDown(diag, supDiag, at, bulge);
                double[] padded = Arrays.copyOf(supDiag, supDiag.length);
                padded[padded.length - 1] = step.bulge;
                Jacobi.assertEquals(steps.get(count.incrementAndGet()), Matrices.of(new double[][]{diag, padded}));
                return step;
            }

        };
    }
}


text:
package org.videolan.vlc.gui.video;

import java.util.Comparator;
import java.util.HashMap;
import java.util.Locale;

import org.videolan.libvlc.Media;
import org.videolan.vlc.MediaGroup;
import org.videolan.vlc.R;
import org.videolan.vlc.util.BitmapCache;
import org.videolan.vlc.util.BitmapUtil;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.Util;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

public class VideoListAdapter extends ArrayAdapter<Media>
                                 implements Comparator<Media> {

    public final static int SORT_BY_TITLE = 0;
    public final static int SORT_BY_LENGTH = 1;
    private int mSortDirection = 1;
    private int mSortBy = SORT_BY_TITLE;
    private boolean mListMode = false;
    private Context mContext;
    private VideoGridFragment mFragment;

    public VideoListAdapter(Context context, VideoGridFragment fragment) {
        super(context, 0);
        mContext = context;
        mFragment = fragment;
    }

    public final static String TAG = "VLC/MediaLibraryAdapter";

    public synchronized void update(Media item) {
        int position = getPosition(item);
        if (position != -1) {
            remove(item);
            insert(item, position);
        }
    }

    public void setTimes(HashMap<String, Long> times) {
        // update times
        for (int i = 0; i < getCount(); ++i) {
            Media media = getItem(i);
            Long time = times.get(media.getLocation());
            if (time != null)
                media.setTime(time);
        }
    }

    public void sortBy(int sortby) {
        switch (sortby) {
            case SORT_BY_TITLE:
                if (mSortBy == SORT_BY_TITLE)
                    mSortDirection *= -1;
                else {
                    mSortBy = SORT_BY_TITLE;
                    mSortDirection = 1;
                }
                break;
            case SORT_BY_LENGTH:
                if (mSortBy == SORT_BY_LENGTH)
                    mSortDirection *= -1;
                else {
                    mSortBy = SORT_BY_LENGTH;
                    mSortDirection *= 1;
                }
                break;
            default:
                mSortBy = SORT_BY_TITLE;
                mSortDirection = 1;
                break;
        }
        sort();
    }

    public void sort() {
        super.sort(this);
    }

    @Override
    public int compare(Media item1, Media item2) {
        int compare = 0;
        switch (mSortBy) {
            case SORT_BY_TITLE:
                compare = item1.getTitle().toUpperCase(Locale.ENGLISH).compareTo(
                        item2.getTitle().toUpperCase(Locale.ENGLISH));
                break;
            case SORT_BY_LENGTH:
                compare = ((Long) item1.getLength()).compareTo(item2.getLength());
                break;
        }
        return mSortDirection * compare;
    }

    /**
     * Display the view of a file browser item.
     */
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        View v = convertView;

        if (v == null || (((ViewHolder)v.getTag()).listmode != mListMode)) {
            LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

            if (!mListMode)
                v = inflater.inflate(R.layout.video_grid_item, parent, false);
            else
                v = inflater.inflate(R.layout.video_list_item, parent, false);

            holder = new ViewHolder();
            holder.layout = v.findViewById(R.id.layout_item);
            holder.thumbnail = (ImageView) v.findViewById(R.id.ml_item_thumbnail);
            holder.title = (TextView) v.findViewById(R.id.ml_item_title);
            holder.subtitle = (TextView) v.findViewById(R.id.ml_item_subtitle);
            holder.progress = (ProgressBar) v.findViewById(R.id.ml_item_progress);
            holder.more = (ImageView) v.findViewById(R.id.item_more);
            holder.listmode = mListMode;
            v.setTag(holder);

            holder.more.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mFragment != null)
                    mFragment.onContextPopupMenu(v, position);
                }
            });

            /* Set the layoutParams based on the values set in the video_grid_item.xml root element */
            v.setLayoutParams(new GridView.LayoutParams(v.getLayoutParams().width, v.getLayoutParams().height));
        } else {
            holder = (ViewHolder) v.getTag();
        }

        Media media = getItem(position);

        /* Thumbnail */
        Bitmap thumbnail = BitmapUtil.getPictureFromCache(media);
        if (thumbnail == null) {
            // missing thumbnail
            thumbnail = BitmapCache.GetFromResource(v, R.drawable.icon_g);
        }
        else if (thumbnail.getWidth() == 1 && thumbnail.getHeight() == 1) {
            // dummy thumbnail
            thumbnail = BitmapCache.GetFromResource(v, R.drawable.icon);
        }
        //FIXME Warning: the thumbnails are upscaled in the grid view!
        holder.thumbnail.setImageBitmap(thumbnail);

        /* Color state */
        ColorStateList titleColor = v.getResources().getColorStateList(
                Util.getResourceFromAttribute(mContext, R.attr.list_title));
        holder.title.setTextColor(titleColor);

        if (media instanceof MediaGroup)
            fillGroupView(holder, media);
        else
            fillVideoView(holder, media);

        return v;
    }

    private void fillGroupView(ViewHolder holder, Media media) {
        MediaGroup mediaGroup = (MediaGroup) media;
        int size = mediaGroup.size();
        String text = getContext().getResources().getQuantityString(R.plurals.videos_quantity, size, size);

        holder.subtitle.setText(text);
        holder.title.setText(media.getTitle() + "\u2026"); // ellipsis
        holder.more.setVisibility(View.INVISIBLE);
        holder.progress.setVisibility(View.GONE);
    }

    private void fillVideoView(ViewHolder holder, Media media) {
        /* Time / Duration */
        long lastTime = media.getTime();
        String text;
        if (lastTime > 0) {
            text = String.format("%s / %s",
                    Strings.millisToText(lastTime),
                    Strings.millisToText(media.getLength()));
            holder.progress.setVisibility(View.VISIBLE);
            holder.progress.setMax((int) (media.getLength() / 1000));
            holder.progress.setProgress((int) (lastTime / 1000));
        } else {
            text = Strings.millisToText(media.getLength());
            holder.progress.setVisibility(View.GONE);
        }

        if (media.getWidth() > 0 && media.getHeight() > 0) {
            text += String.format(" - %dx%d", media.getWidth(), media.getHeight());
        }

        holder.subtitle.setText(text);
        holder.title.setText(media.getTitle());
        holder.more.setVisibility(View.VISIBLE);
    }

    static class ViewHolder {
        boolean listmode;
        View layout;
        ImageView thumbnail;
        TextView title;
        TextView subtitle;
        ImageView more;
        ProgressBar progress;
    }

    public void setListMode(boolean value) {
        mListMode = value;
    }

    public boolean isListMode() {
        return mListMode;
    }
}


text:
package bank;

import agent.Agent;
import bank.NumberAnnouncer.numberState;
import interfaces.AnnouncerB;
import interfaces.BankClient;
import interfaces.BankTeller;
import interfaces.LoanTeller;

import java.util.*;
/**
 *
 * @author Byron Choy
 *
 */

public class LoanNumberAnnouncer extends Agent implements AnnouncerB{
	List<BankClient> clients = new ArrayList<BankClient>();
	LoanTeller loanTeller;
	private int loanNumber = 0;
	public enum numberState{pending, announceL};
	public numberState state = numberState.pending;
	private String name;
	private boolean onTheWay = false;

	public void setLoanTeller(LoanTellerRole lt){
		loanTeller = lt;
	}

	public LoanNumberAnnouncer(String n){
		super();
		name = n;
	}

	//Messages

	public void msgOnTheWay(){
		onTheWay = true;
		stateChanged();
	}
	public void msgAddLoanTeller(LoanTeller l){
		loanTeller = l;
		stateChanged();
	}
	public void msgAddClient(BankClient c){
		Do(c + " added.");
		clients.add(c);
		stateChanged();
	}
	public void msgLoanComplete(){
		Do("Recieved done message from loan line.");
		loanNumber++;
		onTheWay = false;
		state = numberState.announceL;
		stateChanged();
	}

	public void msgRemoveClient(BankClient b){
		clients.remove(b);
		stateChanged();
	}

	public void msgGoodbye(){
		loanTeller = null;
		stateChanged();
	}

	//scheduler
	protected boolean pickAndExecuteAnAction() {
		if (loanTeller == null){
			Reset();
		}
		if (loanTeller != null && state == numberState.announceL && !(clients.isEmpty())){
			announceNumberLoan();
			return true;
		}
		return false;
	}
	//actions
	private void announceNumberLoan(){
		while (onTheWay == false){
			try {
				Thread.sleep(10000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			Do("Calling loan ticket " + loanNumber);
			for (BankClient b : clients){
				b.msgCallingLoanTicket(loanNumber, 5, loanTeller);
			}
		}
		state = numberState.pending;
	}
	private void Reset(){
		state = numberState.pending;
		loanNumber = 0;
	}

	public String getName() {
		return name;
	}
	public String toString() {
		return "Bank Teller  " + getName();
	}

	public int getNumClients(){
		return clients.size();
	}

}


text:
- Feature Name: Time Series Culling
- Status: in progress
- Start Date: 2016-08-29
- Authors: Matt Tracy
- RFC PR: #9343
- Cockroach Issue: #5910

# Summary
Currently, Time Series data recorded by CockroachDB for its own internal
metrics is retained indefinitely. High-resolution metrics data quickly loses
utility as it ages, consuming disk space and creating range-related overhead
without conferring an appropriate benefit.

The simplest solution to deal with this would be to build a system that deletes
time series data older than a certain threshold; however, this RFC suggests a
mechanism for "rolling up" old time series from the system into a lower
resolution that is still retained. This will allow us to keep some metrics
information indefinitely, which can be used for historical performance
evaluation, without needing to keep an unacceptably expensive amount of
information.

Fully realizing this solution has three components:

1. A distributed "culling" algorithm that occasionally searches for
high-resolution time series data older than a certain threshold and runs a
"roll-up" process on the discovered keys.
2. A "roll-up" process that computes low-resolution time series data from the
existing data in a high-resolution time series key, deleting the high-resolution
key in the process.
3. Modifications to the query system to utilize underlying data which is stored
at multiple resolutions (currently only supports a single resolution). This
includes the use of data at different resolutions to serve a single query.

# Motivation

In our test clusters, time series create a very large amount of data (on the
order of several gigabytes per week) which quickly loses utility as it ages.

To estimate how much data this is, we first observe the data usage of a single
time series. A single time series stores data as contiguous samples representing
ten-second intervals; all samples for a wall-clock hour are stored in a single
key. In the engine, the keys look like this:

| Key                                                      | Key Size | Value Size |
|----------------------------------------------------------|----------|------------|
| /System/tsd/cr.store.replicas/1/10s/2016-09-26T17:00:00Z | 30       | 5670       |
| /System/tsd/cr.store.replicas/1/10s/2016-09-26T18:00:00Z | 30       | 5535       |
| /System/tsd/cr.store.replicas/1/10s/2016-09-26T19:00:00Z | 30       | 5046       |

The above is the data stored for one time series over three complete hours.
Notice the variation in the size of the values; this is due to the fact that
samples may be absent for some ten-second periods, due to the asynchronous
nature of this system. For our purposes, we will estimate the size of a single
hour of data for a single time series to be *5500* bytes, or 5.5K.

The total disk usage of high-resolution data on the cluster can thus be
estimated with the following function:

` Total bytes = [bytes per time series hour] * [# of time series per node] * [# of nodes] * [# of hours] `

Thus, data accumulates over time, and as more nodes are added (or if later
versions of cockroach add additional time series), the rate of new time series
data being accumulated increases linearly. As of this writing, each single-node store records
**242** time series. Thus, the bytes needed per hour on a ten-node cluster is:

`Total Bytes (hour) = 5500 * 242 * 10 = 13310000 (12.69 MiB)`

After just one week:

`Total Bytes (week) = 12.69MiB * 168 hours = 2.08 GiB`

As time passes, this data can represent a large share (or in the case of idle
clusters, the majority) of in-use data on the cluster. This data will also
continue to build indefinitely; a static CockroachDB Cluster will eventually
consume all available disk space, even if no external data is written! With just
the current time series, a ten-node cluster will generate almost a terabyte of
metrics data over a single year.

The prompt culling of old data is thus a clear area of improvement for
CockroachDB. However, rather than simply deleting data older than a threshold,
this RFC proposes a solution which efficiently keeps metrics data for a longer
time span by downsampling it to a much lower resolution on disk.

To give some context of numbers: currently, all metrics on disk are stored in a
format which is downsampled to _ten second sample periods_; this is the
"high-resolution" data. We are looking to delete this data when it is older
than a certain threshold, which will likely be set in the range of _2-4 weeks_.
We also propose that, when this data is deleted, it is first downsampled further
into _one hour sample periods_; this is the "low-resolution" data. This data
will be kept for a much longer time, likely _6-12 months_, but perhaps longer.

In the lower resolution, each datapoint represents the same data as an _entire
slab_ of high-resolution data (at the ten second resolution, data is stored in
slabs corresponding to a wall-clock hour; each slab contains up to 360 samples).
Thus, the expected data storage of the low-resolution is approximately _180x
smaller_ than the high-resolution (not 360 because the individual low-resolution
samples will include a "min" and "max" value not present at the high-resolution.
The high-resolution keys only contain a "sum" and "count" field.)

By keeping data at the low resolution, users will still be able to inspect
cluster performance over larger times scales, without requiring the storage of
an excessive amount of metrics data.

# Detailed design

## Culling algorithm

The culling algorithm is responsible for identifying high-resolution time series
keys that are older than a system-set threshold. Once identified, the keys are
passed into the rollup/delete process.

There are two primary design requirements of the culling algorithm:

1. From a single node, efficiently locating time series keys which need to be
culled.
2. Across the cluster, efficiently distributing the task of culling with minimal
coordination between nodes.

#### Locating Time Series Keys

Locating time series keys to be culled is not completely trivial due to the
construction of time series keys, which is thus:
`[ts prefix][series name][timestamp][source]`

> Example: "ts/cr.node.sql.inserts/1473739200/1" would contain time series data
> for "cr.node.sql.inserts" on September 13th 2016 between 4am-5am UTC,
> specifically for node 1.

Because of this construction, which prioritizes name over timestamp, the most
recent time series data for series "A" would sort *before* the oldest time
series data for series "B". This means that we cannot simply cull the beginning
of the time series range.

The simplest alternative would be to scan the time series range looking for
invalid keys; however, this is considered to be a burdensome scan due to the
number of keys that are not culled. For a per-node time series being recorded on
a 10 node cluster with a 2 week retention period, we would expect to retain (10
x 24 x 14) = *3360* keys that should not be culled. In a system that maintains
dozens, possibly hundreds of time series, this is a lot of data for each node to
scan on a regular basis.

However, this scan can be effectively distributed across the cluster by creating
a new *replica queue* which searches for time series keys. The new queue can
quickly determine if each range contains time series keys (by inspecting
start/end keys); for ranges that do contain time series keys, specific keys
can then be inspected at the engine level. This means that key inspections do
not require network calls, and the number of keys that can be inspected at once
is limited to the size of a range.

Once the queue discovers a range that contains time series keys, the scanning
process does not need to inspect every key on the range. The algorithm is as
follows:

1. Find the first time series key in the range (scan for [ts prefix]).
2. Deconstruct the key to retrieve its name.
3. Run the rollup/delete operation on all keys in the range:
    `[ts prefix][series name][0] - [tsprefix][series name][now - threshold]`
4. Find the next key on the range which contains data for a different time
series by searching for key `PrefixEnd([ts prefix][series name])`.
5. If a key was found in step 5, return to step 2 with that series name.

This algorithm will avoid scanning keys that do not need to be rolled up; this
is desirable, as once the culling algorithm is in place and has run once, the
majority of time series keys will *not* need to be culled.

The queue will be configured to run only on the range leader for a given range
in order to avoid duplicate work; however, this is *not* necessary for
correctness, as demonstrated in the [Rollup Algorithm](#rollup-algorithm)
section below.

The queue will initially be set to process replicas at the same rate as the
replica GC queue (as of this RFC, one range per 50 milliseconds).

##### Package Dependency

There is one particular complication to this method: *go package dependency*.
Knowledge on how to identify and cull time series keys is contained in the `ts`
package, but all logic for replica queues (and all current queues) lives in
`storage`, meaning that one of three things must happen:

+ `storage` can depend on `ts`. This seems to be trivially possible now, but may
be unintuitive to those trying to understand our code-base. For reference, the
`storage` package used to depend on the `sql` package in order to record event
logs, but this eventually became an impediment to new development and had to be
modified.
+ The queue logic could be implemented in `ts`, and `storage` could implement
an interface that allows it to use the `ts` code without a dependency.
+ Parts of the `ts` package could be split off into another package that can
intuitively live below `storage`. However, this is likely to be a considerable
portion of `ts` in order to properly implement rollups.

Tenatively, we will be attempting to use the first method and have `storage`
depend on `ts`; if it is indeed trivially possible, this will be the fastest
method of completing this project.

#### Culling low resolution data

Although the volume is much lower, low-resolution data will still build
up indefinitely unless it is culled. This data will also be culled by the same
algorithm outlined here; however, it will not be rolled up further, but will
simply be deleted.

## Rollup algorithm

The rollup algorithm is intended to be run on a single high-resolution key
identified by the culling algorithm. The algorithm is as follows:

1. Read the data in the key. Each key represents a "slab" of high resolution
samples captured over a wall-clock hour (up to 360 samples per hour).
2. "Downsample" all of the data in the key into a single sample; the new sample
will have a sum, count, min and max, computed from the samples in the original
key.
3. Write the computed sample as a low-resolution data point into the time series
system; this is exactly the same process as currently recorded time series,
except it will be writing to a different key space (with a different key
prefix).
4. Delete the original high-resolution key.

This algorithm is safe to use, even in the case where the same key is being
culled by multiple nodes at the same time; this is because step 3 and 4 are
currently *idempotent*. The low-resolution sample generated by each node will be
identical, and the engine-level time series merging system currently discards
duplicate samples. The deletion of the high-resolution key may cause an error on
some of the nodes, but only because the key will have already been deleted.

The end result is that the culled high-resolution key is gone, but a single
sample (representing the entire hour) has been written into a low-resolution
time series with the same name and source.

## Querying Across Culling Boundary

The final component of this is to allow querying across the culling boundary;
that is, if an incoming time series query wants data from both sides of the
culling boundary, it will have to process data from two different resolutions.

There are no broad design decisions to make here; this is simply a matter
of modifying low-level iterators and querying slightly different data. This
component will likely be the most complicated to actually *write*, but it should
be somewhat easier to *test* than the above algorithms, as there is already
an existing test infrastructure for time series queries.

## Implementation

This system can (and should) be implemented in three distinct phases:

1. The "culling" algorithm will be implemented, but will not roll-up the data in
discovered keys; instead, it will simply *delete* the discovered time series by
issuing a DeleteRange command. This will provide the immediate benefit of
limiting the growth of time series data on the cluster.

2. The "rollup" algorithm will be implemented, generating low-resolution data
before deleting the high-resolution data. However, the low-resolution data will
not immediately be accessible for queries.

3. The query system will be modified to consider the high-resolution data.

# Drawbacks

+ Culling represents another periodic process which runs on each node, which can
occasionally cause unexpected issues.

+ Depending on the exact layout of time series data across ranges, it is
possible that deleting time series could result in empty ranges. Specifically,
this can occur if a range contains data only for a single time series *and* the
subsequent range also contains data for that same time series. If this is a
common occurrence, it could result in a "trail" of ranges with no data, which
might add overhead into storage algorithms that scale with the number of ranges.

# Alternatives

### Alternative Location algorithm

As an alternative to the queue-based location algorithm, we could use a system
where each node maintains a list of time series it has written; given the name
of a series, it is easy to construct a scan range which will return all keys
that need to be culled:

`[ts prefix][series name][0] - [ts prefix][series name][(now - threshold)]`

This will return all keys in the series which are older than the threshold. Note
that this includes time series keys generated by any node, not just the current
node; this is acceptable, as the rollup algorithm can be run on any key from
any node.

This process can also be effectively distributed across nodes with the following
algorithm:

+ Each node's time series module maintains a list of time series it is
responsible for culling. This is initialized to a list of "retired" time series,
and is augmented each time the node writes a time series it has not written
before (in the currently running instance).
+ The time series module maintains a random permutation of the list; this
permutation is randomized again each time a new time series is added. This
should normalize very quickly, as new time series are not currently added while
a node is running.
+ Each node will periodically attempt to cull data for a single time series;
this starts with the first name in the current permutation, and proceeds through
it in a loop.

In this way, each node eventually attempts to cull all time series (guaranteeing
that each is culled), but the individual nodes proceed through the series in a
random order - this helps to distribute the work across nodes, and helps to
avoid the chance of duplicate work. The total speed of work can be tuned by
adjusting the frequency of the per-node culling process.

This alternative was rejected due to a complication that occurs when a time
series is "retired"; we only know about a time series name if the currently
running process has recorded it. If a time series is removed from the system,
its data will never be culled. Thus, we must also maintain a list of *retired*
time series names in the event that any are removed. This requires some manual
effort on the part of developers; the consequences for failing to do so are not
especially severe (a limited amount of old data will persist on the cluster),
but this is still considered inferior to the queue-based solution.

### Immediate Rollups

This was the original intention of the time series system: when a
high-resolution data sample is recorded, it is actually directly merged into
both the high-resolution AND the low-resolution time series. The engine-level
time series merging system would then be responsible for properly aggregating
multiple high-resolution samples into a single composite sample in the
low-resolution series.

The advantage of this method is that it does not require queries to use multiple
resolutions, and it allows for the delete-only culling process to be used. This
was also the original design of the time series system.

Unfortunately, it is not currently possible due to recent changes which were
required by the replica consistency checker. The engine-level merge component no
longer aggregates samples, it decimates (discarding only the most recent sample
for a period). This was necessary to deal with the unforunate reality of raft
command replays.

### Opportunistic Rollups

Instead of rolling up when low-resolution data is deleted, it is instead rolled
up as soon as an entire hour of high-resolution samples has been collected in a
key. That is, at 5:01 it should be appropriate to roll-up the data stored in the
4:00 key. With this alternative, cross-resolution queries can also be avoided
and the delete-only culling method can be used.

However, this introduces additional complications and drawbacks:

+ When querying at low resolution, data from the most recent hour will not be
even partially available.
+ This requires maintaining additional metadata on the cluster about which
keys have already been rolled up.

# Unresolved questions


text:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Reporte_ingreso extends CI_Controller {

  public function __construct() {
    parent::__construct();

   if($this->session->userdata('logged_in') == FALSE){
     redirect('login/index/error_no_autenticado');
   }
    $this->load->helper(array('url', 'form', 'paginacion'));
    $this->load->library('table');
    $this->load->model(array('ActivoFijo/Reporte_Ingreso_Model'));
    $this->load->model(array('ActivoFijo/Datos_Comunes_Model'));
  }

  public function Recibirfechas(){
    $USER = $this->session->userdata('logged_in');
    if($USER){
      if ($this->input->post('fecha_inicio')!=NULL && $this->input->post('fecha_fin')!=NULL) {
        redirect('ActivoFijo/Reportes/Reporte_ingreso/Reporte/'.$this->input->post('fecha_inicio').'/'.$this->input->post('fecha_fin'));
      } else {
        redirect('ActivoFijo/Reportes/Reporte_ingreso/Reporte/');
      }
    } else {
      redirect('login');
    }
  }

  public function reporte(){
    $USER = $this->session->userdata('logged_in');
    if($USER){
      $data['title'] = "Reporte de Ingresos Adquiridos";
      $data['menu'] = $this->menu_dinamico->menus($this->session->userdata('logged_in'),$this->uri->segment(1));
      $data['js'] = 'assets/js/validate/reporte/activofijo/val_fechas.js';
      $table = '';

      if ($this->uri->segment(5) != '' && $this->uri->segment(6) != '') {
        $template = array(
        'table_open' => '
'
        );

        $this->table->set_template($template);
        $this->table->set_heading('#','Descripción','Marca','Modelo','Serie','Código', 'CódigoAnterior',
          'CuentaContable','NombreDocumentoAmpara','FechaDeAdquisición','Precio','SubCategoría',
          'Categoria','Proyecto', 'Sección', 'Empleado');

        $num = '25';
        $registros = $this->Reporte_Ingreso_Model->obtenerIngresosFiltro($this->uri->segment(5),
        $this->uri->segment(6),$num, $this->uri->segment(7));
        $total = $this->Reporte_Ingreso_Model->obtenerIngresosFiltroTotal($this->uri->segment(5),$this->uri->segment(6));
        $pagination = paginacion('index.php/ActivoFijo/Reportes/Reporte_ingreso/reporte/'.$this->uri->segment(5).
        '/'.$this->uri->segment(6),$total,$num, '7');

        if (!($registros == FALSE)) {
          $fecha_inicio=$this->uri->segment(5);
          $fecha_fin=$this->uri->segment(6);
          $i = $this->uri->segment(7) + 1;
          foreach($registros as $pro) {
            $this->table->add_row($i,$pro->descripcion,$pro->nombre_marca,$pro->modelo,$pro->serie,$pro->codigo,
            $pro->codigo_anterior,$pro->nombre_cuenta,$pro->nombre_doc_ampara,$pro->fecha_adquisicion,
            '$'.number_format($pro->precio_unitario,2),$pro->nombre_subcategoria,$pro->nombre_categoria,$pro->nombre_fuente,
            $pro->nombre_seccion,$pro->primer_nombre.' '.$pro->segundo_nombre.' '.$pro->primer_apellido.' '.$pro->segundo_apellido);
            $i++;
          }
        } else {
          $msg = array('data' => "No se encontraron resultados", 'colspan' => "16");
          $this->table->add_row($msg);
        }

       $table = "
" .
                    "
 ".$this->uri->segment(5) . " - " . $this->uri->segment(6) ."
".
                    "
" .
                      "
uri->segment(5).'/'.$this->uri->segment(6))."' class='icono icon-file-excel'>
                      Exportar Excel
                      uri->segment(5).'/'.$this->uri->segment(6))."' class='icono icon-printer' target='_blank'>Imprimir

" .
                      "
". $this->table->generate() . "
" . $pagination . "

";

      }
      $data['body'] = $this->load->view('ActivoFijo/Reportes/Reporte_de_ingreso_view', '',TRUE) . "
" . $table;
      $this->load->view('base', $data);
    } else {
      redirect('login/index/forbidden');
    }
  }

//metodo para exportar a excell
 public function ReporteExcel() {
    $this->load->library(array('excel'));
    $estilo_titulo = array(
        'font' => array(
          'name' => 'Calibri',
          'bold' => TRUE,
          'size' => 12,
        ),
        'borders' => array(
          'allborders' => array(
          'style' => PHPExcel_Style_Border::BORDER_THICK
          ),
          'color' => array('rgb' => '676767'),
        ),
        'alignment' => array(
          'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
          'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
          'rotation' => 0,
          'wrap' => TRUE,
        ),
    );

    $estilo_contenido = array(
      'font' => array(
        'name' => 'Calibri',
        'bold' => FALSE,
        'size' => 11,
      ),
      'borders' => array(
        'allborders' => array(
        'style' => PHPExcel_Style_Border::BORDER_THIN
        ),
        'color' => array('rgb' => '676767'),
      ),
      'alignment' => array(
        'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
        'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
        'rotation' => 0,
        'wrap' => TRUE,
      ),
    );

    $estilo_numero = array(
      'font' => array(
        'name' => 'Calibri',
        'bold' => FALSE,
        'size' => 11,
      ),
      'borders' => array(
        'allborders' => array(
        'style' => PHPExcel_Style_Border::BORDER_THIN
        ),
        'color' => array('rgb' => '676767'),
      ),
      'alignment' => array(
        'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
        'rotation' => 0,
        'wrap' => TRUE,
      ),
    );

    $objPHPExcel = new PHPExcel();
    $objPHPExcel->getProperties()->setCreator("SICBAF")
                 ->setLastModifiedBy("SICBAF")
                 ->setTitle("Reporte de Ingresos de Bienes Adquiridos")
                 ->setSubject("Reporte de Ingresos de Bienes Adquiridos")
                 ->setDescription("Reporte de Ingresos de Bienes Adquiridos.")
                 ->setKeywords("office PHPExcel php")
                 ->setCategory("Reporte de Ingresos de Bienes Adquiridos");
    $objPHPExcel->setActiveSheetIndex(0)
                 ->setCellValue('A1', '#')
                 ->setCellValue('B1', 'Descripción')
                 ->setCellValue('C1', 'Marca')
                 ->setCellValue('D1', 'Modelo')
                 ->setCellValue('E1', 'Serie')
                 ->setCellValue('F1', 'Código')
                 ->setCellValue('G1', 'Código Anterior')
                 ->setCellValue('H1', 'Cuenta Contable')
                 ->setCellValue('I1', 'Nombre Documento Ampara')
                 ->setCellValue('J1', 'Fecha De Adquisición')
                 ->setCellValue('K1', 'Precio')
                 ->setCellValue('L1', 'SubCategoría')
                 ->setCellValue('M1', 'Categoria')
                 ->setCellValue('N1', 'Proyecto')
                 ->setCellValue('O1', 'Sección')
                 ->setCellValue('P1', 'Empleado');
    $objPHPExcel->getActiveSheet()->getStyle('A1:P1')->applyFromArray($estilo_titulo);

    $total_registros = 0;
    if ($this->uri->segment(6) != 0) {
      $total_registros = $this->Reporte_Ingreso_Model->obtenerIngresosFiltroTotal($this->uri->segment(5),$this->uri->segment(6));
    }

    if ($total_registros > 0) {

      $registros;
      if ($this->uri->segment(6) != 0) {
        $registros = $this->Reporte_Ingreso_Model->obtenerIngresosFiltroexcel($this->uri->segment(5), $this->uri->segment(6));
      } /*else {
        // solo recibe unidad o seccion
        $registros = $this->Reporte_Ingreso_Model->obtenerIngresosFiltroTotal($this->uri->segment(5), $this->uri->segment(6));
      }*/

      $i = 2;
      while ($registro = current($registros)) {
        $objPHPExcel->setActiveSheetIndex(0)
                    ->setCellValue('A'.$i, $i-1)
                    ->setCellValue('B'.$i, $registro->descripcion)
                    ->setCellValue('C'.$i, $registro->nombre_marca)
                    ->setCellValue('D'.$i, $registro->modelo)
                    ->setCellValue('E'.$i, $registro->serie)
                    ->setCellValue('F'.$i, $registro->codigo)
                    ->setCellValue('G'.$i, $registro->codigo_anterior)
                    ->setCellValue('H'.$i, $registro->nombre_cuenta)
                    ->setCellValue('I'.$i, $registro->nombre_doc_ampara)
                    ->setCellValue('J'.$i, $registro->fecha_adquisicion)
                    ->setCellValue('K'.$i, $registro->precio_unitario)
                    ->setCellValue('L'.$i, $registro->nombre_subcategoria)
                    ->setCellValue('M'.$i, $registro->nombre_categoria)
                    ->setCellValue('N'.$i, $registro->nombre_fuente)
                    ->setCellValue('O'.$i, $registro->nombre_seccion)
                    ->setCellValue('P'.$i, $registro->primer_nombre.' '.$registro->segundo_nombre.' '.$registro->primer_apellido.' '.$registro->segundo_apellido);

        $objPHPExcel->getActiveSheet()->getStyle('A'.$i.':P'.$i)->applyFromArray($estilo_contenido);
        $objPHPExcel->getActiveSheet()->getStyle('K'.$i)->applyFromArray($estilo_numero);
        $objPHPExcel->getActiveSheet() ->getStyle('K'.$i)->getNumberFormat()->setFormatCode('$#,##0.00');

        $next = next($registros);
        $i++;
      }
    } else {
      $objPHPExcel->setActiveSheetIndex(0)->mergeCells('A2:P2');
      $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A2', "No se encontraron resultados");
      $objPHPExcel->getActiveSheet()->getStyle('A2:P2')->applyFromArray($estilo_contenido);
    }

    foreach(range('A','P') as $columnID){
      $objPHPExcel->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
    }

    $objPHPExcel->setActiveSheetIndex(0);

    header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
    header("Content-Disposition: attachment; filename='reporte_ingreso_bienes.xlsx'");
    header('Cache-Control: max-age=0');

    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
    $objWriter->save('php://output');
  }

//}

// acá termina

  public function ImprimirReporte() {
    $USER = $this->session->userdata('logged_in');
    if ($USER) {
      if ($this->uri->segment(5) != NULL && $this->uri->segment(6) != NULL) {
        $template = array(
            'table_open' => '
'
        );
        $this->table->set_template($template);
        $this->table->set_heading('#','Descripción','Marca','Modelo','Serie','Código', 'CódigoAnterior',
          'CuentaContable','NombreDocumentoAmpara','FechaDeAdquisición','Precio','SubCategoría',
          'Categoria','Proyecto', 'Sección', 'Empleado');

        $total = $this->Reporte_Ingreso_Model->obtenerIngresosFiltroTotal($this->uri->segment(5),$this->uri->segment(6));
        $registros = $this->Reporte_Ingreso_Model->obtenerIngresosFiltro($this->uri->segment(5),
            $this->uri->segment(6),$total, $this->uri->segment(7));

        if (!($registros == FALSE)) {
          $fecha_inicio=$this->uri->segment(5);
          $fecha_fin=$this->uri->segment(6);
          $i = 1;
          foreach($registros as $pro) {
            $this->table->add_row($i,$pro->descripcion,$pro->nombre_marca,$pro->modelo,$pro->serie,$pro->codigo,
            $pro->codigo_anterior,$pro->nombre_cuenta,$pro->nombre_doc_ampara,$pro->fecha_adquisicion,
            '$'.number_format($pro->precio_unitario,2),$pro->nombre_subcategoria,$pro->nombre_categoria,$pro->nombre_fuente,
            $pro->nombre_seccion,$pro->primer_nombre.' '.$pro->segundo_nombre.' '.$pro->primer_apellido.' '.$pro->segundo_apellido);
            $i++;
          }
        } else {
          $msg = array('data' => "No se encontraron resultados", 'colspan' => "16");
          $this->table->add_row($msg);
        }

        $data = array(
          'table' => $this->table->generate(),
          'title' => 'Bienes Usuario'
        );
        $this->load->view('ActivoFijo/Reportes/imprimir_reporte_view', $data);
      }
    } else {
      redirect('login');
    }
  }
}
?>


text:
<?php
namespace mxreCaptcha\Form\Element;

use mxreCaptcha\Validator;
use Zend\Form\Element;
use Zend\InputFilter\InputProviderInterface;

class ReCaptcha extends Element implements InputProviderInterface
{
    /** @var string */
    protected $siteKey;

    /**
     * @param string $siteKey
     * @return $this
     */
    public function setSiteKey($siteKey)
    {
        $this->siteKey = $siteKey;
        return $this;
    }

    /**
     * @return string
     */
    public function getSiteKey()
    {
        return $this->siteKey;
    }

    /**
     * Should return an array specification compatible with
     * {@link Zend\InputFilter\Factory::createInput()}.
     *
     * @return array
     */
    public function getInputSpecification()
    {
        return [
            'name'       => $this->getName(),
            'required'   => true,
            'validators' => [
                ['name' => Validator\ReCaptcha::class],
            ],
        ];
    }
}


text:
TEST_F(CZMQToolkitTests, CalculateHeadersEmptyMessage) {
   CZMQToolkit::GetHash(&t_data, t_header);
   uLong crc = crc32(0L, NULL, 0);
   EXPECT_EQ(crc, t_header);
}

TEST_F(CZMQToolkitTests, CalculateHeadersShortMessage) {
   MakeSmallData();
   t_data.assign(&t_smallData[0], &t_smallData[0] + 16);
   CZMQToolkit::GetHash(&t_data, t_header);
   uLong crc = crc32(0L, NULL, 0);
   crc = crc32(crc, reinterpret_cast<unsigned char*> (&t_smallData[0]), 16);
   EXPECT_EQ(crc, t_header);
}

TEST_F(CZMQToolkitTests, CalculateHeadersBigMessage) {
   MakeBigData(1500);
   t_data.assign(t_bigData, t_bigData + t_bigDataSize);
   CZMQToolkit::GetHash(&t_data, t_header);
   uLong crc = crc32(0L, NULL, 0);
   crc = crc32(crc, &t_bigData[0], t_bigDataSize);
   EXPECT_EQ(crc, t_header);
}

TEST_F(CZMQToolkitTests, CalculateHeadersBigMessageBench) {

   MakePacketsData();
   t_data.assign(t_bigData, t_bigData + t_bigDataSize);
   int iterations = PACKETS_TO_TEST >> 2;
   SetExpectedTime(iterations, t_bigDataSize, 5000, 500000L);
   StartTimedSection();
   while (iterations-- >= 0) {
      CZMQToolkit::GetHash(&t_data, t_header);
   }
   EndTimedSection();
   if (PACKETS_TO_TEST > 1000) {
      EXPECT_TRUE(TimedSectionPassed());
   }
}

TEST_F(CZMQToolkitTests, CalculateHeadersSmallMessageBench) {

   MakeSmallData();
   t_data.assign(t_smallData, t_smallData + 16);
   int iterations = PACKETS_TO_TEST << 4;
   SetExpectedTime(iterations, 16, 5000, 4000000L);
   StartTimedSection();
   while (iterations-- >= 0) {
      CZMQToolkit::GetHash(&t_data, t_header);
   }
   EndTimedSection();
   if (PACKETS_TO_TEST > 1000) {
      EXPECT_TRUE(TimedSectionPassed());
   }

}

TEST_F(CZMQToolkitTests, ValidateMessage) {

   zmsg_t* message = NULL;
   ASSERT_FALSE(CZMQToolkit::IsValidMessage(message));
   message = zmsg_new();
   ASSERT_TRUE(CZMQToolkit::IsValidMessage(message));
   for (int i = 0; i < ZMQ_KILL_MESSAGE; i++) {
      zmsg_addmem(message, "", 0);
   }
   ASSERT_FALSE(CZMQToolkit::IsValidMessage(message));
   zmsg_destroy(&message);
}

TEST_F(CZMQToolkitTests, SendShutdownMessage) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   CZMQToolkit::SendShutdownMessage(NULL);
   CZMQToolkit::SendShutdownMessage(mReqSocket);
   zmsg_t* message = zmsg_recv(mRepSocket);
   ASSERT_FALSE(message == NULL);
   ASSERT_FALSE(CZMQToolkit::IsValidMessage(message));
   zmsg_destroy(&message);
}

TEST_F(CZMQToolkitTests, SendAndGetSizeTFromSocketFailures) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   size_t testVal = 1023456;
   ASSERT_FALSE(CZMQToolkit::SendSizeTToSocket(NULL, testVal));
   ASSERT_FALSE(CZMQToolkit::GetSizeTFromSocket(NULL, testVal));

   zctx_destroy(&mContext);
   ASSERT_FALSE(CZMQToolkit::SendSizeTToSocket(mReqSocket, testVal));
   ASSERT_FALSE(CZMQToolkit::GetSizeTFromSocket(mRepSocket, testVal));
}

TEST_F(CZMQToolkitTests, SendAndGetSizeTFromSocket) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   size_t testVal = 1023456;
   size_t replyVal;

   ASSERT_TRUE(CZMQToolkit::SendSizeTToSocket(mReqSocket, testVal));
   ASSERT_TRUE(CZMQToolkit::GetSizeTFromSocket(mRepSocket, replyVal));
   ASSERT_EQ(testVal, replyVal);
}
// TODO, this test causes an assertion in the new czmq, but I don't know why
//TEST_F(CZMQToolkitTests, SendAndGetSizeTFromSocketInvalid) {
//   ASSERT_TRUE(mRepSocket != NULL);
//   ASSERT_TRUE(mReqSocket != NULL);
//   size_t replyVal;
//
//   ASSERT_TRUE(CZMQToolkit::SendBlankMessage(mReqSocket));
//   ASSERT_FALSE(CZMQToolkit::GetSizeTFromSocket(mRepSocket, replyVal));
//}
TEST_F(CZMQToolkitTests, GetSizeTFromSocketShutdownMsg) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   ASSERT_TRUE(mReqSocket2 != NULL);
   size_t replyVal;
   CZMQToolkit::SendShutdownMessage(mReqSocket);
   ASSERT_FALSE(CZMQToolkit::GetSizeTFromSocket(mRepSocket, replyVal));

}

TEST_F(CZMQToolkitTests, SendBlankMessageFailures) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   ASSERT_FALSE(CZMQToolkit::SendBlankMessage(NULL));
   ASSERT_FALSE(CZMQToolkit::PopAndDiscardMessage(NULL));

   zctx_destroy(&mContext);
   ASSERT_FALSE(CZMQToolkit::SendBlankMessage(mReqSocket));
   ASSERT_FALSE(CZMQToolkit::PopAndDiscardMessage(mRepSocket));
}

TEST_F(CZMQToolkitTests, SendBlankMessage) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);

   ASSERT_TRUE(CZMQToolkit::SendBlankMessage(mReqSocket));
   ASSERT_TRUE(CZMQToolkit::PopAndDiscardMessage(mRepSocket));
}

TEST_F(CZMQToolkitTests, PopAndDiscardMessageShutdownMsg) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   ASSERT_TRUE(mReqSocket2 != NULL);

   CZMQToolkit::SendShutdownMessage(mReqSocket);
   ASSERT_FALSE(CZMQToolkit::PopAndDiscardMessage(mRepSocket));

}

TEST_F(CZMQToolkitTests, SocketFIFOFailures) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   ASSERT_FALSE(CZMQToolkit::SocketFIFO(NULL));
   zctx_destroy(&mContext);
   ASSERT_FALSE(CZMQToolkit::SocketFIFO(mRepSocket));
}

TEST_F(CZMQToolkitTests, SocketFIFO) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);

   size_t testVal = 1023456;
   size_t replyVal;

   ASSERT_TRUE(CZMQToolkit::SendSizeTToSocket(mReqSocket, testVal));
   ASSERT_TRUE(CZMQToolkit::SocketFIFO(mRepSocket));
   ASSERT_TRUE(CZMQToolkit::GetSizeTFromSocket(mReqSocket, replyVal));
   ASSERT_EQ(testVal, replyVal);
}
TEST_F(CZMQToolkitTests, SocketFIFOInvalidLength) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);

   zmsg_t* bullet = zmsg_new();
   zmsg_addmem(bullet,"",0);
   zmsg_addmem(bullet,"",0);
   ASSERT_TRUE(CZMQToolkit::SendExistingMessage(bullet,mReqSocket));
   ASSERT_FALSE(CZMQToolkit::SocketFIFO(mRepSocket));
}
TEST_F(CZMQToolkitTests, SocketFIFOShutdownMsg) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   ASSERT_TRUE(mReqSocket2 != NULL);

   CZMQToolkit::SendShutdownMessage(mReqSocket);
   ASSERT_FALSE(CZMQToolkit::SocketFIFO(mRepSocket));

}

TEST_F(CZMQToolkitTests, SendExistingMessageFailures) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   zmsg_t* message = NULL;
   ASSERT_FALSE(CZMQToolkit::SendExistingMessage(message, NULL));
   ASSERT_FALSE(CZMQToolkit::SendExistingMessage(message, mReqSocket));
   message = zmsg_new();
   zmsg_addmem(message, "abc", 3);
   ASSERT_FALSE(CZMQToolkit::SendExistingMessage(message, NULL));
   zctx_destroy(&mContext);
   zclock_sleep(100);
   ASSERT_FALSE(CZMQToolkit::SendExistingMessage(message, mReqSocket));
   zmsg_destroy(&message);
}

TEST_F(CZMQToolkitTests, SendExistingMessage) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   zmsg_t* message = zmsg_new();
   zmsg_addmem(message, "abc", 3);
   ASSERT_TRUE(CZMQToolkit::SendExistingMessage(message, mReqSocket));
   zmsg_t* gotMessage = zmsg_recv(mRepSocket);
   ASSERT_EQ(1, zmsg_size(gotMessage));
   zframe_t* frame = zmsg_pop(gotMessage);
   ASSERT_EQ(3, zframe_size(frame));
   std::string aString(reinterpret_cast<char*> (zframe_data(frame)), 3);
   ASSERT_EQ("abc", aString);
   zframe_destroy(&frame);
   zmsg_destroy(&gotMessage);
   zmsg_destroy(&message);
}

TEST_F(CZMQToolkitTests, PassMessageAlongFailures) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   ASSERT_FALSE(CZMQToolkit::PassMessageAlong(NULL, NULL));
   ASSERT_FALSE(CZMQToolkit::PassMessageAlong(mRepSocket, NULL));
   ASSERT_FALSE(CZMQToolkit::PassMessageAlong(NULL, mReqSocket));
   zctx_destroy(&mContext);
   ASSERT_FALSE(CZMQToolkit::PassMessageAlong(mRepSocket, mReqSocket));
}

TEST_F(CZMQToolkitTests, PassMessageAlong) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);

   size_t testVal = 1023456;
   size_t replyVal;

   ASSERT_TRUE(CZMQToolkit::SendSizeTToSocket(mReqSocket, testVal));
   ASSERT_TRUE(CZMQToolkit::PassMessageAlong(mRepSocket, mRepSocket));
   ASSERT_TRUE(CZMQToolkit::GetSizeTFromSocket(mReqSocket, replyVal));
   ASSERT_EQ(testVal, replyVal);
}

TEST_F(CZMQToolkitTests, PassMessageAlongShutdownMsg) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   ASSERT_TRUE(mReqSocket2 != NULL);

   CZMQToolkit::SendShutdownMessage(mReqSocket);
   ASSERT_FALSE(CZMQToolkit::PassMessageAlong(mRepSocket, mRepSocket));

}

TEST_F(CZMQToolkitTests, ForkPartsOfMessageTwoDirectionsFailures) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   ASSERT_TRUE(mReqSocket2 != NULL);
   ASSERT_FALSE(CZMQToolkit::ForkPartsOfMessageTwoDirections(NULL, NULL, NULL));
   ASSERT_FALSE(CZMQToolkit::ForkPartsOfMessageTwoDirections(mRepSocket, NULL, NULL));
   ASSERT_FALSE(CZMQToolkit::ForkPartsOfMessageTwoDirections(NULL, mReqSocket, NULL));
   ASSERT_FALSE(CZMQToolkit::ForkPartsOfMessageTwoDirections(NULL, NULL, mReqSocket2));
   ASSERT_FALSE(CZMQToolkit::ForkPartsOfMessageTwoDirections(mRepSocket, mReqSocket, NULL));
   ASSERT_FALSE(CZMQToolkit::ForkPartsOfMessageTwoDirections(mRepSocket, NULL, mReqSocket2));
   ASSERT_FALSE(CZMQToolkit::ForkPartsOfMessageTwoDirections(NULL, mReqSocket, mReqSocket2));

   zctx_destroy(&mContext);
   ASSERT_FALSE(CZMQToolkit::ForkPartsOfMessageTwoDirections(mRepSocket, mReqSocket, mReqSocket2));
}

TEST_F(CZMQToolkitTests, ForkPartsOfMessageTwoDirections) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   ASSERT_TRUE(mReqSocket2 != NULL);

   zmsg_t* message = zmsg_new();
   zmsg_addmem(message, "123", 3);
   zmsg_addmem(message, "4567", 4);
   zmsg_send(&message, mReqSocket);

   ASSERT_TRUE(CZMQToolkit::ForkPartsOfMessageTwoDirections(mRepSocket, mRepSocket, mReqSocket2));
   message = zmsg_recv(mReqSocket);
   ASSERT_EQ(1, zmsg_size(message));
   zframe_t* frame = zmsg_last(message);
   ASSERT_EQ(3, zframe_size(frame));
   std::string aString(reinterpret_cast<char*> (zframe_data(frame)), zframe_size(frame));
   ASSERT_EQ("123", aString);
   zmsg_destroy(&message);
   message = zmsg_recv(mRepSocket);
   ASSERT_EQ(1, zmsg_size(message));
   frame = zmsg_last(message);
   ASSERT_EQ(4, zframe_size(frame));
   aString.assign(reinterpret_cast<char*> (zframe_data(frame)), zframe_size(frame));
   ASSERT_EQ("4567", aString);
   zmsg_destroy(&message);
}

TEST_F(CZMQToolkitTests, ForkPartsOfMessageTwoDirectionsShutdownMsg) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   ASSERT_TRUE(mReqSocket2 != NULL);

   CZMQToolkit::SendShutdownMessage(mReqSocket);
   ASSERT_FALSE(CZMQToolkit::ForkPartsOfMessageTwoDirections(mRepSocket, mRepSocket, mReqSocket2));

}

TEST_F(CZMQToolkitTests, SendStringWithHashFailures) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   ASSERT_TRUE(mReqSocket2 != NULL);

   zmsg_t* message = NULL;
   std::string* aString = NULL;
   ASSERT_FALSE(CZMQToolkit::SendStringWithHash(mReqSocket, message, aString));
   message = zmsg_new();
   ASSERT_FALSE(CZMQToolkit::SendStringWithHash(mReqSocket, message, aString));
   zmsg_destroy(&message);
   std::string expectedString("abc");
   aString = new std::string(expectedString);
   ASSERT_FALSE(CZMQToolkit::SendStringWithHash(mReqSocket, message, aString));
   message = zmsg_new();
   ASSERT_FALSE(CZMQToolkit::SendStringWithHash(NULL, message, aString));

   zctx_destroy(&mContext);
   ASSERT_FALSE(CZMQToolkit::SendStringWithHash(mReqSocket, message, aString));

   zmsg_destroy(&message);
   delete aString;
}

TEST_F(CZMQToolkitTests, SendStringWithHash) {
   ASSERT_TRUE(mRepSocket != NULL);
   ASSERT_TRUE(mReqSocket != NULL);
   ASSERT_TRUE(mReqSocket2 != NULL);

   zmsg_t* message = zmsg_new();
   std::string expectedString("abc");
   std::string* aString = new std::string(expectedString);

   ASSERT_TRUE(CZMQToolkit::SendStringWithHash(mReqSocket, message, aString));
   ASSERT_TRUE(CZMQToolkit::ForkPartsOfMessageTwoDirections(mRepSocket, mRepSocket, mReqSocket2));
   message = zmsg_recv(mReqSocket);
   ASSERT_EQ(1, zmsg_size(message));
   zframe_t* frame = zmsg_last(message);
   ASSERT_EQ(sizeof (uLong), zframe_size(frame));
   uLong hash = *(reinterpret_cast<uLong*> (zframe_data(frame)));
   ASSERT_EQ(891568578, hash);
   zmsg_destroy(&message);
   message = zmsg_recv(mRepSocket);
   ASSERT_EQ(1, zmsg_size(message));
   frame = zmsg_last(message);
   ASSERT_EQ(sizeof (std::string*), zframe_size(frame));
   ASSERT_EQ(aString, *(reinterpret_cast<std::string**> (zframe_data(frame))));
   zmsg_destroy(&message);
   delete aString;
}


text:
<?php

namespace CCICommunity\BaseBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class VDCType extends AbstractType
{
        /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('titre')
            ->add('texte')
            ->add('file', 'file', array('label'  => 'Image'))
            ->add('auteur')
            ->add('date')
            ->add('promo')
        ;
    }

    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'CCICommunity\BaseBundle\Entity\VDC'
        ));
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'ccicommunity_basebundle_vdc';
    }
}


text:
<!doctype html>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="theme-color" content="#000000">

    <link rel="manifest" href="%PUBLIC_URL%/manifest.json">
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
     <link href="https://fonts.googleapis.com/css?family=Montserrat:100,400,500" rel="stylesheet">

    <title>Sha-Studio</title>

      You need to enable JavaScript to run this app.

sha studio.


text:
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using LightBDD.Results;

namespace LightBDD.Notification
{
    /// <summary>
    /// Progress notifier using console for displaying simplified progress, dedicated for multithreaded environment.
    /// </summary>
    [DebuggerStepThrough]
    public class SimplifiedConsoleProgressNotifier : IProgressNotifier
    {
        private static readonly SimplifiedConsoleProgressNotifier Instance = new SimplifiedConsoleProgressNotifier();
        private int _scenariosPending;
        private int _scenariosFailed;
        private int _scenariosFinished;

        /// <summary>
        /// Progress notifier instance
        /// </summary>
        public static SimplifiedConsoleProgressNotifier GetInstance() { return Instance; }

        private SimplifiedConsoleProgressNotifier()
        {
        }

        /// <summary>
        /// Notifies that scenario has been started.
        /// </summary>
        /// <param name="scenarioName">Scenario name.</param>
        /// <param name="label">Scenario label.</param>
        [MethodImpl(MethodImplOptions.Synchronized)]
        public void NotifyScenarioStart(string scenarioName, string label)
        {
            _scenariosPending++;
            WriteProgress("starting: {0}", scenarioName);
        }

        /// <summary>
        /// Notifies that scenario has been finished with given status and optional details.
        /// </summary>
        /// <param name="scenarioResult">Scenario result</param>
        [MethodImpl(MethodImplOptions.Synchronized)]
        public void NotifyScenarioFinished(IScenarioResult scenarioResult)
        {
            _scenariosFinished++;
            _scenariosPending--;
            if (scenarioResult.Status == ResultStatus.Failed)
                _scenariosFailed++;
            WriteProgress("{0}: {1}", scenarioResult.Status.ToString().ToUpperInvariant(), scenarioResult.Name);
        }

        private void WriteProgress(string format, params object[] args)
        {
            Console.WriteLine("Finished={0}, Failed={1}, Pending={2}: {3}", _scenariosFinished, _scenariosFailed, _scenariosPending, string.Format(format, args));
        }

        /// <summary>
        /// Notifies that feature has been started.
        /// </summary>
        /// <param name="featureName">Feature name.</param>
        /// <param name="featureDescription">Feature description.</param>
        /// <param name="label">Feature label.</param>
        public void NotifyFeatureStart(string featureName, string featureDescription, string label)
        {
        }

        /// <summary>
        /// Notifies that step has been started.
        /// </summary>
        /// <param name="stepName">Step name.</param>
        /// <param name="stepNumber">Step number starting from 1.</param>
        /// <param name="totalStepCount">Total number of steps.</param>
        public void NotifyStepStart(string stepName, int stepNumber, int totalStepCount)
        {
        }

        /// <summary>
        /// Notifies that step execution has been finished.
        /// </summary>
        /// <param name="stepResult">Step result.</param>
        /// <param name="totalStepCount">Total step count</param>
        public void NotifyStepFinished(IStepResult stepResult, int totalStepCount)
        {
        }

        /// <summary>
        /// Notifies that step has been commented.
        /// </summary>
        /// <param name="comment">Comment.</param>
        /// <param name="stepNumber">Step number starting from 1.</param>
        /// <param name="totalStepCount">Total number of steps.</param>
        public void NotifyStepComment(int stepNumber, int totalStepCount, string comment)
        {
        }

        /// <summary>
        /// Resets counters.
        /// </summary>
        [MethodImpl(MethodImplOptions.Synchronized)]
        public void Reset()
        {
            _scenariosPending = _scenariosFinished = _scenariosFailed = 0;
        }
    }
}


text:
import shogun as sg
import data
import numpy as np

# load data
feature_matrix = data.swissroll()
# create features instance
features = sg.RealFeatures(feature_matrix)

# create Diffusion Maps converter instance
converter = sg.DiffusionMaps()

# set target dimensionality
converter.set_target_dim(2)
# set number of time-steps
converter.set_t(2)
# set width of gaussian kernel
converter.set_width(10.0)

# create euclidean distance instance
distance = sg.EuclideanDistance()
# enable converter instance to use created distance instance
converter.set_distance(distance)

# compute embedding with Diffusion Maps method
embedding = converter.embed(features)

# compute custom distance matrix
distance_matrix = np.exp(-np.dot(feature_matrix.T,feature_matrix))
# create Custom Kernel instance
custom_distance = sg.CustomDistance(distance_matrix)
# construct embedding based on created distance
distance_embedding = converter.embed_distance(custom_distance)


text:
import * as React from "react";
import {withLayout} from "../components/Layout";
import Row from "react-bootstrap/lib/Row";
import Col from "react-bootstrap/lib/Col";
import Container from "react-bootstrap/lib/Container";
import Hero from "../components/Hero";
import SEO from "../components/SEO/SEO";
import {Questions} from "./faq";
import { useTranslation } from "gatsby-plugin-react-i18next";

const SupportPage = ({pageContext}: PageProps) => {
  const {t, i18n} = useTranslation();
  const qs = Questions(t).filter((q) => q.support);

  let email = "support@impactasaurus.org";
  if (i18n.language === "pt") {
    email = "support.pt@impactasaurus.org";
  }

  return (
    <>
    <SEO
      title={t("support.title")}
      description={t("support.description")}
      context={pageContext}
    />
    <Hero>

{t("support.title")}

{t("support.subtitle")}

    </Hero>
    <Container className="slanted">
      <Row>
        <Col>

{t("support.email")}

        </Col>
      </Row>
      <Row className="header">
        <Col>

<a href={`mailto:${email}`}>{email}

        </Col>
      </Row>
      <Row className="header">
        <Col>

Common Queries

          {qs.map((q) => (

{q.title}

              {q.main}

          ))}
        </Col>
      </Row>
    </Container>
    </>
  );
};

export default withLayout(SupportPage);

export const query = graphql`
  query($language: String!) {
    locales: allLocale(filter: {language: {eq: $language}}) {
      edges {
        node {
          ns
          data
          language
        }
      }
    }
  }
`;