Ejemplo n.º 1
0
def test_CategoricalSummary__make_input_file_IO(cat_sum,
                                                expected_latext_content):
    with StringIO() as inputIO:
        cat_sum._make_input_file_IO(inputIO)
        input_string = inputIO.getvalue()

    helpers.assert_bigstring_equal(input_string, expected_latext_content)
Ejemplo n.º 2
0
def test_CategoricalSummary__make_report_IO(cat_sum, expected_latex_report,
                                            temp_template):
    with StringIO() as report, open(temp_template, 'r') as template:
        cat_sum._make_report_IO(template, 'testpath.tex', report,
                                'test report title')
        helpers.assert_bigstring_equal(report.getvalue(),
                                       expected_latex_report)
Ejemplo n.º 3
0
def test_DatasetSummary__make_tex_table(dset_sum):
    if dset_sum.ds.scenario == (True, True):
        expected = r"""
        \begin{table}[h!]
            \caption{test title}
            \centering
            \begin{tabular}{l l l l l}
                \toprule
                \textbf{Statistic} & \textbf{Inlet} & \textbf{Outlet} \\
                \toprule
                Count & 25 & 25 \\
                \midrule
                Number of NDs & 5 & 5 \\
                \midrule
                Min; Max & 0.123; 123 & 0.123; 123 \\
                \midrule
                Mean & 12.3 & 12.3 \\
                %%
                (95\% confidence interval) & (11.3; 13.3) & (11.3; 13.3) \\
                \midrule
                Standard Deviation & 4.56 & 4.56 \\
                \midrule
                Log. Mean & 12.3 & 12.3 \\
                %%
                (95\% confidence interval) & (11.3; 13.3) & (11.3; 13.3) \\
                \midrule
                Log. Standard Deviation & 4.56 & 4.56 \\
                \midrule
                Geo. Mean & 12.3 & 12.3 \\
                %%
                (95\% confidence interval) & (11.3; 13.3) & (11.3; 13.3) \\
                \midrule
                Coeff. of Variation & 5.61 & 5.61 \\
                \midrule
                Skewness & 6.12 & 6.12 \\
                \midrule
                Median & 1.23 & 1.23 \\
                %%
                (95\% confidence interval) & (0.235; 2.23) & (0.235; 2.23) \\
                \midrule
                Quartiles & 0.612; 2.35 & 0.612; 2.35 \\
                \toprule
                Number of Pairs & \multicolumn{2}{c} {22} \\
                \midrule
                Wilcoxon p-value & \multicolumn{2}{c} {$<0.001$} \\
                \midrule
                Mann-Whitney p-value & \multicolumn{2}{c} {0.456} \\
                \bottomrule
            \end{tabular}
        \end{table}""" + '\n'
        result = dset_sum._make_tex_table('test title')
        helpers.assert_bigstring_equal(result, expected)
    else:
        pass
Ejemplo n.º 4
0
def test_DatasetSummary__make_tex_table(dset_sum):
    if dset_sum.ds.scenario == (True, True):
        expected = r"""
        \begin{table}[h!]
            \caption{test title}
            \centering
            \begin{tabular}{l l l l l}
                \toprule
                \textbf{Statistic} & \textbf{Inlet} & \textbf{Outlet} \\
                \toprule
                Count & 25 & 25 \\
                \midrule
                Number of NDs & 5 & 5 \\
                \midrule
                Min; Max & 0.123; 123 & 0.123; 123 \\
                \midrule
                Mean & 12.3 & 12.3 \\
                %%
                (95\% confidence interval) & (11.3; 13.3) & (11.3; 13.3) \\
                \midrule
                Standard Deviation & 4.56 & 4.56 \\
                \midrule
                Log. Mean & 12.3 & 12.3 \\
                %%
                (95\% confidence interval) & (11.3; 13.3) & (11.3; 13.3) \\
                \midrule
                Log. Standard Deviation & 4.56 & 4.56 \\
                \midrule
                Geo. Mean & 12.3 & 12.3 \\
                %%
                (95\% confidence interval) & (11.3; 13.3) & (11.3; 13.3) \\
                \midrule
                Coeff. of Variation & 5.61 & 5.61 \\
                \midrule
                Skewness & 6.12 & 6.12 \\
                \midrule
                Median & 1.23 & 1.23 \\
                %%
                (95\% confidence interval) & (0.235; 2.23) & (0.235; 2.23) \\
                \midrule
                Quartiles & 0.612; 2.35 & 0.612; 2.35 \\
                \toprule
                Number of Pairs & \multicolumn{2}{c} {22} \\
                \midrule
                Wilcoxon p-value & \multicolumn{2}{c} {$<0.001$} \\
                \midrule
                Mann-Whitney p-value & \multicolumn{2}{c} {0.456} \\
                \bottomrule
            \end{tabular}
        \end{table}""" + '\n'
        result = dset_sum._make_tex_table('test title')
        helpers.assert_bigstring_equal(result, expected)
    else:
        pass
