示例#1
0
def test_null():
    flux_h5m = "files_test_magic/null_test.h5m"
    expected_file = "files_test_magic/null_test.wwinp"
    output = "null_wwinp"

    if output in os.listdir("."):
        os.remove(output)

    magic.magic(flux_h5m, "None", False, 33333, output, "None", 0.1)

    f = open(output)
    written = f.readlines()
    f.close

    g = open(expected_file)
    expected = g.readlines()
    g.close

    assert_equal(written[1:], expected[1:])
    os.remove(output)
示例#2
0
def single_group_test1():
    flux_h5m = "files_test_magic/single_group_test1.h5m"
    expected_file = "files_test_magic/single_group_test1.wwinp"
    output = "single_group_test1"

    if output in os.listdir("."):
        os.remove(output)

    magic.magic(flux_h5m, "None", False, 0, output, "None", 0.1)

    f = open(output)
    written = f.readlines()
    f.close

    g = open(expected_file)
    expected = g.readlines()
    g.close

    assert_equal(written[1:], expected[1:])
    os.remove(output)
示例#3
0
def test_block_3():
    flux_h5m = "files_test_magic/iteration_0.h5m"
    expected_file = "files_test_magic/iteration_0.wwinp"
    output = "iteration_0_wwinp"

    if output in os.listdir("."):
        os.remove(output)

    magic.magic(flux_h5m, "None", False, 0, output, "None", 0.1)

    f = open(output)
    written = f.readlines()
    f.close

    g = open(expected_file)
    expected = g.readlines()
    g.close

    assert_equal(written[1:], expected[1:])
    os.remove(output)
示例#4
0
def test_tolerance():
    flux_h5m = "files_test_magic/iteration_1.h5m"
    ww_mesh = "files_test_magic/iteration_0.wwmesh"
    expected_file = "files_test_magic/tolerance_test.wwinp"
    output = "tolerance_test"

    if output in os.listdir("."):
        os.remove(output)

    magic.magic(flux_h5m, ww_mesh, False, 0, output, "None", 0.7)

    f = open(output)
    written = f.readlines()
    f.close

    g = open(expected_file)
    expected = g.readlines()
    g.close

    assert_equal(written[1:], expected[1:])
    os.remove(output)
示例#5
0
def test_block_1_2():
    flux_h5m = "files_test_magic/block_1_2_test.h5m"
    expected_file = "files_test_magic/block_1_2_test_expected_wwinp"
    output = "block_1_2_wwinp"

    if output in os.listdir("."):
        os.remove(output)

    magic.magic(flux_h5m, "None", False, 0, output, "None", 0.1)

    f = open(output)
    written = f.readlines()
    f.close

    g = open(expected_file)
    expected = g.readlines()
    g.close

    # exclude first line, it contain a date
    # everything else on the first line is the same for all wwinp files and is
    # therefore not particularly import to test.
    assert_equal(written[1:], expected[1:])
    os.remove(output)
示例#6
0
def test_magic_it_0_1_group():
    thisdir = os.path.dirname(__file__)
    flux_sm_filename = os.path.join(thisdir, 'files_test_magic/iteration_0_flux_1_group.h5m')
    flux_sm = ScdMesh.fromFile(flux_sm_filename)
    expected_sm_filename = os.path.join(thisdir, 'files_test_magic/iteration_0_magic_1_group.h5m')   
    expected_sm = ScdMesh.fromFile(expected_sm_filename)    

    totals_bool = False
    null_value = 1E-3
    tolerance = 0.2

    written_sm = magic.magic(flux_sm, totals_bool, null_value, tolerance)
    
    #verify weight window lower bounds are the same
    for x in range(0,3):
        for y in range(0,3):
            for z in range(0,3):
                expected_voxel = expected_sm.getHex(x,y,z)
                expected = expected_sm.imesh.getTagHandle('ww_n_group_001')[expected_voxel]
                written_voxel = written_sm.getHex(x,y,z)
                written = written_sm.imesh.getTagHandle('ww_n_group_001')[written_voxel]
                assert_equal(written, expected)
示例#7
0
def test_magic_it_0_1_group():
    thisdir = os.path.dirname(__file__)
    flux_sm_filename = os.path.join(thisdir, "files_test_magic/iteration_0_flux_1_group.h5m")
    flux_sm = ScdMesh.fromFile(flux_sm_filename)
    expected_sm_filename = os.path.join(thisdir, "files_test_magic/iteration_0_magic_1_group.h5m")
    expected_sm = ScdMesh.fromFile(expected_sm_filename)

    totals_bool = False
    null_value = 1e-3
    tolerance = 0.2

    written_sm = magic.magic(flux_sm, totals_bool, null_value, tolerance)

    # verify weight window lower bounds are the same
    for x in range(0, 3):
        for y in range(0, 3):
            for z in range(0, 3):
                expected_voxel = expected_sm.getHex(x, y, z)
                expected = expected_sm.imesh.getTagHandle("ww_n_group_001")[expected_voxel]
                written_voxel = written_sm.getHex(x, y, z)
                written = written_sm.imesh.getTagHandle("ww_n_group_001")[written_voxel]
                assert_equal(written, expected)