def test_row_type_filter_2(): filtered = results.read_result_files(RESULT_FILES, "run =~ *General-0* AND module =~ Test.node1 AND name =~ foo1*") df = results.get_results(filtered, row_types=["scalar", "attr"]) _assert_sequential_index(df) # 2 times 3 rows for scalars (incl. value), and 3 times 2 rows for the vector, stats, and histogram (only attr) # since we only filtered for row types, not result types, we get the attrs for the other kinds of results too, just not the results themselves return df.shape == (12, 7)
def test_vectors_start_end_time_at_load(): trimmed = results.read_result_files(RESULT_FILES, vector_start_time=40, vector_end_time=60) df = results.get_vectors(trimmed) _assert_sequential_index(df) _assert(sanitize_and_compare_csv(df, "vectors_start_end_time.csv"), "content mismatch")
def test_vector_time_limit_at_load_2(): filtered = results.read_result_files( RESULT_FILES, "type =~ vector AND run =~ General-0*", vector_end_time=50.0) df = results.get_results(filtered, row_types=["vector"]) _assert_sequential_index(df) return df["vectime"].map(lambda a: (a < 50.0).all()).all()
def test_vectors_end_time(): trimmed = results.read_result_files(RESULT_FILES) df = results.get_vectors(trimmed, end_time=80) _assert_sequential_index(df) _assert(sanitize_and_compare_csv(df, "vectors_end_time.csv"), "content mismatch")
def test_vector_data(): filtered = results.read_result_files( RESULT_FILES, "type =~ vector AND run =~ General-0*") df = results.get_results(filtered, row_types=["vector"]) _assert_sequential_index(df) return df["vectime"].map(lambda a: a.shape == (100, )).all()
def test_row_type_filter_3(): filtered = results.read_result_files(RESULT_FILES, "type =~ param") df = results.get_results(filtered, row_types=["attr"]) _assert_sequential_index(df) # params don't have attrs return df.empty
def test_result_filter(): filtered = results.read_result_files(RESULT_FILES, "type =~ scalar") df = results.get_results(filtered) _assert_sequential_index(df) # in all 6 runs: 20 lines of metadata, and 4 lines (1 scalar and 3 attrs) for all 8 scalars return df.shape == (312, 7)
""" This is all the tests extracted from results_api_test, adapted to the standalone result loading/processing API. """ from omnetpp.scave import results import pandas as pd import tester tester.print = print from tester import _assert, _assert_sequential_index, run_tests, sanitize_and_compare_csv RESULT_FILES = ["results/General-*.vec", "results/General-*.sca"] r = results.read_result_files(RESULT_FILES) def test_runs(): df = results.get_runs(r) _assert_sequential_index(df) _assert(sanitize_and_compare_csv(df, "runs.csv"), "content mismatch") def test_runs_with_itervars(): df = results.get_runs(r, include_itervars=True) _assert_sequential_index(df) _assert(sanitize_and_compare_csv(df, "runs_with_itervars.csv"), "content mismatch") def test_runs_with_runattrs(): df = results.get_runs(r, include_runattrs=True)