<commit_before>// Copyright 2016 ELIFE. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
#include <ctest.h>
#include <inform/time_series.h>
#include <math.h>

CTEST(TimeSeries, ActiveInfoSeriesTooShort)
{
    int const series[] = {1,1,0,0,1,0,0,1};
    ASSERT_TRUE(isnan(inform_active_info(series, 0, 2)));
    ASSERT_TRUE(isnan(inform_active_info(series, 1, 2)));
}

CTEST(TimeSeries, ActiveInfoHistoryTooLong)
{
    int const series[] = {1,1,0,0,1,0,0,1};

    ASSERT_TRUE(isnan(inform_active_info(series, 2, 2)));
    ASSERT_FALSE(isnan(inform_active_info(series, 3, 2)));
}

CTEST(TimeSeries, ActiveInfoSingleSeries)
{
    ASSERT_DBL_NEAR_TOL(0.918296,
                        inform_active_info((int[]){1,1,0,0,1,0,0,1}, 8, 2),
                        1e-6);

    ASSERT_DBL_NEAR_TOL(0.000000,
                        inform_active_info((int[]){1,0,0,0,0,0,0,0,0}, 9, 2),
                        1e-6);

    ASSERT_DBL_NEAR_TOL(0.305958,
                        inform_active_info((int[]){0,0,1,1,1,1,0,0,0}, 9, 2),
                        1e-6);

    ASSERT_DBL_NEAR_TOL(0.347458,
                        inform_active_info((int[]){1,0,0,0,0,0,0,1,1}, 9, 2),
                        1e-6);

    ASSERT_DBL_NEAR_TOL(0.347458,
                        inform_active_info((int[]){1,0,0,0,0,0,0,1,1}, 9, 2),
                        1e-6);

    ASSERT_DBL_NEAR_TOL(0.399533,
                        inform_active_info((int[]){0,0,0,0,0,1,1,0,0}, 9, 2),
                        1e-6);

    ASSERT_DBL_NEAR_TOL(0.399533,
                        inform_active_info((int[]){0,0,0,0,1,1,0,0,0}, 9, 2),
                        1e-6);

    ASSERT_DBL_NEAR_TOL(0.305958,
                        inform_active_info((int[]){1,1,1,0,0,0,0,1,1}, 9, 2),
                        1e-6);

    ASSERT_DBL_NEAR_TOL(0.305958,
                        inform_active_info((int[]){0,0,0,1,1,1,1,0,0}, 9, 2),
                        1e-6);

    ASSERT_DBL_NEAR_TOL(0.347458,
                        inform_active_info((int[]){0,0,0,0,0,0,1,1,0}, 9, 2),
                        1e-6);
}
<commit_msg>Change indentation<commit_after>// Copyright 2016 ELIFE. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
#include <ctest.h>
#include <inform/time_series.h>
#include <math.h>

CTEST(TimeSeries, ActiveInfoSeriesTooShort)
{
    int const series[] = {1,1,0,0,1,0,0,1};
    ASSERT_TRUE(isnan(inform_active_info(series, 0, 2)));
    ASSERT_TRUE(isnan(inform_active_info(series, 1, 2)));
}

CTEST(TimeSeries, ActiveInfoHistoryTooLong)
{
    int const series[] = {1,1,0,0,1,0,0,1};

    ASSERT_TRUE(isnan(inform_active_info(series, 2, 2)));
    ASSERT_FALSE(isnan(inform_active_info(series, 3, 2)));
}

CTEST(TimeSeries, ActiveInfoSingleSeries)
{
    ASSERT_DBL_NEAR_TOL(0.918296,
            inform_active_info((int[]){1,1,0,0,1,0,0,1}, 8, 2),
            1e-6);

    ASSERT_DBL_NEAR_TOL(0.000000,
            inform_active_info((int[]){1,0,0,0,0,0,0,0,0}, 9, 2),
            1e-6);

    ASSERT_DBL_NEAR_TOL(0.305958,
            inform_active_info((int[]){0,0,1,1,1,1,0,0,0}, 9, 2),
            1e-6);

    ASSERT_DBL_NEAR_TOL(0.347458,
            inform_active_info((int[]){1,0,0,0,0,0,0,1,1}, 9, 2),
            1e-6);

    ASSERT_DBL_NEAR_TOL(0.347458,
            inform_active_info((int[]){1,0,0,0,0,0,0,1,1}, 9, 2),
            1e-6);

    ASSERT_DBL_NEAR_TOL(0.399533,
            inform_active_info((int[]){0,0,0,0,0,1,1,0,0}, 9, 2),
            1e-6);

    ASSERT_DBL_NEAR_TOL(0.399533,
            inform_active_info((int[]){0,0,0,0,1,1,0,0,0}, 9, 2),
            1e-6);

    ASSERT_DBL_NEAR_TOL(0.305958,
            inform_active_info((int[]){1,1,1,0,0,0,0,1,1}, 9, 2),
            1e-6);

    ASSERT_DBL_NEAR_TOL(0.305958,
            inform_active_info((int[]){0,0,0,1,1,1,1,0,0}, 9, 2),
            1e-6);

    ASSERT_DBL_NEAR_TOL(0.347458,
            inform_active_info((int[]){0,0,0,0,0,0,1,1,0}, 9, 2),
            1e-6);
}

{'fraction_non_alphanumeric': 0.17320503330866024, 'fraction_numerical': 0.11201579077226746, 'mean_word_length': 2.441426146010187, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2947888', 'n_tokens_mistral': 1869, 'n_tokens_neox': 1676, 'n_words': 217}