<commit_before>from recon.trans import wall2meld, dsres2meld

from recon.wall import WallReader, WallWriter
from recon.meld import MeldReader, MeldWriter

from TestWall import write_wall

from nose.tools import *

def testWall2Meld():
    write_wall(verbose=True);

    with open("sample.wll", "rb") as wfp:
        with open("sample.mld", "w+") as mfp:
            wall2meld(wfp, mfp)

    with open("sample.mld", "rb") as fp:
        meld = MeldReader(fp, verbose=True)

        print "Objects:"
        for objname in meld.objects():
            obj = meld.read_object(objname)
            print "  "+objname+" = "+str(obj)

        print "Tables:"
        for tabname in meld.tables():
            table = meld.read_table(tabname)
            print "  "+tabname
            for signal in table.signals():
                print "    #"+signal+": "+str(table.data(signal))

        print "table.metadata = "+str(table.metadata)
        print "table.var_metadata = "+str(table.var_metadata)

        assert_equals(meld.metadata, {"a": "bar"})
        assert_equals(table.signals(), ["time", "x", "y", "a", "b"])
        assert_equals(table.data("time"), [0.0, 1.0, 2.0])
        assert_equals(table.metadata, {"b": "foo"})
        assert_equals(table.var_metadata["time"], {"units": "s"})
        assert_equals(table.data("x"), [1.0, 0.0, 1.0])
        assert_equals(table.data("y"), [2.0, 3.0, 3.0])
        assert_equals(table.data("a"), [2.0, 1.0, 2.0])
        assert_equals(table.data("b"), [-2.0, -3.0, -3.0])

def testDsres2Meld():
    with open("dsres.mld", "w+") as fp:
        dsres2meld("tests/dsres.mat", fp, verbose=True, compression=False)

    with open("dsres.mld", "rb") as fp:
        meld = MeldReader(fp, verbose=True)
        print str(meld.report())

def testDsres2Meld_Compression():
    with open("dsres_comp.mld", "w+") as fp:
        dsres2meld("tests/dsres.mat", fp, verbose=True, compression=True)

    with open("dsres_comp.mld", "rb") as fp:
        meld = MeldReader(fp, verbose=True)
        print str(meld.report())

@nottest
def testDsres2Meld_Robot():
    with open("dsres_robot.mld", "w+") as fp:
        dsres2meld("tests/fullRobot.mat", fp, verbose=True, compression=False)

    with open("dsres.mld", "rb") as fp:
        meld = MeldReader(fp, verbose=True)
        print str(meld.report())

@nottest
def testDsres2Meld_Compression_Robot():
    with open("dsres_robot_comp.mld", "w+") as fp:
        dsres2meld("tests/fullRobot.mat", fp, verbose=True)

    with open("dsres_comp.mld", "rb") as fp:
        meld = MeldReader(fp, verbose=True)
        print str(meld.report())
<commit_msg>Getting rid of some output<commit_after>from recon.trans import wall2meld, dsres2meld

from recon.wall import WallReader, WallWriter
from recon.meld import MeldReader, MeldWriter

from TestWall import write_wall

from nose.tools import *

def testWall2Meld():
    write_wall(verbose=True);

    with open("sample.wll", "rb") as wfp:
        with open("sample.mld", "w+") as mfp:
            wall2meld(wfp, mfp)

    with open("sample.mld", "rb") as fp:
        meld = MeldReader(fp, verbose=True)

        print "Objects:"
        for objname in meld.objects():
            obj = meld.read_object(objname)
            print "  "+objname+" = "+str(obj)

        print "Tables:"
        for tabname in meld.tables():
            table = meld.read_table(tabname)
            print "  "+tabname
            for signal in table.signals():
                print "    #"+signal+": "+str(table.data(signal))

        print "table.metadata = "+str(table.metadata)
        print "table.var_metadata = "+str(table.var_metadata)

        assert_equals(meld.metadata, {"a": "bar"})
        assert_equals(table.signals(), ["time", "x", "y", "a", "b"])
        assert_equals(table.data("time"), [0.0, 1.0, 2.0])
        assert_equals(table.metadata, {"b": "foo"})
        assert_equals(table.var_metadata["time"], {"units": "s"})
        assert_equals(table.data("x"), [1.0, 0.0, 1.0])
        assert_equals(table.data("y"), [2.0, 3.0, 3.0])
        assert_equals(table.data("a"), [2.0, 1.0, 2.0])
        assert_equals(table.data("b"), [-2.0, -3.0, -3.0])

def testDsres2Meld():
    with open("dsres.mld", "w+") as fp:
        dsres2meld("tests/dsres.mat", fp, verbose=True, compression=False)

    with open("dsres.mld", "rb") as fp:
        meld = MeldReader(fp, verbose=True)
        print str(meld.report())

def testDsres2Meld_Compression():
    with open("dsres_comp.mld", "w+") as fp:
        dsres2meld("tests/dsres.mat", fp, verbose=True, compression=True)

    with open("dsres_comp.mld", "rb") as fp:
        meld = MeldReader(fp, verbose=True)
        print str(meld.report())

#@nottest
def testDsres2Meld_Robot():
    with open("dsres_robot.mld", "w+") as fp:
        dsres2meld("tests/fullRobot.mat", fp, verbose=False, compression=False)

    with open("dsres.mld", "rb") as fp:
        meld = MeldReader(fp, verbose=False)
        print str(meld.report())

#@nottest
def testDsres2Meld_Compression_Robot():
    with open("dsres_robot_comp.mld", "w+") as fp:
        dsres2meld("tests/fullRobot.mat", fp, verbose=False)

    with open("dsres_comp.mld", "rb") as fp:
        meld = MeldReader(fp, verbose=False)
        print str(meld.report())

{'fraction_non_alphanumeric': 0.16423288450597384, 'fraction_numerical': 0.01593021050635312, 'mean_word_length': 2.95648912228057, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, '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': '1311970', 'n_tokens_mistral': 1940, 'n_tokens_neox': 1868, 'n_words': 402}