Ejemplo n.º 5
0
def test_makeLongLandscapeTexTable(footnote, long_landscape_tables):
    dfdict = {
        "W": {"a": 0.84386963791251501, "b": -0.22109837444207142},
        "X": {"a": 0.70049867715201963, "b": 1.4764939161054218},
        "Y": {"a": -1.3477794473987552, "b": -1.1939220296611821},
    }
    df = pandas.DataFrame.from_dict(dfdict)
    result = utils.makeLongLandscapeTexTable(
        df, "test caption", "label", footnotetext=footnote
    )
    expected = long_landscape_tables[footnote]
    helpers.assert_bigstring_equal(result, expected)
Ejemplo n.º 6
0
def test_CategoricalSummary_makeReport(cat_sum, expected_latex_report, temp_template):
    templatepath = get_tex_file('draft_template.tex')
    inputpath = get_tex_file('inputs_{}.tex'.format(cat_sum.paramgroup.lower()))
    with TemporaryDirectory() as tmpdir:
        reportpath = os.path.join(tmpdir, 'report_{}.tex'.format(cat_sum.paramgroup.lower()))
        testpath = os.path.join(tmpdir, 'testpath.tex'.format(cat_sum.paramgroup.lower()))
        cat_sum.makeReport(
            temp_template,
            testpath,
            reportpath,
            'test report title',
            regenfigs=False
        )

        with open(reportpath, 'r') as rp:
            helpers.assert_bigstring_equal(rp.read(), expected_latex_report)
Ejemplo n.º 7
0
def test_CategoricalSummary_makeReport(cat_sum, expected_latex_report,
                                       temp_template):
    templatepath = get_tex_file('draft_template.tex')
    inputpath = get_tex_file('inputs_{}.tex'.format(
        cat_sum.paramgroup.lower()))
    with TemporaryDirectory() as tmpdir:
        reportpath = os.path.join(
            tmpdir, 'report_{}.tex'.format(cat_sum.paramgroup.lower()))
        testpath = os.path.join(
            tmpdir, 'testpath.tex'.format(cat_sum.paramgroup.lower()))
        cat_sum.makeReport(temp_template,
                           testpath,
                           reportpath,
                           'test report title',
                           regenfigs=False)

        with open(reportpath, 'r') as rp:
            helpers.assert_bigstring_equal(rp.read(), expected_latex_report)
Ejemplo n.º 8
0
def test_makeLongLandscapeTexTable(footnote, long_landscape_tables):
    dfdict = {
        'W': {
            'a': 0.84386963791251501,
            'b': -0.22109837444207142,
        },
        'X': {
            'a': 0.70049867715201963,
            'b': 1.4764939161054218,
        },
        'Y': {
            'a': -1.3477794473987552,
            'b': -1.1939220296611821,
        },
    }
    df = pandas.DataFrame.from_dict(dfdict)
    result = utils.makeLongLandscapeTexTable(df, 'test caption', 'label',
                                             footnotetext=footnote)
    expected = long_landscape_tables[footnote]
    helpers.assert_bigstring_equal(result, expected)
Ejemplo n.º 9
0
def test_makeLongLandscapeTexTable(footnote, long_landscape_tables):
    dfdict = {
        'W': {
            'a': 0.84386963791251501,
            'b': -0.22109837444207142,
        },
        'X': {
            'a': 0.70049867715201963,
            'b': 1.4764939161054218,
        },
        'Y': {
            'a': -1.3477794473987552,
            'b': -1.1939220296611821,
        },
    }
    df = pandas.DataFrame.from_dict(dfdict)
    result = utils.makeLongLandscapeTexTable(df,
                                             'test caption',
                                             'label',
                                             footnotetext=footnote)
    expected = long_landscape_tables[footnote]
    helpers.assert_bigstring_equal(result, expected)
Ejemplo n.º 10
0
def test_DatasetSummary_makeTexInput(dset_sum, expected_latext_input):
    result = dset_sum.makeTexInput('test table title')
    helpers.assert_bigstring_equal(result,
                                   expected_latext_input[dset_sum.ds.scenario])
Ejemplo n.º 11
0
def test_CategoricalSummary__make_report_IO(cat_sum, expected_latex_report, temp_template):
    with StringIO() as report, open(temp_template, 'r') as template:
        cat_sum._make_report_IO(template, 'testpath.tex', report, 'test report title')
        helpers.assert_bigstring_equal(report.getvalue(), expected_latex_report)
Ejemplo n.º 12
0
def test_CategoricalSummary__make_input_file_IO(cat_sum, expected_latext_content):
    with StringIO() as inputIO:
        cat_sum._make_input_file_IO(inputIO)
        input_string = inputIO.getvalue()

    helpers.assert_bigstring_equal(input_string, expected_latext_content)
Ejemplo n.º 13
0
def test_DatasetSummary_makeTexInput(dset_sum, expected_latext_input):
    result = dset_sum.makeTexInput('test table title')
    helpers.assert_bigstring_equal(result, expected_latext_input[dset_sum.ds.scenario])